This commit is contained in:
solosw
2026-01-05 14:11:34 +08:00
parent 35ef825371
commit 99b11b04e4
658 changed files with 99266 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
package config
// 配置键常量定义
const (
// 系统基础配置
ConfigSiteName = "site_name" // 网站名称
ConfigSiteUrl = "site_url" // 网站地址
ConfigSiteLogo = "site_logo" // 网站Logo
ConfigSiteDescription = "site_description" // 网站描述
// 商品相关配置
ConfigPriceIncreaseRate = "warehouse_price_rate" // 商品入库价格增长率
ConfigMaxStockQuantity = "max_stock_quantity" // 最大库存数量
ConfigMinSalePrice = "min_sale_price" // 最低销售价格
// 用户相关配置
ConfigMaxUserLevel = "max_user_level" // 用户最大等级
ConfigDefaultUserScore = "default_user_score" // 新用户默认积分
ConfigReferralBonus = "referral_bonus" // 推荐奖励积分
// 订单相关配置
ConfigOrderTimeout = "order_timeout" // 订单超时时间(分钟)
ConfigMaxOrderQuantity = "max_order_quantity" // 单笔订单最大数量
ConfigMinOrderAmount = "min_order_amount" // 最小订单金额
// 系统功能开关
ConfigEnableRegistration = "enable_registration" // 是否开放注册
ConfigEnableUpgrade = "enable_upgrade" // 是否开启升级功能
ConfigMaintenanceMode = "maintenance_mode" // 维护模式
)
+33
View File
@@ -0,0 +1,33 @@
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"
}