优化发布界面
This commit is contained in:
@@ -58,12 +58,15 @@ func DefaultPublishOptions() PublishOptionsDTO {
|
||||
},
|
||||
},
|
||||
QuantityItems: []PublishQuantityItem{
|
||||
{Key: "awmAmmo", Label: "AWM子弹", Price: "0.8元/发"},
|
||||
{Key: "helmet6", Label: "6头数量", Price: "2元/个"},
|
||||
{Key: "armor6", Label: "6甲数量", Price: "3元/个"},
|
||||
{Key: "kit5", Label: "5级全装套数量", Price: "5元/个"},
|
||||
{Key: "level6Ammo", Label: "6级子弹", Price: "0.26元/发"},
|
||||
{Key: "gridCard9", Label: "9格体验卡", Price: "5元/张", Placeholder: "如果是赛季9格,此处填0即可"},
|
||||
{Key: "level6Ammo", Label: "6级弹", Price: "0.1元/发", Placeholder: "按单发数量填写,60发=6元"},
|
||||
{Key: "awmAmmo", Label: "AWM子弹", Price: "0.6元/发"},
|
||||
{Key: "barrettAmmo", Label: "巴雷特子弹", Price: "0.3元/发"},
|
||||
{Key: "armor6", Label: "6甲", Price: "2.5元/个"},
|
||||
{Key: "helmet6", Label: "6头", Price: "1.5元/个"},
|
||||
{Key: "gridCard9", Label: "9格体验卡", Price: "3元/张", Placeholder: "如果是赛季9格,此处填0即可"},
|
||||
{Key: "redPacket45", Label: "45格大红包", Price: "1.5元/个"},
|
||||
{Key: "coffeeBean", Label: "高级咖啡豆", Price: "2.5元/个"},
|
||||
{Key: "bulletPart", Label: "高级子弹零件", Price: "3元/个"},
|
||||
},
|
||||
ScreenshotSlots: []PublishScreenshotSlot{
|
||||
{Key: "coin", Label: "纯币截图", Required: true, Hint: "请上传纯币截图(必传)"},
|
||||
|
||||
@@ -3,6 +3,7 @@ package systemconfig
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
|
||||
@@ -132,11 +133,54 @@ func (r *Repository) ensureDefaults() error {
|
||||
if err := tx.Clauses(clause.OnConflict{DoNothing: true}).Create(&row).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if item.Key == publishOptionsConfigKey {
|
||||
if err := updateLegacyPublishOptions(tx, item); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func updateLegacyPublishOptions(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 !isLegacyPublishOptionsValue(row.Value) {
|
||||
return nil
|
||||
}
|
||||
row.Value = item.Value
|
||||
row.Description = item.Description
|
||||
return tx.Save(&row).Error
|
||||
}
|
||||
|
||||
func isLegacyPublishOptionsValue(value string) bool {
|
||||
legacyMarkers := []string{
|
||||
`"kit5"`,
|
||||
"5级全装套",
|
||||
"6级子弹",
|
||||
"6头数量",
|
||||
"6甲数量",
|
||||
"0.26元/发",
|
||||
"0.8元/发",
|
||||
"çº",
|
||||
"å¼",
|
||||
"å…",
|
||||
"å¤",
|
||||
"ä½",
|
||||
"é«",
|
||||
"ï¼",
|
||||
}
|
||||
for _, marker := range legacyMarkers {
|
||||
if strings.Contains(value, marker) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func appendAuditLog(tx *gorm.DB, actorID uint64, action string, bizID uint64, meta AuditMeta, detail map[string]any) error {
|
||||
raw, err := json.Marshal(detail)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user