Files
huangguo_server/app/api/userctrl/privilege.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

41 lines
1.0 KiB
Go

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)
}