39 lines
968 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package common
import (
"bindbox-game/internal/pkg/core"
)
type ConfigResponse struct {
SubscribeTemplates map[string]string `json:"subscribe_templates"`
}
// GetPublicConfig 获取公开配置(包含订阅模板ID)
// @Summary 获取公开配置
// @Description 获取小程序前端需要用到的公开配置如订阅消息模板ID
// @Tags 公共
// @Accept json
// @Produce json
// @Success 200 {object} ConfigResponse
// @Router /api/app/config/public [get]
func (h *handler) GetPublicConfig() core.HandlerFunc {
return func(ctx core.Context) {
// 查询订阅消息模板 ID
var val string
cfg, err := h.readDB.SystemConfigs.WithContext(ctx.RequestContext()).
Where(h.readDB.SystemConfigs.ConfigKey.Eq("wechat.lottery_result_template_id")).
First()
if err == nil && cfg != nil {
val = cfg.ConfigValue
}
rsp := ConfigResponse{
SubscribeTemplates: map[string]string{
"lottery_result": val,
},
}
ctx.Payload(rsp)
}
}