feat: 添加日志管理和敏感词过滤功能
- 新增日志管理模块:操作日志、登录日志、数据变更日志 - 新增敏感词过滤器 (sanitizer) - 新增日志异步写入管理器 - 新增日志定时清理服务 - 优化帖子相关服务和上传服务
This commit is contained in:
56
internal/model/data_change_log.go
Normal file
56
internal/model/data_change_log.go
Normal file
@@ -0,0 +1,56 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user