Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 25s
feat(admin): 新增工会管理功能 feat(activity): 添加活动管理相关服务 feat(user): 实现用户道具卡和积分管理 feat(guild): 新增工会成员管理功能 fix: 修复数据库连接配置 fix: 修正jwtoken导入路径 fix: 解决端口冲突问题 style: 统一代码格式和注释风格 style: 更新项目常量命名 docs: 添加项目框架和开发规范文档 docs: 更新接口文档注释 chore: 移除无用代码和文件 chore: 更新Makefile和配置文件 chore: 清理日志文件 test: 添加道具卡测试脚本
72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package app
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"bindbox-game/internal/code"
|
|
"bindbox-game/internal/pkg/core"
|
|
"bindbox-game/internal/pkg/validation"
|
|
)
|
|
|
|
type rewardItem struct {
|
|
ProductID int64 `json:"product_id"`
|
|
Name string `json:"name"`
|
|
Weight int32 `json:"weight"`
|
|
Quantity int64 `json:"quantity"`
|
|
OriginalQty int64 `json:"original_qty"`
|
|
Level int32 `json:"level"`
|
|
Sort int32 `json:"sort"`
|
|
IsBoss int32 `json:"is_boss"`
|
|
}
|
|
|
|
type listRewardsResponse struct {
|
|
List []rewardItem `json:"list"`
|
|
}
|
|
|
|
// ListIssueRewards 奖励配置列表
|
|
// @Summary 奖励配置列表
|
|
// @Description 获取指定期的奖励配置列表
|
|
// @Tags APP端.活动
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param activity_id path integer true "活动ID"
|
|
// @Param issue_id path integer true "期ID"
|
|
// @Success 200 {object} listRewardsResponse
|
|
// @Failure 400 {object} code.Failure
|
|
// @Router /api/app/activities/{activity_id}/issues/{issue_id}/rewards [get]
|
|
func (h *handler) ListIssueRewards() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
issueIDStr := ctx.Param("issue_id")
|
|
if issueIDStr == "" {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "未传递期ID"))
|
|
return
|
|
}
|
|
if _, err := strconv.ParseInt(issueIDStr, 10, 64); err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, validation.Error(err)))
|
|
return
|
|
}
|
|
issueID, _ := strconv.ParseInt(issueIDStr, 10, 64)
|
|
items, err := h.activity.ListIssueRewards(ctx.RequestContext(), issueID)
|
|
if err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ListIssueRewardsError, err.Error()))
|
|
return
|
|
}
|
|
res := new(listRewardsResponse)
|
|
res.List = make([]rewardItem, len(items))
|
|
for i, v := range items {
|
|
res.List[i] = rewardItem{
|
|
ProductID: v.ProductID,
|
|
Name: v.Name,
|
|
Weight: v.Weight,
|
|
Quantity: v.Quantity,
|
|
OriginalQty: v.OriginalQty,
|
|
Level: v.Level,
|
|
Sort: v.Sort,
|
|
IsBoss: v.IsBoss,
|
|
}
|
|
}
|
|
ctx.Payload(res)
|
|
}
|
|
}
|