130 lines
5.3 KiB
Go
130 lines
5.3 KiB
Go
package exchcodectrl
|
||
|
||
import (
|
||
"encoding/json"
|
||
|
||
"91porn-server/common"
|
||
"91porn-server/common/constant"
|
||
"91porn-server/common/stderr"
|
||
"91porn-server/models/l/operatorlgmod"
|
||
"91porn-server/models/v/exchcodemod"
|
||
"91porn-server/web/service/exchcodeser"
|
||
|
||
"github.com/gin-gonic/gin"
|
||
)
|
||
|
||
// CodeList doc
|
||
// @Summary 兑换码列表
|
||
// @Description 兑换码管理
|
||
// @Tags Web-ExchangeCode
|
||
// @Accept mpfd,json
|
||
// @Produce json,html
|
||
// @Param batchNum query string false "批次号"
|
||
// @Param channel query string false "渠道号"
|
||
// @Param code query string false "兑换码"
|
||
// @Param app query string false "APP:ysAppVideo--音色短视频 pfAppVideo--泡芙视频 ltAppVpn--雷霆加速器"
|
||
// @Param authority formData string false "兑换权限:shortVideoVip--短视频vip filmVip--影视vip(影院)superVip--超级vip(可以兑换短视频,也可兑换影视) gold--兑换金币"
|
||
// @Param status query string false "状态 unused--未使用,used--已兑换,expired--已过期"
|
||
// @Param pageNumber query integer true "页码"
|
||
// @Param pageSize query integer true "每页条数"
|
||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||
// @Router /api/web/admin/exchange/code/list [get]
|
||
func CodeList(ctx *gin.Context) {
|
||
var manager, err = common.GetAdminAct(ctx)
|
||
if err != nil {
|
||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||
return
|
||
}
|
||
var param = exchcodemod.ListReqParam{}
|
||
if err = ctx.ShouldBind(¶m); err != nil {
|
||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||
return
|
||
}
|
||
code, data, err := exchcodeser.GetExchangeCodeList(param, manager)
|
||
if err != nil {
|
||
common.ServeJSON(ctx, code, err)
|
||
return
|
||
}
|
||
common.ServeJSON(ctx, code, data)
|
||
}
|
||
|
||
// CodeAdd doc
|
||
// @Summary 添加兑换码
|
||
// @Description 兑换码管理
|
||
// @Tags Web-ExchangeCode
|
||
// @Accept mpfd,json
|
||
// @Produce json,html
|
||
// @Param app formData string true "APP类型:ysAppVideo--音色短视频 pfAppVideo--泡芙视频 ltAppVpn--雷霆加速器"
|
||
// @Param channels formData array true "渠道号列表"
|
||
// @Param authority formData string true "兑换权限:shortVideoVip--短视频vip filmVip--影视vip(影院)superVip--超级vip(可以兑换短视频,也可兑换影视) gold--兑换金币"
|
||
// @Param reward formData integer true "兑换量"
|
||
// @Param count formData integer true "兑换码生成数量"
|
||
// @Param effectiveAt formData string true "生效时间"
|
||
// @Param invalidAt formData string true "失效时间"
|
||
// @Param remark formData string false "备注"
|
||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||
// @Router /api/web/admin/exchange/code/add [post]
|
||
func CodeAdd(ctx *gin.Context) {
|
||
var manager, err = common.GetAdminAct(ctx)
|
||
if err != nil {
|
||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||
return
|
||
}
|
||
var param = exchcodemod.AddReqParam{}
|
||
if err = ctx.ShouldBind(¶m); err != nil {
|
||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||
return
|
||
}
|
||
code, err := exchcodeser.AddExchangeCode(param, manager)
|
||
if err != nil {
|
||
common.ServeJSON(ctx, code, err)
|
||
return
|
||
}
|
||
log, _ := json.Marshal(param)
|
||
_ = operatorlgmod.RecordOperation(manager, constant.ExchangeCode, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||
common.ServeJSON(ctx, code, nil)
|
||
}
|
||
|
||
// CodeUpdate doc
|
||
// @Summary 编辑兑换码
|
||
// @Description 兑换码管理
|
||
// @Tags Web-ExchangeCode
|
||
// @Accept mpfd,json
|
||
// @Produce json,html
|
||
// @Param id query string true "兑换码id"
|
||
// @Param status query string false "状态"
|
||
// @Param authority query string false "兑换权限"
|
||
// @Param reward query integer false "兑换量(奖励值)"
|
||
// @Param remark query integer false "备注"
|
||
// @Param effectiveAt query string false "生效时间"
|
||
// @Param invalidAt query string false "失效时间"
|
||
// @Success 200 {string} json "{"msg": "操作成功", "data":[]}"
|
||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||
// @Router /api/web/admin/exchange/code/update [post]
|
||
func CodeUpdate(ctx *gin.Context) {
|
||
var manager, err = common.GetAdminAct(ctx)
|
||
if err != nil {
|
||
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
||
return
|
||
}
|
||
var param = exchcodemod.UpdateReqParam{}
|
||
if err = ctx.ShouldBind(¶m); err != nil {
|
||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||
return
|
||
}
|
||
code, err := exchcodeser.UpdateExchangeCode(param, manager)
|
||
if err != nil {
|
||
common.ServeJSON(ctx, code, err)
|
||
return
|
||
}
|
||
log, _ := json.Marshal(param)
|
||
_ = operatorlgmod.RecordOperation(manager, constant.ExchangeCode, constant.Add, string(log), ctx.Request.URL.RequestURI())
|
||
common.ServeJSON(ctx, code, nil)
|
||
}
|
||
|
||
func ChannelList(ctx *gin.Context) {
|
||
common.ServeJSON(ctx, 200, gin.H{"total": 1, "list": []map[string]interface{}{{"device": "any", "channel": "system"}}})
|
||
}
|