优化日志模块:重构操作日志记录与查询功能,支持批量操作日志记录,完善日志查询接口,增加软删除操作类型

This commit is contained in:
2026-01-16 16:55:32 +08:00
committed by 张斌
parent cc940c27b7
commit f0e6bdd37c
8 changed files with 260 additions and 300 deletions

View File

@@ -3,37 +3,13 @@ package dto
import (
"gitee.com/red-future---jilin-g/common/beans"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// ========== 操作日志查询相关DTO ==========
// GetLogReq 获取操作日志请求
type GetLogReq struct {
g.Meta `path:"/getLog" method:"get" tags:"操作日志" summary:"获取操作日志详情" dc:"根据日志ID获取操作日志的详细信息"`
ID string `json:"id" v:"required" dc:"日志ID"`
}
// GetLogResp 获取操作日志响应
type GetLogResp struct {
OperationLogInfo
}
// OperationLogInfo 操作日志信息
type OperationLogInfo struct {
ID string `json:"id" dc:"日志ID"`
ServiceName string `json:"service_name" dc:"服务名"`
Collection string `json:"collection" dc:"数据所在集合名称"`
CollectionID string `json:"collection_id" dc:"数据ID"`
Operation string `json:"operation" dc:"操作类型"`
UserName string `json:"user_name" dc:"操作人名称"`
IPAddress string `json:"ip_address" dc:"操作IP地址"`
Data map[string]interface{} `json:"data" dc:"当前数据"`
}
// ListLogsReq 查询操作日志列表请求(通用方法,支持根据不同条件动态查询)
type ListLogsReq struct {
g.Meta `path:"/listLogs" method:"get" tags:"操作日志" summary:"查询操作日志列表" dc:"根据多个条件查询操作日志列表"`
beans.Page
*beans.Page
ServiceName string `json:"service_name" dc:"服务名(可选)"`
Collection string `json:"collection" dc:"数据所在集合名称(可选)"`
CollectionID string `json:"collection_id" dc:"数据ID可选"`
@@ -48,3 +24,16 @@ type ListLogsResp struct {
Logs []OperationLogInfo `json:"logs" dc:"日志列表"`
Total int64 `json:"total" dc:"总数"`
}
// OperationLogInfo 操作日志信息
type OperationLogInfo struct {
ID string `json:"id" dc:"日志ID"`
ServiceName string `json:"service_name" dc:"服务名"`
Collection string `json:"collection" dc:"数据所在集合名称"`
CollectionID interface{} `json:"collection_id" dc:"数据ID"`
Operation string `json:"operation" dc:"操作类型"`
Creator string `json:"creator" dc:"操作人名称"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
Data interface{} `json:"data" dc:"当前数据"`
IPAddress string `json:"ip_address" dc:"操作IP地址"`
}