refactor(抽奖记录): 重构抽奖记录列表接口,支持按等级筛选 新增用户昵称、头像及奖品名称、图片等展示字段 优化分页逻辑,默认返回最新100条记录 feat(游戏): 添加扫雷游戏验证和结算接口 新增游戏票据验证和结算相关接口定义及Swagger文档 docs(API): 更新Swagger文档 更新抽奖记录和游戏相关接口的文档描述 style(路由): 添加游戏路由注释 添加扫雷游戏接口路由的占位注释
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package app
|
|
|
|
import (
|
|
"encoding/json"
|
|
"bindbox-game/internal/pkg/core"
|
|
"bindbox-game/internal/pkg/logger"
|
|
"bindbox-game/internal/repository/mysql"
|
|
"bindbox-game/internal/repository/mysql/dao"
|
|
cfgsvc "bindbox-game/internal/service/sysconfig"
|
|
)
|
|
|
|
type noticeHandler struct {
|
|
logger logger.CustomLogger
|
|
readDB *dao.Query
|
|
cfg cfgsvc.Service
|
|
}
|
|
|
|
func NewNotice(l logger.CustomLogger, db mysql.Repo) *noticeHandler {
|
|
return ¬iceHandler{logger: l, readDB: dao.Use(db.GetDbR()), cfg: cfgsvc.New(l, db)}
|
|
}
|
|
|
|
type appNoticeItem struct {
|
|
Content string `json:"content"`
|
|
}
|
|
|
|
type listAppNoticesResponse struct {
|
|
List []appNoticeItem `json:"list"`
|
|
}
|
|
|
|
// ListNoticesForApp 获取公告列表
|
|
// @Summary 获取公告列表
|
|
// @Description 获取APP首页滚动公告
|
|
// @Tags APP端.基础
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} listAppNoticesResponse
|
|
// @Router /api/app/notices [get]
|
|
func (h *noticeHandler) ListNoticesForApp() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
rsp := new(listAppNoticesResponse)
|
|
conf, err := h.cfg.GetByKey(ctx.RequestContext(), "app_notice")
|
|
if err != nil {
|
|
rsp.List = []appNoticeItem{}
|
|
ctx.Payload(rsp)
|
|
return
|
|
}
|
|
val := conf.ConfigValue
|
|
var arr []string
|
|
if err := json.Unmarshal([]byte(val), &arr); err == nil {
|
|
items := make([]appNoticeItem, 0, len(arr))
|
|
for _, s := range arr { items = append(items, appNoticeItem{Content: s}) }
|
|
rsp.List = items
|
|
ctx.Payload(rsp)
|
|
return
|
|
}
|
|
if val == "" {
|
|
rsp.List = []appNoticeItem{}
|
|
ctx.Payload(rsp)
|
|
return
|
|
}
|
|
rsp.List = []appNoticeItem{{Content: val}}
|
|
ctx.Payload(rsp)
|
|
}
|
|
}
|