common增加通用log模块
This commit is contained in:
96
log/model/dto/log_dto.go
Normal file
96
log/model/dto/log_dto.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"gitee.com/red-future---jilin-g/common/beans"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// ========== 操作日志查询相关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"`
|
||||
Module string `json:"module" dc:"模块名"`
|
||||
Service string `json:"service" dc:"服务名"`
|
||||
Operation string `json:"operation" dc:"操作类型"`
|
||||
Resource string `json:"resource" dc:"资源类型"`
|
||||
ResourceID string `json:"resource_id" dc:"资源ID"`
|
||||
UserID interface{} `json:"user_id" dc:"操作人ID"`
|
||||
UserName string `json:"user_name" dc:"操作人名称"`
|
||||
IPAddress string `json:"ip_address" dc:"操作IP地址"`
|
||||
UserAgent string `json:"user_agent" dc:"用户代理"`
|
||||
Description string `json:"description" dc:"操作描述"`
|
||||
BeforeData map[string]interface{} `json:"before_data" dc:"操作前的数据"`
|
||||
AfterData map[string]interface{} `json:"after_data" dc:"操作后的数据"`
|
||||
ExtraData map[string]interface{} `json:"extra_data" dc:"额外数据"`
|
||||
CreatedAt string `json:"created_at" dc:"创建时间"`
|
||||
UpdatedAt string `json:"updated_at" dc:"更新时间"`
|
||||
}
|
||||
|
||||
// ListLogsReq 查询操作日志列表请求(通用方法,支持根据不同条件动态查询)
|
||||
type ListLogsReq struct {
|
||||
g.Meta `path:"/listLogs" method:"get" tags:"操作日志" summary:"查询操作日志列表" dc:"根据多个条件查询操作日志列表"`
|
||||
beans.Page
|
||||
Module string `json:"module" dc:"模块名(可选)"`
|
||||
Service string `json:"service" dc:"服务名(可选)"`
|
||||
Operation string `json:"operation" dc:"操作类型(可选)"`
|
||||
Resource string `json:"resource" dc:"资源类型(可选)"`
|
||||
ResourceID string `json:"resource_id" dc:"资源ID(可选)"`
|
||||
UserID string `json:"user_id" dc:"用户ID(可选)"`
|
||||
StartTime string `json:"start_time" dc:"开始时间(可选)"`
|
||||
EndTime string `json:"end_time" dc:"结束时间(可选)"`
|
||||
SortFields string `json:"sort_fields" dc:"排序字段,多个用逗号分隔,如:-createdAt,module(可选)"`
|
||||
}
|
||||
|
||||
// ListLogsResp 查询操作日志列表响应
|
||||
type ListLogsResp struct {
|
||||
Logs []OperationLogInfo `json:"logs" dc:"日志列表"`
|
||||
Total int64 `json:"total" dc:"总数"`
|
||||
}
|
||||
|
||||
// ========== 记录操作日志DTO ==========
|
||||
|
||||
// RecordCreateLogReq 记录创建操作日志请求
|
||||
type RecordCreateLogReq struct {
|
||||
g.Meta `path:"/recordCreateLog" method:"post" tags:"操作日志" summary:"记录创建操作日志" dc:"记录数据创建操作的行为日志"`
|
||||
Module string `json:"module" v:"required" dc:"模块名"`
|
||||
Service string `json:"service" v:"required" dc:"服务名"`
|
||||
Resource string `json:"resource" v:"required" dc:"资源类型"`
|
||||
ResourceID string `json:"resource_id" v:"required" dc:"资源ID"`
|
||||
Description string `json:"description" dc:"操作描述"`
|
||||
AfterData map[string]interface{} `json:"after_data" dc:"操作后的数据"`
|
||||
}
|
||||
|
||||
// RecordUpdateLogReq 记录更新操作日志请求
|
||||
type RecordUpdateLogReq struct {
|
||||
g.Meta `path:"/recordUpdateLog" method:"post" tags:"操作日志" summary:"记录更新操作日志" dc:"记录数据更新操作的行为日志"`
|
||||
Module string `json:"module" v:"required" dc:"模块名"`
|
||||
Service string `json:"service" v:"required" dc:"服务名"`
|
||||
Resource string `json:"resource" v:"required" dc:"资源类型"`
|
||||
ResourceID string `json:"resource_id" v:"required" dc:"资源ID"`
|
||||
Description string `json:"description" dc:"操作描述"`
|
||||
BeforeData map[string]interface{} `json:"before_data" dc:"操作前的数据"`
|
||||
AfterData map[string]interface{} `json:"after_data" dc:"操作后的数据"`
|
||||
}
|
||||
|
||||
// RecordDeleteLogReq 记录删除操作日志请求
|
||||
type RecordDeleteLogReq struct {
|
||||
g.Meta `path:"/recordDeleteLog" method:"post" tags:"操作日志" summary:"记录删除操作日志" dc:"记录数据删除操作的行为日志"`
|
||||
Module string `json:"module" v:"required" dc:"模块名"`
|
||||
Service string `json:"service" v:"required" dc:"服务名"`
|
||||
Resource string `json:"resource" v:"required" dc:"资源类型"`
|
||||
ResourceID string `json:"resource_id" v:"required" dc:"资源ID"`
|
||||
Description string `json:"description" dc:"操作描述"`
|
||||
BeforeData map[string]interface{} `json:"before_data" dc:"操作前的数据"`
|
||||
}
|
||||
24
log/model/entity/log.go
Normal file
24
log/model/entity/log.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"gitee.com/red-future---jilin-g/common/do"
|
||||
)
|
||||
|
||||
// OperationLog 操作日志实体 - 用于记录数据增删改操作行为
|
||||
type OperationLog struct {
|
||||
do.MongoBaseDO `bson:",inline"`
|
||||
|
||||
Module string `bson:"module" json:"module"` // 模块名:如 order, wallet, market 等
|
||||
Service string `bson:"service" json:"service"` // 服务名:具体的微服务名称
|
||||
Operation string `bson:"operation" json:"operation"` // 操作类型:create, update, delete
|
||||
Resource string `bson:"resource" json:"resource"` // 资源类型:如 order, wallet, product 等
|
||||
ResourceID string `bson:"resource_id" json:"resource_id"` // 资源ID:具体操作的数据ID,如订单号、钱包ID等
|
||||
UserID interface{} `bson:"user_id" json:"user_id"` // 操作人ID
|
||||
UserName string `bson:"user_name" json:"user_name"` // 操作人名称
|
||||
IPAddress string `bson:"ip_address" json:"ip_address"` // 操作IP地址
|
||||
UserAgent string `bson:"user_agent" json:"user_agent"` // 用户代理
|
||||
Description string `bson:"description" json:"description"` // 操作描述
|
||||
BeforeData map[string]interface{} `bson:"before_data,omitempty" json:"before_data"` // 操作前的数据(用于update/delete)
|
||||
AfterData map[string]interface{} `bson:"after_data,omitempty" json:"after_data"` // 操作后的数据(用于create/update)
|
||||
ExtraData map[string]interface{} `bson:"extra_data,omitempty" json:"extra_data"` // 额外数据
|
||||
}
|
||||
Reference in New Issue
Block a user