新增合作与反馈入口配置

This commit is contained in:
yml2213
2026-08-15 16:37:30 +08:00
parent 134d6fa05e
commit d9f552577a
14 changed files with 332 additions and 36 deletions
@@ -0,0 +1,43 @@
package systemconfig
import (
"encoding/json"
"strings"
)
const cooperationFeedbackConfigKey = "mobile.cooperation_feedback"
func defaultCooperationFeedback() CooperationFeedbackConfig {
return CooperationFeedbackConfig{
Title: "合作与反馈",
Subtitle: "点击查看联系方式",
ImageURL: "",
Enabled: true,
}
}
func defaultCooperationFeedbackConfigValue() string {
raw, err := json.Marshal(defaultCooperationFeedback())
if err != nil {
return `{"title":"合作与反馈","subtitle":"点击查看联系方式","image_url":"","enabled":true}`
}
return string(raw)
}
func normalizeCooperationFeedback(item CooperationFeedbackConfig) CooperationFeedbackConfig {
def := defaultCooperationFeedback()
title := strings.TrimSpace(item.Title)
if title == "" {
title = def.Title
}
subtitle := strings.TrimSpace(item.Subtitle)
if subtitle == "" {
subtitle = def.Subtitle
}
return CooperationFeedbackConfig{
Title: title,
Subtitle: subtitle,
ImageURL: strings.TrimSpace(item.ImageURL),
Enabled: item.Enabled,
}
}
+13 -4
View File
@@ -22,10 +22,11 @@ type HomeAnnouncementsDTO struct {
}
type HomeConfigDTO struct {
Announcements []string `json:"announcements"`
Banners []HomeBannerItem `json:"banners"`
PublishOptions PublishOptionsDTO `json:"publish_options"`
AWRecycle AWRecycleConfig `json:"aw_recycle"`
Announcements []string `json:"announcements"`
Banners []HomeBannerItem `json:"banners"`
PublishOptions PublishOptionsDTO `json:"publish_options"`
AWRecycle AWRecycleConfig `json:"aw_recycle"`
CooperationFeedback CooperationFeedbackConfig `json:"cooperation_feedback"`
}
// AWRecycleConfig 首页「AW炫彩回收」入口:点击展示可配置图片。
@@ -36,6 +37,14 @@ type AWRecycleConfig struct {
Enabled bool `json:"enabled"`
}
// CooperationFeedbackConfig 首页「合作与反馈」入口:点击展示可配置图片。
type CooperationFeedbackConfig struct {
Title string `json:"title"`
Subtitle string `json:"subtitle"`
ImageURL string `json:"image_url"`
Enabled bool `json:"enabled"`
}
type OrderAgreementsDTO struct {
VirtualAssetPurchase AgreementContentDTO `json:"virtual_asset_purchase"`
RenterAgreement AgreementContentDTO `json:"renter_agreement"`
@@ -48,6 +48,7 @@ var defaultConfigs = []defaultConfig{
{Key: homeAnnouncementsConfigKey, Value: defaultHomeAnnouncementsConfigValue(), Description: "移动端首页公告 JSON 数组"},
{Key: homeBannersConfigKey, Value: defaultHomeBannersConfigValue(), Description: "移动端首页轮播图 JSON 数组"},
{Key: awRecycleConfigKey, Value: defaultAWRecycleConfigValue(), Description: "首页 AW炫彩回收入口配置 JSON(标题/副标题/展示图片)"},
{Key: cooperationFeedbackConfigKey, Value: defaultCooperationFeedbackConfigValue(), Description: "首页 合作与反馈入口配置 JSON(标题/副标题/展示图片)"},
{Key: publishOptionsConfigKey, Value: defaultPublishOptionsConfigValue(), Description: "发布页选项配置 JSON"},
{Key: salePriceConfigKey, Value: defaultSalePriceConfigValue(), Description: "内部出售定价规则 JSON"},
}
@@ -71,6 +72,7 @@ var adminVisibleConfigKeys = []string{
"mobile.home_announcements",
"mobile.home_banners",
"mobile.aw_recycle",
"mobile.cooperation_feedback",
"order.agreements",
"order.pending_payment_timeout_minutes",
"order.return_overdue_grace_minutes",
@@ -32,15 +32,20 @@ func (s *Service) HomeConfig(ctx context.Context) (*HomeConfigDTO, error) {
if err != nil {
return nil, err
}
cooperationFeedback, err := s.cooperationFeedback(ctx)
if err != nil {
return nil, err
}
publishOptions, err := s.publishOptions(ctx)
if err != nil {
return nil, err
}
return &HomeConfigDTO{
Announcements: announcements,
Banners: banners,
PublishOptions: publishOptions,
AWRecycle: awRecycle,
Announcements: announcements,
Banners: banners,
PublishOptions: publishOptions,
AWRecycle: awRecycle,
CooperationFeedback: cooperationFeedback,
}, nil
}
@@ -79,3 +84,15 @@ func (s *Service) awRecycle(ctx context.Context) (AWRecycleConfig, error) {
}
return normalizeAWRecycle(item), nil
}
func (s *Service) cooperationFeedback(ctx context.Context) (CooperationFeedbackConfig, error) {
value, err := s.repo.FindValue(ctx, cooperationFeedbackConfigKey)
if err != nil {
return defaultCooperationFeedback(), err
}
item := defaultCooperationFeedback()
if err := json.Unmarshal([]byte(value), &item); err != nil {
item = defaultCooperationFeedback()
}
return normalizeCooperationFeedback(item), nil
}