Files
shangbangbang/internal/config/events.go
T
solosw 99b11b04e4 1.0
2026-01-05 14:11:34 +08:00

33 lines
1.5 KiB
Go

package config
// ConfigEvent 配置变更事件
type ConfigEvent struct {
ConfigKey string `json:"config_key"` // 配置键
OldValue interface{} `json:"old_value"` // 旧值
NewValue interface{} `json:"new_value"` // 新值
ChangeType string `json:"change_type"` // 变更类型:create, update, delete
ChangedBy uint `json:"changed_by"` // 修改人ID
ChangedAt int64 `json:"changed_at"` // 修改时间戳
}
// ConfigEventHandler 配置事件处理器接口
type ConfigEventHandler interface {
Handle(event ConfigEvent) error
GetConfigKeys() []string // 返回该处理器关心的配置键列表
}
// ConfigChange 配置变更记录(用于审计)
type ConfigChange struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
ConfigKey string `gorm:"type:varchar(100);not null;comment:配置键" json:"config_key"`
OldValue string `gorm:"type:text;comment:旧值" json:"old_value"`
NewValue string `gorm:"type:text;comment:新值" json:"new_value"`
ChangeType string `gorm:"type:varchar(20);not null;comment:变更类型" json:"change_type"`
ChangedBy uint `gorm:"type:int;not null;comment:修改人ID" json:"changed_by"`
ChangedAt int64 `gorm:"type:bigint;not null;comment:修改时间戳" json:"changed_at"`
Extra map[string]interface{} `gorm:"type:json;comment:额外信息" json:"extra"`
}
func (ConfigChange) TableName() string {
return "config_changes"
}