Files
junhong_cmp_fiber/openspec/changes/archive/2026-04-30-add-asset-operation-audit-log/验收准备.md
2026-04-30 11:18:13 +08:00

59 lines
4.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 资产审计日志验收准备
## 0.1 资产敏感写操作覆盖矩阵
| 业务域 | 场景 | `operation_type` | 主要入口 |
|---|---|---|---|
| IoT 卡 | 分配 | `card_allocate` | `iot_card.Service.AllocateCards` |
| IoT 卡 | 回收 | `card_recall` | `iot_card.Service.RecallCards` |
| IoT 卡 | 系列绑定 | `card_series_binding` | `iot_card.Service.BatchSetSeriesBinding` |
| IoT 卡 | 轮询开关 | `card_polling_status` | `iot_card.Service.UpdatePollingStatus/BatchUpdatePollingStatus` |
| IoT 卡 | 实名策略 | `card_realname_policy` | `iot_card.Service.UpdateRealnamePolicy` |
| IoT 卡 | 手动实名状态 | `card_realname_status` | `iot_card.Service.ManualUpdateRealnameStatus` |
| IoT 卡 | 删除/批量删除 | `card_delete` / `card_batch_delete` | `iot_card.Service.DeleteCard/BatchDeleteCards` |
| IoT 卡停复机 | 自动停机/复机 | `card_auto_stop` / `card_auto_start` | `iot_card.StopResumeService.stopCardWithRetry/resumeSingleCard` |
| IoT 卡停复机 | 手动停机/复机 | `card_manual_stop` / `card_manual_start` | `iot_card.StopResumeService.ManualStopCard/ManualStartCard` |
| 设备 | 删除 | `device_delete` | `device.Service.Delete` |
| 设备 | 分配/回收 | `device_allocate` / `device_recall` | `device.Service.AllocateDevices/RecallDevices` |
| 设备 | 系列绑定 | `device_series_binding` | `device.Service.BatchSetSeriesBinding` |
| 设备 | 绑卡/解绑 | `device_bind_card` / `device_unbind_card` | `device.Service.BindCard/UnbindCard` |
| 设备 | 停机/复机 | `device_stop` / `device_start` | `device.Service.StopDevice/StartDevice` |
| 设备远程控制 | 限速 | `device_speed_limit` | `device.Service.GatewaySetSpeedLimit` |
| 设备远程控制 | WiFi 设置 | `device_set_wifi` | `device.Service.GatewaySetWiFi` |
| 设备远程控制 | 切卡 | `device_switch_card` | `device.Service.GatewaySwitchCard` |
| 设备远程控制 | 切卡模式 | `device_switch_mode` | `device.Service.GatewaySwitchMode` |
| 设备远程控制 | 重启/恢复出厂 | `device_reboot` / `device_reset` | `device.Service.GatewayRebootDevice/ResetDevice` |
| 统一资产入口 | 停用 | `asset_deactivate` | `asset.LifecycleService.DeactivateIotCard/DeactivateDevice` |
| 统一资产入口 | 轮询开关 | `asset_polling_status` | `polling.AssetPollingService.UpdatePollingStatus` |
| 统一资产入口 | 实名策略 | `asset_realname_policy` | `device.Service.UpdateRealnamePolicy`(设备路径) |
| 导入任务 | 设备导入任务创建 | `device_import_task_create` | `device_import.Service.CreateImportTask` |
| 导入任务 | 卡导入任务创建 | `iot_card_import_task_create` | `iot_card_import.Service.CreateImportTask` |
## 0.2 审计字段验收清单
| 字段组 | 核对项 | 说明 |
|---|---|---|
| `operator_*` | `operator_id/operator_type/operator_name` | 系统触发场景 `operator_type=system``operator_id` 可为空 |
| `asset_*` | `asset_type/asset_id/asset_identifier` | 设备使用虚拟号,卡使用 ICCID批量/导入场景允许按任务摘要记录 |
| `operation_*` | `operation_type/operation_desc` | `operation_type` 必须来自 `pkg/constants/asset_audit.go` |
| `before_data/after_data` | 变更镜像 | 状态/配置修改类要求体现前后差异 |
| `request_*` | `request_id/ip_address/user_agent/request_path/request_method` | 由日志中间件注入到 `context`,审计统一读取 |
| `result_*` | `result_status/error_code/error_msg` | 覆盖 `success/failed/denied`;失败/拒绝需记录错误摘要 |
| 批量聚合 | `batch_total/success_count/fail_count` | 批量与设备停复机场景需写入聚合统计 |
## 0.3 手工验收数据与脚本
### 接口回放建议Postman/curl
1. 成功样例:设备分配、卡分配、设备远程控制(限速)
2. 失败样例:远程控制网关失败、非法设备 ID、事务失败
3. 拒绝样例:停复机保护期、越权分配、无效实名策略
### SQL 脚本
- 统一查询脚本:`docs/add-asset-operation-audit-log/手工验收脚本.sql`
- 重点核对:
- 同一操作存在 `success/failed/denied` 三类结果
- `before_data/after_data` 存在且字段合理
- WiFi 密码字段已脱敏(不出现明文)