refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
57 lines
1.8 KiB
Go
57 lines
1.8 KiB
Go
package app
|
||
|
||
import (
|
||
"bindbox-game/internal/code"
|
||
"bindbox-game/internal/pkg/core"
|
||
"bindbox-game/internal/pkg/validation"
|
||
"net/http"
|
||
usersvc "bindbox-game/internal/service/user"
|
||
)
|
||
|
||
type listShipmentsRequest struct {
|
||
Page int `form:"page"`
|
||
PageSize int `form:"page_size"`
|
||
}
|
||
|
||
type listShipmentsResponse struct {
|
||
Page int `json:"page"`
|
||
PageSize int `json:"page_size"`
|
||
Total int64 `json:"total"`
|
||
List []*usersvc.ShipmentGroup `json:"list"`
|
||
}
|
||
|
||
// @Summary 获取用户发货分组列表
|
||
// @Description 按运单号聚合用户的发货记录,支持分页
|
||
// @Tags APP端.发货
|
||
// @Accept json
|
||
// @Produce json
|
||
// @Security LoginVerifyToken
|
||
// @Param user_id path integer true "用户ID"
|
||
// @Param page query int false "页码,默认1"
|
||
// @Param page_size query int false "每页数量,最多100,默认20"
|
||
// @Success 200 {object} listShipmentsResponse
|
||
// @Failure 400 {object} code.Failure
|
||
// @Router /api/app/users/{user_id}/shipments [get]
|
||
func (h *handler) ListUserShipments() core.HandlerFunc {
|
||
return func(ctx core.Context) {
|
||
req := new(listShipmentsRequest)
|
||
rsp := new(listShipmentsResponse)
|
||
if err := ctx.ShouldBindQuery(req); err != nil {
|
||
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, validation.Error(err)))
|
||
return
|
||
}
|
||
userID := int64(ctx.SessionUserInfo().Id)
|
||
rows, total, err := h.user.ListUserShipmentGroups(ctx.RequestContext(), userID, req.Page, req.PageSize)
|
||
if err != nil {
|
||
ctx.AbortWithError(core.Error(http.StatusBadRequest, 10030, err.Error()))
|
||
return
|
||
}
|
||
rsp.Page = req.Page
|
||
rsp.PageSize = req.PageSize
|
||
rsp.Total = total
|
||
rsp.List = rows
|
||
ctx.Payload(rsp)
|
||
}
|
||
}
|
||
|