|
@@ -3,6 +3,7 @@ package service
|
|
|
import (
|
|
|
"fmt"
|
|
|
"iot_manager_service/app/device/dao"
|
|
|
+ "iot_manager_service/app/device/model"
|
|
|
"iot_manager_service/app/system/service"
|
|
|
"iot_manager_service/util"
|
|
|
"time"
|
|
@@ -12,7 +13,7 @@ var IpBroadcastService = new(ipBroadcastService)
|
|
|
|
|
|
type ipBroadcastService struct{}
|
|
|
|
|
|
-func (s *ipBroadcastService) Get(id int) (*dao.IpBroadcast, *util.Errors) {
|
|
|
+func (s *ipBroadcastService) Get(id int) (*model.IpBroadcastDetail, *util.Errors) {
|
|
|
// 创建查询实例
|
|
|
device := &dao.IpBroadcast{
|
|
|
ID: id,
|
|
@@ -21,8 +22,13 @@ func (s *ipBroadcastService) Get(id int) (*dao.IpBroadcast, *util.Errors) {
|
|
|
if err != nil {
|
|
|
return nil, util.FailResponse(err.Error(), nil)
|
|
|
}
|
|
|
- return device, nil
|
|
|
-
|
|
|
+ endTime, state := util.GetDeviceState(device.CastSn)
|
|
|
+ return &model.IpBroadcastDetail{
|
|
|
+ IpBroadcast: *device,
|
|
|
+ RunState: state,
|
|
|
+ NetworkState: state,
|
|
|
+ EndLineTime: endTime,
|
|
|
+ }, nil
|
|
|
}
|
|
|
|
|
|
func (s *ipBroadcastService) CreateOrUpdate(userId int64, tenantId int, req dao.IpBroadcast) *util.Errors {
|
|
@@ -60,7 +66,7 @@ func (s *ipBroadcastService) CreateOrUpdate(userId int64, tenantId int, req dao.
|
|
|
return util.SuccessResponse(util.Succeeded, nil)
|
|
|
}
|
|
|
|
|
|
-func (s *ipBroadcastService) List(searchValue string, current, size int) ([]dao.IpBroadcast, *util.Errors) {
|
|
|
+func (s *ipBroadcastService) List(searchValue string, current, size int) ([]model.IpBroadcastDetail, *util.Errors) {
|
|
|
device := dao.IpBroadcast{}
|
|
|
if searchValue != "" {
|
|
|
device.CastSn = searchValue
|
|
@@ -73,7 +79,17 @@ func (s *ipBroadcastService) List(searchValue string, current, size int) ([]dao.
|
|
|
if err != nil {
|
|
|
return nil, util.FailResponse(err.Error(), nil)
|
|
|
}
|
|
|
- return devices, nil
|
|
|
+ var details []model.IpBroadcastDetail
|
|
|
+ for _, d := range devices {
|
|
|
+ endTime, state := util.GetDeviceState(d.CastSn)
|
|
|
+ details = append(details, model.IpBroadcastDetail{
|
|
|
+ IpBroadcast: d,
|
|
|
+ RunState: state,
|
|
|
+ NetworkState: state,
|
|
|
+ EndLineTime: endTime,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return details, nil
|
|
|
}
|
|
|
|
|
|
func (s *ipBroadcastService) Remove(userId int64, tenantId int, id int) *util.Errors {
|