5 Commits

Author SHA1 Message Date
5f5116a4a1 修改文档 2025-10-16 10:53:25 +08:00
89542f9475 修改模块地址 2025-10-16 10:45:49 +08:00
3333514cff 修改保存升级结果方法参数 2025-10-07 20:12:38 +08:00
c283409b9e 添加设备操作日志方法 2025-09-25 14:23:17 +08:00
207b56e419 语音助手参数添加在线状态字段 2025-09-20 17:42:05 +08:00
4 changed files with 65 additions and 12 deletions

View File

@@ -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
View File

@@ -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

View File

@@ -151,18 +151,18 @@ 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 result.Code != 0 { if res.Code != 0 {
return fmt.Errorf("%s", result.Message) return fmt.Errorf("%s", res.Message)
} }
return nil return nil
} }
@@ -195,6 +195,28 @@ func (d *Device) GetVoiceAssistant(deviceId uint32) (*VoiceAssistant, error) {
return result.Data, nil 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
}
var device *Device var device *Device
// 获取设备相关RPC类 // 获取设备相关RPC类

View File

@@ -77,6 +77,37 @@ type WebsocketSignData struct {
type VoiceAssistant struct { type VoiceAssistant struct {
Id uint32 `json:"id"` Id uint32 `json:"id"`
Type uint8 `json:"type"` Type uint8 `json:"type"`
OnlineStatus uint8 `json:"online_status"`
BemFaEnable uint8 `json:"bem_fa_enable"` BemFaEnable uint8 `json:"bem_fa_enable"`
BemFaName string `json:"bem_fa_name"` 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
)