From c10b70757fc7c97e1f1ae01033e720e4d8b5992b Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 21 Mar 2026 14:42:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B5=84=E4=BA=A7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20device=5Frealtime=20=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=9B=BA=E5=AE=9A=E5=81=87=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E5=89=8D=E7=AB=AF=E5=9B=A0=20nil=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gateway 同步接口尚未对接,临时为设备类型资产返回 mock 数据, 后续对接后搜索 buildMockDeviceRealtime 替换为真实数据 --- internal/handler/app/client_asset.go | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/internal/handler/app/client_asset.go b/internal/handler/app/client_asset.go index b9917fb..0c4818c 100644 --- a/internal/handler/app/client_asset.go +++ b/internal/handler/app/client_asset.go @@ -185,6 +185,11 @@ func (h *ClientAssetHandler) GetAssetInfo(c *fiber.Ctx) error { BoundDeviceName: resolved.Asset.BoundDeviceName, } + // TODO: Gateway 同步接口对接后,替换为真实设备实时数据 + if resp.AssetType == "device" { + resp.DeviceRealtime = buildMockDeviceRealtime() + } + return response.Success(c, resp) } @@ -586,3 +591,45 @@ func packageStatusName(status int) string { 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, + } +}