feat(03-01): Gateway SyncDeviceInfo 方法 + DTO 字段扩展
- gateway/models.go:新增 SyncDeviceInfoReq / SyncDeviceInfoResp 结构定义 - gateway/device.go:新增 SyncDeviceInfo() 方法,POST /device/sync-info - device_dto.go:DeviceResponse 新增 5 个 sync-info 同步字段;DeviceCardBindingResponse 新增 is_current - asset_dto.go:BoundCardInfo 新增 is_current 字段
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Package gateway 提供设备相关的 7 个 API 方法封装
|
||||
// Package gateway 提供设备相关的 8 个 API 方法封装
|
||||
package gateway
|
||||
|
||||
import (
|
||||
@@ -68,3 +68,13 @@ func (c *Client) RebootDevice(ctx context.Context, req *DeviceOperationReq) erro
|
||||
_, err := c.doRequest(ctx, "/device/restart", req)
|
||||
return err
|
||||
}
|
||||
|
||||
// SyncDeviceInfo 同步查询设备信息(直接返回,无需回调)
|
||||
// 与异步 /device/info 的区别:直接返回全量数据,无需 callbackUrl
|
||||
// POST /device/sync-info
|
||||
func (c *Client) SyncDeviceInfo(ctx context.Context, req *SyncDeviceInfoReq) (*SyncDeviceInfoResp, error) {
|
||||
if req.CardNo == "" {
|
||||
return nil, errors.New(errors.CodeInvalidParam, "cardNo 不能为空")
|
||||
}
|
||||
return doRequestWithResponse[SyncDeviceInfoResp](c, ctx, "/device/sync-info", req)
|
||||
}
|
||||
|
||||
@@ -131,3 +131,31 @@ type SlotInfoResp struct {
|
||||
Slots []SlotInfo `json:"slots" description:"卡槽信息列表"`
|
||||
Extend string `json:"extend,omitempty" description:"扩展字段(广电国网特殊参数)"`
|
||||
}
|
||||
|
||||
// SyncDeviceInfoReq sync-info 同步查询设备信息请求
|
||||
// cardNo 规则:>15 位用 ICCID,=15 位用 IMEI,=11 位用 SN
|
||||
type SyncDeviceInfoReq struct {
|
||||
CardNo string `json:"card_no" description:"设备标识(ICCID/IMEI/SN)"`
|
||||
}
|
||||
|
||||
// SyncDeviceInfoResp sync-info 同步查询设备信息响应(对应 Gateway data 字段)
|
||||
// 注意:所有字段均可能为 null/零值,表示暂无数据
|
||||
type SyncDeviceInfoResp struct {
|
||||
DeviceID string `json:"device_id" description:"设备ID(IMEI/SN)"`
|
||||
DeviceName string `json:"device_name" description:"设备名称"`
|
||||
IMEI string `json:"imei" description:"IMEI号"`
|
||||
CurrentIccid string `json:"current_iccid" description:"当前使用的ICCID"`
|
||||
DeviceType string `json:"device_type" description:"设备类型:1=诺行,2=玺龙,3=迎势达"`
|
||||
SoftwareVersion string `json:"software_version" description:"软件版本号"`
|
||||
MacAddress string `json:"mac_address" description:"MAC地址"`
|
||||
SSID string `json:"ssid" description:"WiFi热点名称"`
|
||||
WifiEnabled bool `json:"wifi_enabled" description:"WiFi开关状态"`
|
||||
SwitchMode string `json:"switch_mode" description:"切卡模式:0=自动,1=手动"`
|
||||
RSSI string `json:"rssi" description:"接收信号强度"`
|
||||
BatteryLevel *int `json:"battery_level" description:"电池电量百分比(无电池时为null)"`
|
||||
OnlineStatus int `json:"online_status" description:"在线状态:1=在线,2=离线"`
|
||||
LastUpdateTime string `json:"last_update_time" description:"设备信息最后更新时间(ISO 8601)"`
|
||||
LastOnlineTime string `json:"last_online_time" description:"设备最后在线时间(ISO 8601)"`
|
||||
RunTime string `json:"run_time" description:"本次开机运行时间(秒)"`
|
||||
DailyUsage string `json:"daily_usage" description:"日使用流量(字节)"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user