优化admin-gui
This commit is contained in:
@@ -41,6 +41,7 @@ var defaultConfigs = []defaultConfig{
|
||||
{Key: "settlement.platform_fee_rate", Value: "0.00", Description: "平台抽成比例"},
|
||||
{Key: "settlement.owner_cycle_days", Value: "0", Description: "号主结算周期天数"},
|
||||
{Key: "withdraw.min_amount", Value: "100", Description: "提现最低金额预留"},
|
||||
{Key: "chat.default_support_admin_id", Value: "1", Description: "订单群聊默认接入的客服管理员 ID"},
|
||||
{Key: homeAnnouncementsConfigKey, Value: defaultHomeAnnouncementsConfigValue(), Description: "移动端首页公告 JSON 数组"},
|
||||
{Key: homeBannersConfigKey, Value: defaultHomeBannersConfigValue(), Description: "移动端首页轮播图 JSON 数组"},
|
||||
{Key: publishOptionsConfigKey, Value: defaultPublishOptionsConfigValue(), Description: "发布页选项配置 JSON"},
|
||||
@@ -136,6 +137,11 @@ func (r *Repository) ensureDefaults() error {
|
||||
if err := tx.Clauses(clause.OnConflict{DoNothing: true}).Create(&row).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if item.Key == "chat.default_support_admin_id" {
|
||||
if err := updateDefaultDescription(tx, item); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if item.Key == publishOptionsConfigKey {
|
||||
if err := updateLegacyPublishOptions(tx, item); err != nil {
|
||||
return err
|
||||
@@ -146,6 +152,18 @@ func (r *Repository) ensureDefaults() error {
|
||||
})
|
||||
}
|
||||
|
||||
func updateDefaultDescription(tx *gorm.DB, item defaultConfig) error {
|
||||
var row model.SystemConfig
|
||||
if err := tx.Where("`key` = ?", item.Key).First(&row).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if row.Description == item.Description {
|
||||
return nil
|
||||
}
|
||||
row.Description = item.Description
|
||||
return tx.Save(&row).Error
|
||||
}
|
||||
|
||||
func updateLegacyPublishOptions(tx *gorm.DB, item defaultConfig) error {
|
||||
var row model.SystemConfig
|
||||
if err := tx.Where("`key` = ?", item.Key).First(&row).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user