feat(admin): 新增管理后台前端资源文件 feat(api): 实现获取用户统计数据的API接口 - 添加获取用户道具卡数量、优惠券数量和积分余额的接口 - 实现设置默认地址和删除地址的接口 feat(service): 新增用户统计服务方法 - 实现GetUserStats方法查询用户统计数据 - 添加地址管理相关服务方法 fix(core): 修复静态资源路由问题 - 调整静态资源路由配置 - 优化404路由处理逻辑 chore: 更新前端构建配置 - 添加Windows平台构建命令 - 更新README构建说明
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package app
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"bindbox-game/internal/pkg/core"
|
|
)
|
|
|
|
type userStatsResponse struct {
|
|
ItemCardCount int64 `json:"item_card_count"`
|
|
CouponCount int64 `json:"coupon_count"`
|
|
PointsBalance int64 `json:"points_balance"`
|
|
}
|
|
|
|
// GetUserStats 获取用户统计
|
|
// @Summary 获取用户统计
|
|
// @Description 返回当前登录用户的道具卡数量、优惠券数量、积分余额
|
|
// @Tags APP端.用户
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param user_id path integer true "用户ID"
|
|
// @Security LoginVerifyToken
|
|
// @Success 200 {object} userStatsResponse
|
|
// @Failure 400 {object} code.Failure "参数错误"
|
|
// @Failure 401 {object} code.Failure "未授权"
|
|
// @Failure 500 {object} code.Failure "服务器内部错误"
|
|
// @Router /api/app/users/{user_id}/stats [get]
|
|
func (h *handler) GetUserStats() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
userID := int64(ctx.SessionUserInfo().Id)
|
|
stats, err := h.user.GetUserStats(ctx.RequestContext(), userID)
|
|
if err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, 10010, err.Error()))
|
|
return
|
|
}
|
|
rsp := &userStatsResponse{
|
|
ItemCardCount: stats.ItemCardCount,
|
|
CouponCount: stats.CouponCount,
|
|
PointsBalance: stats.PointsBalance,
|
|
}
|
|
ctx.Payload(rsp)
|
|
}
|
|
} |