Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a0b0f33b1e | |||
| a05373e50c | |||
| df5fb556a0 |
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新设备版本信息
|
// 更新设备版本信息
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -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"` // 类型
|
||||||
@@ -150,7 +149,8 @@ type AutomationTask struct {
|
|||||||
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"` // 事件条件列表
|
||||||
|
StatusConditionList []AutomationCondition `json:"status_condition_list"` // 事件条件列表
|
||||||
ActionList []AutomationAction `json:"action_list"` // 动作列表
|
ActionList []AutomationAction `json:"action_list"` // 动作列表
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user