@@ -0,0 +1,40 @@
|
||||
package userctrl
|
||||
|
||||
import (
|
||||
"91porn-server/app/service/userser"
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ConsumePrivilege doc
|
||||
// @Summary 消耗预售卡预付权益
|
||||
// @Description 消耗预售卡预付权益
|
||||
// @Tags user
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param q body userser.ConsumeReq false "请求参数"
|
||||
// @Success 200 {string} string "操作成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /mine/privilege/consume [post]
|
||||
func ConsumePrivilege(ctx *gin.Context) {
|
||||
// 获取用户当前配置
|
||||
uid, err := common.GetUID(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
|
||||
var args userser.ConsumeReq
|
||||
if err := ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
err = userser.Consume(uid, args.PrivilegeType, args.Count)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.Failure, nil)
|
||||
}
|
||||
|
||||
common.ServeJSON(ctx, stderr.Success, nil)
|
||||
}
|
||||
Reference in New Issue
Block a user