3 Commits

Author SHA1 Message Date
a0b0f33b1e websocket签名方法调整 2025-10-22 16:31:53 +08:00
a05373e50c 修改设备参数返回值 2025-10-17 17:31:52 +08:00
df5fb556a0 修改自动化方法返回数据参数 2025-10-17 17:10:47 +08:00
4 changed files with 44 additions and 60 deletions

View File

@@ -120,7 +120,7 @@ func (d *Device) SetAttribute(deviceId uint32, attributeSet map[string]any) erro
} }
// 获取设备属性 // 获取设备属性
func (d *Device) GetAttribute(deviceId uint32) (*map[string]any, error) { func (d *Device) GetAttribute(deviceId uint32) (map[string]any, error) {
body := map[string]any{ body := map[string]any{
"device_id": deviceId, "device_id": deviceId,
} }
@@ -131,7 +131,7 @@ func (d *Device) GetAttribute(deviceId uint32) (*map[string]any, error) {
if result.Code != 0 { if result.Code != 0 {
return nil, fmt.Errorf("%s", result.Message) return nil, fmt.Errorf("%s", result.Message)
} }
return &result.Data, nil return result.Data, nil
} }
// 更新设备版本信息 // 更新设备版本信息

View File

@@ -1,46 +0,0 @@
package rpc
import "fmt"
// 服务相关RPC
type Server struct{}
// 获取Websocket签名信息
func (s *Server) GetWebsocketSignData(sign string) (*WebsocketSignData, error) {
body := map[string]any{
"sign": sign,
}
result := &Result[WebsocketSignData]{}
if err := GetRequest().Send("server.get_websocket_sign", body, result); err != nil {
return nil, err
}
if result.Code != 0 {
return nil, fmt.Errorf("%s", result.Message)
}
return &result.Data, nil
}
// 删除Websocket签名
func (s *Server) DeleteWebsocketSign(sign string) error {
body := map[string]any{
"sign": sign,
}
result := &Result[WebsocketSignData]{}
if err := GetRequest().Send("server.get_websocket_sign", body, result); err != nil {
return err
}
if result.Code != 0 {
return fmt.Errorf("%s", result.Message)
}
return nil
}
var server *Server
// 获取服务相关RPC类
func GetServer() *Server {
if server == nil {
server = &Server{}
}
return server
}

View File

@@ -127,7 +127,6 @@ type AutomationCondition struct {
} }
// 自动化动作 // 自动化动作
type AutomationAction struct { type AutomationAction struct {
Id uint32 `json:"id"` // ID Id uint32 `json:"id"` // ID
Type uint8 `json:"type"` // 类型 Type uint8 `json:"type"` // 类型
@@ -141,17 +140,18 @@ type AutomationAction struct {
// 自动化任务 // 自动化任务
type AutomationTask struct { type AutomationTask struct {
Id uint32 `json:"id"` // ID Id uint32 `json:"id"` // ID
Title string `json:"title"` // 标题 Title string `json:"title"` // 标题
CreateUserId uint32 `json:"create_user_id"` // 创建用户ID CreateUserId uint32 `json:"create_user_id"` // 创建用户ID
EffectivePeriod uint8 `json:"effective_period"` // 生效时段 EffectivePeriod uint8 `json:"effective_period"` // 生效时段
PeriodBeginTime *string `json:"period_begin_time,omitempty"` // 时段开始时间 PeriodBeginTime *string `json:"period_begin_time,omitempty"` // 时段开始时间
PeriodEndTime *string `json:"period_end_time,omitempty"` // 时段结束时间 PeriodEndTime *string `json:"period_end_time,omitempty"` // 时段结束时间
RepeatType uint8 `json:"repeat_type"` // 重复类型 RepeatType uint8 `json:"repeat_type"` // 重复类型
CustomRepeatRange []uint8 `json:"custom_repeat_range"` // 自定义重复范围 CustomRepeatRange []uint8 `json:"custom_repeat_range"` // 自定义重复范围
IsSatisfyAll uint8 `json:"is_satisfy_all"` // 是否要满足所有条件 IsSatisfyAll uint8 `json:"is_satisfy_all"` // 是否要满足所有条件
ConditionList []AutomationCondition `json:"condition_list"` // 条件列表 EventConditionList []AutomationCondition `json:"event_condition_list"` // 事件条件列表
ActionList []AutomationAction `json:"action_list"` // 动作列表 StatusConditionList []AutomationCondition `json:"status_condition_list"` // 事件条件列表
ActionList []AutomationAction `json:"action_list"` // 动作列表
} }
// 系统位置 // 系统位置

View File

@@ -21,6 +21,36 @@ func (u *User) GetDetail(userId uint32) (*UserDetail, error) {
return &result.Data, nil return &result.Data, nil
} }
// 获取Websocket签名信息
func (s *User) GetWebsocketSignData(sign string) (*WebsocketSignData, error) {
body := map[string]any{
"sign": sign,
}
result := &Result[WebsocketSignData]{}
if err := GetRequest().Send("user.get_websocket_sign", body, result); err != nil {
return nil, err
}
if result.Code != 0 {
return nil, fmt.Errorf("%s", result.Message)
}
return &result.Data, nil
}
// 删除Websocket签名
func (s *User) DeleteWebsocketSign(sign string) error {
body := map[string]any{
"sign": sign,
}
result := &Result[WebsocketSignData]{}
if err := GetRequest().Send("user.get_websocket_sign", body, result); err != nil {
return err
}
if result.Code != 0 {
return fmt.Errorf("%s", result.Message)
}
return nil
}
var user *User var user *User
// 获取用户相关RPC // 获取用户相关RPC