package exchcodectrl import ( "91jd-server/app/service/exchcodeser" "91jd-server/common" "91jd-server/common/stderr" "91jd-server/models/commod" "github.com/gin-gonic/gin" ) // CodeExchange doc // @Summary 兑换码兑换 // @Description 兑换码 // @Tags ExchangeCode // @Accept mpfd,json // @Produce json,html // @Param code formData string true "兑换码" // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/app/code/exchange [post] func CodeExchange(ctx *gin.Context) { uid, err := common.GetUID(ctx) if err != nil { common.ServeJSON(ctx, stderr.ErrNoToken, nil) return } var param struct { Code string `json:"code" binding:"required"` } if err = ctx.ShouldBind(¶m); err != nil { common.ServeJSON(ctx, stderr.ErrParamError, err) return } code, data, err := exchcodeser.CodeExchange(uid, param.Code) if err != nil { common.ServeJSON(ctx, code, err) return } common.ServeJSON(ctx, code, data) } // UserRecord doc // @Summary 查询用户兑换记录 // @Description 查询用户兑换记录 // @Tags UserRecord // @Accept mpfd,json // @Produce json,html // @Param pageNumber formData int true "页码" // @Param pageSize formData int true "每页数据量" // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/app/code/userRecord [get] func UserRecord(ctx *gin.Context) { uid, err := common.GetUID(ctx) if err != nil { common.ServeJSON(ctx, stderr.ErrNoToken, nil) return } var req struct { commod.Page } if err = ctx.ShouldBind(&req); err != nil { common.ServeJSON(ctx, stderr.ErrParamError, err) return } code, data, err := exchcodeser.UserExchageRecord(uid, req.Page) if err != nil { common.ServeJSON(ctx, code, err) return } common.ServeJSON(ctx, code, data) }