From c283409b9e860975ba789f86c3d66d060bad903f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=81=92?= <2390904403@qq.com> Date: Thu, 25 Sep 2025 14:23:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=BE=E5=A4=87=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=97=A5=E5=BF=97=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/rpc/device.go | 22 ++++++++++++++++++++++ pkg/rpc/type.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/pkg/rpc/device.go b/pkg/rpc/device.go index 095d2ff..541cac1 100644 --- a/pkg/rpc/device.go +++ b/pkg/rpc/device.go @@ -195,6 +195,28 @@ func (d *Device) GetVoiceAssistant(deviceId uint32) (*VoiceAssistant, error) { 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 // 获取设备相关RPC类 diff --git a/pkg/rpc/type.go b/pkg/rpc/type.go index b3d908a..9a1adcd 100644 --- a/pkg/rpc/type.go +++ b/pkg/rpc/type.go @@ -81,3 +81,33 @@ type VoiceAssistant struct { 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 +)