docOperationLogs

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveOrCreateById

func SaveOrCreateById(entity *Entity) int64

Types

type Entity

type Entity struct {
	Id            uint64    `gorm:"primaryKey;column:id;autoIncrement;not null;" json:"id"`                           // 日志ID
	EntityType    string    `gorm:"column:entity_type;type:varchar(50);not null;default:'';" json:"entityType"`       // 实体类型
	EntityId      uint64    `gorm:"column:entity_id;type:bigint unsigned;not null;default:0;" json:"entityId"`        // 实体ID
	OperationType string    `gorm:"column:operation_type;type:varchar(20);not null;default:'';" json:"operationType"` // 操作类型(create/update/delete)
	FieldName     string    `gorm:"column:field_name;type:varchar(100);" json:"fieldName"`                            // 字段名称
	OldValue      string    `gorm:"column:old_value;type:text;" json:"oldValue"`                                      // 旧值
	NewValue      string    `gorm:"column:new_value;type:text;" json:"newValue"`                                      // 新值
	Metadata      string    `gorm:"column:metadata;type:json;" json:"metadata"`                                       // 扩展元数据
	UserId        uint64    `gorm:"column:user_id;type:bigint unsigned;not null;default:0;" json:"userId"`            // 操作用户ID
	IpAddress     string    `gorm:"column:ip_address;type:varchar(45);" json:"ipAddress"`                             // 操作IP地址
	UserAgent     string    `gorm:"column:user_agent;type:text;" json:"userAgent"`                                    // 用户代理
	CreatedAt     time.Time `gorm:"column:created_at;index;autoCreateTime;<-:create;" json:"createdAt"`               // 创建时间
}

func Get

func Get(id any) (entity Entity)

func (*Entity) TableName

func (itself *Entity) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL