优化日志模块:重构操作日志记录与查询功能,支持批量操作日志记录,完善日志查询接口,增加软删除操作类型
This commit is contained in:
@@ -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地址"`
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ type OperationLog struct {
|
||||
|
||||
ServiceName string `bson:"service_name" json:"service_name"` // 服务名:具体的微服务名称
|
||||
Collection string `bson:"collection" json:"collection"` // 集合名:数据所在的集合名称
|
||||
CollectionID string `bson:"collection_id" json:"collection_id"` // 数据ID:具体操作的数据ID,如订单号、钱包ID等
|
||||
CollectionID interface{} `bson:"collection_id" json:"collection_id"` // 数据ID:具体操作的数据ID,如订单号、钱包ID等
|
||||
Operation string `bson:"operation" json:"operation"` // 操作类型:create, update, delete
|
||||
IPAddress string `bson:"ip_address" json:"ip_address"` // 操作IP地址
|
||||
Data interface{} `bson:"data,omitempty" json:"data"` // 当前数据:操作时的数据状态
|
||||
|
||||
Reference in New Issue
Block a user