Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f5116a4a1 | |||
| 89542f9475 | |||
| 3333514cff | |||
| c283409b9e | |||
| 207b56e419 | |||
| 69e7893d27 |
@@ -10,7 +10,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"gitee.com/LifetimeNine/singularity-rpc-client/pkg/rpc"
|
"git.lifetime-nine.cn/singularity/rpc-client/pkg/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module gitee.com/LifetimeNine/singularity-rpc-client
|
module git.lifetime-nine.cn/singularity/rpc-client
|
||||||
|
|
||||||
go 1.24.3
|
go 1.24.3
|
||||||
|
|
||||||
|
|||||||
@@ -151,18 +151,68 @@ func (d *Device) UpdateVersion(deviceId uint32, versionNumber uint) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存升级结果
|
// 保存升级结果
|
||||||
func (d *Device) SaveUpgradeResult(upgradeTaskId uint32, status uint8, finishTime time.Time) error {
|
func (d *Device) SaveUpgradeResult(upgradeTaskId uint32, result uint8, finishTime time.Time) error {
|
||||||
body := map[string]any{
|
body := map[string]any{
|
||||||
"upgrade_task_id": upgradeTaskId,
|
"upgrade_task_id": upgradeTaskId,
|
||||||
"status": status,
|
"result": result,
|
||||||
"finish_time": finishTime.Format(time.DateTime),
|
"finish_time": finishTime.Format(time.DateTime),
|
||||||
}
|
}
|
||||||
result := &Result[any]{}
|
res := &Result[any]{}
|
||||||
if err := GetRequest().Send("device.save_upgrade_result", body, result); err != nil {
|
if err := GetRequest().Send("device.save_upgrade_result", body, res); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if res.Code != 0 {
|
||||||
|
return fmt.Errorf("%s", res.Message)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取语音助手参数列表
|
||||||
|
func (d *Device) GetVoiceAssistantList() ([]VoiceAssistant, error) {
|
||||||
|
body := map[string]any{}
|
||||||
|
result := &Result[[]VoiceAssistant]{}
|
||||||
|
if err := GetRequest().Send("device.get_voice_assistant_list", body, result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if result.Code != 0 {
|
if result.Code != 0 {
|
||||||
return fmt.Errorf("%s", result.Message)
|
return nil, fmt.Errorf("%s", result.Message)
|
||||||
|
}
|
||||||
|
return result.Data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取设备语音助手参数
|
||||||
|
func (d *Device) GetVoiceAssistant(deviceId uint32) (*VoiceAssistant, error) {
|
||||||
|
body := map[string]any{
|
||||||
|
"device_id": deviceId,
|
||||||
|
}
|
||||||
|
result := &Result[*VoiceAssistant]{}
|
||||||
|
if err := GetRequest().Send("device.get_voice_assistant", body, result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if result.Code != 0 {
|
||||||
|
return nil, fmt.Errorf("%s", result.Message)
|
||||||
|
}
|
||||||
|
return result.Data, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录设备操作日志
|
||||||
|
func (d *Device) RecordOperationLog(deviceId uint32, platform DeviceOperationLogPlatform, attribute string, value any, valueType uint8, result DeviceOperationLogResult, reason *string, userId *uint32) error {
|
||||||
|
body := map[string]any{
|
||||||
|
"device_id": deviceId,
|
||||||
|
"platform": platform,
|
||||||
|
"attribute": attribute,
|
||||||
|
"value": value,
|
||||||
|
"value_type": valueType,
|
||||||
|
"result": result,
|
||||||
|
"reason": reason,
|
||||||
|
"user_id": userId,
|
||||||
|
}
|
||||||
|
res := &Result[any]{}
|
||||||
|
if err := GetRequest().Send("device.record_operation_log", body, res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if res.Code != 0 {
|
||||||
|
return fmt.Errorf("%s", res.Message)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,3 +72,42 @@ type WebsocketSignData struct {
|
|||||||
UserId uint32 `json:"user_id"`
|
UserId uint32 `json:"user_id"`
|
||||||
Platform string `json:"platform"`
|
Platform string `json:"platform"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 语音助手数据
|
||||||
|
type VoiceAssistant struct {
|
||||||
|
Id uint32 `json:"id"`
|
||||||
|
Type uint8 `json:"type"`
|
||||||
|
OnlineStatus uint8 `json:"online_status"`
|
||||||
|
BemFaEnable uint8 `json:"bem_fa_enable"`
|
||||||
|
BemFaName string `json:"bem_fa_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设备操作日志平台
|
||||||
|
type DeviceOperationLogPlatform uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// 设备操作日志平台 - 管理后台
|
||||||
|
DeviceOperationLogPlatformBackstage DeviceOperationLogPlatform = iota + 1
|
||||||
|
// 设备操作日志平台 - 语音助手
|
||||||
|
DeviceOperationLogPlatformAssistant
|
||||||
|
// 设备操作日志平台 - 设备
|
||||||
|
DeviceOperationLogPlatformDevice
|
||||||
|
// 设备操作日志平台 - APP
|
||||||
|
DeviceOperationLogPlatformApp
|
||||||
|
// 设备操作日志平台 - 自动化
|
||||||
|
DeviceOperationLogPlatformAutomation
|
||||||
|
// 设备操作日志平台 - 桌面端
|
||||||
|
DeviceOperationLogPlatformDesktop
|
||||||
|
// 设备操作日志平台 - API
|
||||||
|
DeviceOperationLogPlatformAPI
|
||||||
|
)
|
||||||
|
|
||||||
|
// 设备操作日志结果
|
||||||
|
type DeviceOperationLogResult uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
// 设备操作日志结果 - 成功
|
||||||
|
DeviceOperationLogResultSuccess DeviceOperationLogResult = iota + 1
|
||||||
|
// 设备操作日志结果 - 失败
|
||||||
|
DeviceOperationLogResultFail
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user