12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package admin
- import (
- "fmt"
- "server/dao"
- "server/model/common/request"
- )
- type TunnelService struct{}
- func (ts *TunnelService) QueryAllTunnels() ([]dao.Tunnel, error) {
- return dao.QueryAllTunnels()
- }
- func (ts *TunnelService) QueryTunnelList(info request.TunnelSearch) ([]dao.Tunnel, int64, error) {
- limit := info.PageInfo.PageSize
- offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
- return dao.QueryTunnelList(info.Name, info.RegionId, limit, offset)
- }
- func (ts *TunnelService) QueryNoRegionTunnels() ([]dao.Tunnel, error) {
- return dao.QueryNoRegionTunnels()
- }
- func (ts *TunnelService) CreateTunnel(tunnel dao.Tunnel) error {
- return tunnel.CreateTunnel()
- }
- func (ts *TunnelService) UpdateTunnel(tunnel dao.Tunnel) error {
- return tunnel.UpdateTunnel()
- }
- func (ts *TunnelService) UpdateTunnelsRegion(tunnelIds []int, regionId int) error {
- return dao.UpdateTunnelsRegion(tunnelIds, regionId)
- }
- func (ts *TunnelService) UpdateTunnelTime(time dao.TunnelTime) error {
- time.IsComplete = false
- return time.UpdateTunnelTime()
- }
- func (ts *TunnelService) TunnelTimeOk(sn string) error {
- return dao.TunnelTimeOk(sn)
- }
- func (ts *TunnelService) DeleteTunnel(id int) error {
- devices, err := dao.QueryDeviceByTunnelId(id)
- if err != nil {
- return err
- }
- if len(devices) > 0 {
- return fmt.Errorf("存在数据不能删除")
- }
- return dao.DeleteTunnel(id)
- }
|