feat: add audit and app log services

This commit is contained in:
QiuSW
2026-07-09 00:55:46 +08:00
parent 3bd05b316e
commit 769c861eb0
20 changed files with 804 additions and 30 deletions
+12 -8
View File
@@ -99,27 +99,31 @@
- 任务主表为 `image_tasks`,结果表为 `image_task_results`。
- 模拟任务会生成成功状态、耗时、输出路径和前后文件大小字段,供后续页面和统计模块使用。
## 目标新增服务
### AuditLogService
目标方法:
文件:`internal/services/log_service.go`
- `Record(action string, targetType string, targetID string, detail string) error`:记录审计事件。
- `List(filter AuditLogFilter) ([]AuditLog, error)`:分页查询审计日志。
- `Export(filter AuditLogFilter) (string, error)`:导出审计日志文件。
- `List(filter models.AuditLogFilter) ([]models.AuditLog, error)`:分页查询审计日志。
约束:
审计日志记录用户动作,不记录系统堆栈。
当前已接入登录、设置变更和图片任务创建。
### AppLogService
目标方法:
文件:`internal/services/log_service.go`
- `Record(level string, module string, message string, detail string) error`:记录运行日志。
- `List(filter AppLogFilter) ([]AppLog, error)`:分页查询运行日志。
- `Export(filter AppLogFilter) (string, error)`:导出运行日志文件。
- `List(filter models.AppLogFilter) ([]models.AppLog, error)`:分页查询运行日志。
约束:
运行日志用于排错,可以记录错误详情和模块名。
当前已接入图片任务创建失败和服务内部错误路径。
## 目标新增服务
### MetricsService