Files
2026-05-20 16:13:58 +08:00

139 lines
3.5 KiB
Go

package activityApi
import (
"stat/api/proto"
"stat/common/stdLog"
"stat/common/utils"
"stat/service/activitySer"
"stat/service/opLogSer"
"github.com/gin-gonic/gin"
)
// @Tags 活动管理
// @Summary 生成活动抽奖码
// @Description 生成活动抽奖码
// @Accept json
// @Produce json
// @Param param body proto.GenLotteryCodeReq true "参数"
// @Success 200 {string} string "成功"
// @Success 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/stat/activity/lotterycode/gen [POST]
func GenLotCode(ctx *gin.Context) {
account, err := utils.GetAdmin(ctx)
if err != nil {
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
return
}
param := proto.GenLotteryCodeReq{}
if err := ctx.ShouldBind(&param); err != nil {
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
return
}
code, err := activitySer.GenLotteryCodes(ctx, param)
if err != nil {
stdLog.ServerJSON(ctx, code, err)
return
}
// 增加操作日志
opLogSer.AddOpLog(ctx, account, true, param)
stdLog.ServerJSON(ctx, code, "")
}
// @Tags 活动管理
// @Summary 修改活动抽奖码
// @Description 修改活动抽奖码
// @Accept json
// @Produce json
// @Param param body proto.UpdateLotteryCodeReq true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/stat/activity/lotterycode/update [POST]
func UpdateLotCode(ctx *gin.Context) {
account, err := utils.GetAdmin(ctx)
if err != nil {
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
return
}
param := proto.UpdateLotteryCodeReq{}
if err := ctx.ShouldBind(&param); err != nil {
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
return
}
code, err := activitySer.UpdateLotteryCode(ctx, param)
if err != nil {
stdLog.ServerJSON(ctx, code, err)
return
}
// 增加操作日志
opLogSer.AddOpLog(ctx, account, true, param)
stdLog.ServerJSON(ctx, code, "")
}
// @Tags 活动管理
// @Summary 删除活动抽奖码
// @Description 删除活动抽奖码
// @Accept json
// @Produce json
// @Param param body proto.DelLotteryCodeReq true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/stat/activity/lotterycode/del [POST]
func DelLotCode(ctx *gin.Context) {
account, err := utils.GetAdmin(ctx)
if err != nil {
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
return
}
param := proto.DelLotteryCodeReq{}
if err := ctx.ShouldBind(&param); err != nil {
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
return
}
code, err := activitySer.DeleteOneLotteryCode(ctx, param)
if err != nil {
stdLog.ServerJSON(ctx, code, err)
return
}
// 增加操作日志
opLogSer.AddOpLog(ctx, account, true, param)
stdLog.ServerJSON(ctx, code, "")
}
// @Tags 活动管理
// @Summary 活动抽奖码列表
// @Description 活动抽奖码列表
// @Accept json
// @Produce json
// @Param param body proto.LotteryCodeListReq true "参数列表"
// @Success 200 {object} proto.LotteryCodeListResp "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/stat/activity/lotterycode/list [POST]
func LotteryCodeList(ctx *gin.Context) {
param := proto.LotteryCodeListReq{}
if err := ctx.ShouldBind(&param); err != nil {
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
return
}
code, data, err := activitySer.GetLotteryCodeList(ctx, param)
if err != nil {
stdLog.ServerJSON(ctx, code, err)
return
}
stdLog.ServerJSON(ctx, code, data)
}