mongo开发工具类增加增删改操作日志写入redis消息逻辑

This commit is contained in:
2025-12-30 18:18:56 +08:00
parent 5ded2b08a2
commit 8c4918e4ed
6 changed files with 106 additions and 138 deletions

View File

@@ -8,17 +8,11 @@ import (
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"` // 额外数据
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等
Operation string `bson:"operation" json:"operation"` // 操作类型:create, update, delete
UserName string `bson:"user_name" json:"user_name"` // 操作人名称
IPAddress string `bson:"ip_address" json:"ip_address"` // 操作IP地址
Data map[string]interface{} `bson:"data,omitempty" json:"data"` // 当前数据:操作时的数据状态
}