Files
rpc-client/pkg/rpc/type.go
2025-09-19 18:00:55 +08:00

83 lines
2.2 KiB
Go

package rpc
// 结果Code
type ResultCode uint16
const (
// 响应Code 正常
ResultCodeSuccess ResultCode = 0
// 响应Code 失败
ResultCodeError ResultCode = 10000
// 响应Code 参数异常
ResultCodeParamError ResultCode = 10001
// 响应Code 操作失败
ResultCodeActionFail ResultCode = 10002
// 响应Code 数据不存在
ResultCodeDataNotExist ResultCode = 10003
// 响应Code 签名错误
ResultCodeSignError ResultCode = 10105
// 服务通讯失败
ResultCodeServiceCommunicationFail ResultCode = 11000
// 数据解析失败
ResultCodeDataParseFail ResultCode = 11001
// 操作不存在
ResultCodeOperationNotExist ResultCode = 11002
// 设备不存在
ResultCodeDeviceNotExist ResultCode = 11003
// 设备信息不在线
ResultCodeDeviceOffline ResultCode = 11004
// 设备响应超时
ResultCodeDeviceResponseTimeout ResultCode = 11005
// 设备属性不可操作
ResultCodeDeviceAttributeCannotOperation ResultCode = 11006
// 设备属性不存在
ResultCodeDeviceAttributeNotExits ResultCode = 11007
)
// 响应结果
type Result[D any] struct {
Code ResultCode `json:"code"`
Message string `json:"message"`
Data D `json:"data"`
}
// 设备详情
type DeviceDetail struct {
Type uint8 `json:"type"`
ConnectType uint8 `json:"connect_type"`
Secret string `json:"secret"`
PId uint32 `json:"p_id"`
DataId uint32 `json:"data_id"`
}
// 设备属性参数
type DeviceAttributeOption struct {
Type uint8 `json:"type"`
ContentType uint8 `json:"content_type"`
Attribute []struct {
Type uint8 `json:"type"`
Name string `json:"name"`
Flag uint8 `json:"flag"`
Field string `json:"field"`
Readonly bool `json:"readonly"`
AllowItem *[]uint8 `json:"allow_item,omitempty"`
Min *uint32 `json:"min,omitempty"`
Max *uint32 `json:"max,omitempty"`
} `json:"attribute"`
}
// Websocket签名数据
type WebsocketSignData struct {
UserId uint32 `json:"user_id"`
Platform string `json:"platform"`
}
// 语音助手数据
type VoiceAssistant struct {
Id uint32 `json:"id"`
Type uint8 `json:"type"`
BemFaEnable uint8 `json:"bem_fa_enable"`
BemFaName string `json:"bem_fa_name"`
}