fix: 资产信息接口 device_realtime 字段返回固定假数据,避免前端因 nil 报错
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m58s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m58s
Gateway 同步接口尚未对接,临时为设备类型资产返回 mock 数据, 后续对接后搜索 buildMockDeviceRealtime 替换为真实数据
This commit is contained in:
@@ -185,6 +185,11 @@ func (h *ClientAssetHandler) GetAssetInfo(c *fiber.Ctx) error {
|
|||||||
BoundDeviceName: resolved.Asset.BoundDeviceName,
|
BoundDeviceName: resolved.Asset.BoundDeviceName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Gateway 同步接口对接后,替换为真实设备实时数据
|
||||||
|
if resp.AssetType == "device" {
|
||||||
|
resp.DeviceRealtime = buildMockDeviceRealtime()
|
||||||
|
}
|
||||||
|
|
||||||
return response.Success(c, resp)
|
return response.Success(c, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,3 +591,45 @@ func packageStatusName(status int) string {
|
|||||||
return "未知"
|
return "未知"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// buildMockDeviceRealtime 构建设备实时状态假数据
|
||||||
|
// TODO: Gateway 同步接口对接后移除此函数,改为调用 Gateway 接口获取真实数据
|
||||||
|
func buildMockDeviceRealtime() *dto.DeviceRealtimeInfo {
|
||||||
|
onlineStatus := int64(1)
|
||||||
|
batteryLevel := int64(85)
|
||||||
|
deviceStatus := int64(1)
|
||||||
|
runTime := "3600"
|
||||||
|
connectTime := "3500"
|
||||||
|
rsrp := int64(-80)
|
||||||
|
rsrq := int64(-10)
|
||||||
|
rssi := "-65"
|
||||||
|
sinr := int64(15)
|
||||||
|
ssid := "JunHong-WiFi"
|
||||||
|
wifiEnabled := true
|
||||||
|
wifiPassword := "12345678"
|
||||||
|
ipAddress := "192.168.1.1"
|
||||||
|
lanIP := "192.168.1.1"
|
||||||
|
dailyUsage := "0"
|
||||||
|
maxClients := int64(32)
|
||||||
|
switchMode := 0
|
||||||
|
|
||||||
|
return &dto.DeviceRealtimeInfo{
|
||||||
|
OnlineStatus: &onlineStatus,
|
||||||
|
BatteryLevel: &batteryLevel,
|
||||||
|
Status: &deviceStatus,
|
||||||
|
RunTime: &runTime,
|
||||||
|
ConnectTime: &connectTime,
|
||||||
|
Rsrp: &rsrp,
|
||||||
|
Rsrq: &rsrq,
|
||||||
|
Rssi: &rssi,
|
||||||
|
Sinr: &sinr,
|
||||||
|
SSID: &ssid,
|
||||||
|
WifiEnabled: &wifiEnabled,
|
||||||
|
WifiPassword: &wifiPassword,
|
||||||
|
IPAddress: &ipAddress,
|
||||||
|
LANIP: &lanIP,
|
||||||
|
DailyUsage: &dailyUsage,
|
||||||
|
MaxClients: &maxClients,
|
||||||
|
SwitchMode: &switchMode,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user