Files
backend/internal/model/data_change_log.go

57 lines
2.1 KiB
Go
Raw Normal View History

package model
import (
"time"
)
// ChangeType 变更类型
type ChangeType string
const (
ChangePassword ChangeType = "password"
ChangePhone ChangeType = "phone"
ChangeEmail ChangeType = "email"
ChangeNickName ChangeType = "nickname"
ChangeAvatar ChangeType = "avatar"
ChangeProfile ChangeType = "profile"
ChangePrivacy ChangeType = "privacy"
ChangeDelete ChangeType = "delete"
ChangeExport ChangeType = "export"
ChangeWithdraw ChangeType = "withdraw"
)
// OperatorType 操作人类型
type OperatorType string
const (
OperatorTypeSelf OperatorType = "self"
OperatorTypeAdmin OperatorType = "admin"
OperatorTypeSystem OperatorType = "system"
)
// DataChangeLog 数据变更日志实体
type DataChangeLog struct {
ID uint `json:"id" gorm:"primaryKey;autoIncrement"`
UserID string `json:"user_id" gorm:"type:varchar(36);index:idx_user"`
OperatorID string `json:"operator_id" gorm:"type:varchar(36);index:idx_operator"`
OperatorName string `json:"operator_name" gorm:"type:varchar(100)"`
ChangeType string `json:"change_type" gorm:"type:varchar(50);index:idx_change_type"`
TargetType string `json:"target_type" gorm:"type:varchar(50)"`
TargetID string `json:"target_id" gorm:"type:varchar(255)"`
FieldName string `json:"field_name" gorm:"type:varchar(50)"`
OldValue string `json:"old_value" gorm:"type:text"`
NewValue string `json:"new_value" gorm:"type:text"`
IP string `json:"ip" gorm:"type:varchar(45);index:idx_ip"`
IPLocation string `json:"ip_location" gorm:"type:varchar(100)"`
UserAgent string `json:"user_agent" gorm:"type:varchar(500)"`
Reason string `json:"reason" gorm:"type:varchar(500)"`
OperatorType string `json:"operator_type" gorm:"type:varchar(20);index:idx_operator_type"`
DeviceID string `json:"device_id" gorm:"type:varchar(100)"`
ServerIP string `json:"server_ip" gorm:"type:varchar(45)"`
CreatedAt time.Time `json:"created_at" gorm:"index:idx_created"`
}
func (DataChangeLog) TableName() string {
return "data_change_logs"
}