Files
stat_center/api/applicationapi/applicationLoc.go
T
2026-05-20 16:13:58 +08:00

143 lines
3.5 KiB
Go

package applicationapi
import (
"stat/api/proto"
"stat/common/stdLog"
"stat/common/utils"
"stat/service/applicationser"
"stat/service/opLogSer"
"github.com/gin-gonic/gin"
)
// @Tags 广告管理
// @Summary 广告位置列表
// @Description 广告位置列表
// @Accept json
// @Produce json
// @Security ApiKeyAuth
// @Param param body proto.ListAppLocReq true "参数"
// @Success 200 {object} proto.ListAppLocRes "成功"
// @Success 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/stat/appLoc/list [POST]
func ListAppLoc(ctx *gin.Context) {
param := proto.ListAppLocReq{}
if err := ctx.ShouldBindJSON(&param); err != nil {
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
return
}
code, data, err := applicationser.ListAppLoc(ctx, param)
if err != nil {
stdLog.ServerJSON(ctx, code, err)
return
}
stdLog.ServerJSON(ctx, code, data)
}
// @Tags 广告管理
// @Summary 新增广告位置信息
// @Description 谷歌验证
// @Accept json
// @Produce json
// @Security ApiKeyAuth
// @Param param body proto.AddAppLocReq true "参数"
// @Success 200 {string} string "成功"
// @Success 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/stat/appLoc/add [POST]
func AddAppLoc(ctx *gin.Context) {
param := proto.AddAppLocReq{}
if err := ctx.ShouldBindJSON(&param); err != nil {
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
return
}
code, data, err := applicationser.AddAppLoc(ctx, param)
if err != nil {
stdLog.ServerJSON(ctx, code, err)
return
}
account, err := utils.GetAdmin(ctx)
if err != nil {
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
return
}
// 增加操作日志
opLogSer.AddOpLog(ctx, account, true, param)
stdLog.ServerJSON(ctx, code, data)
}
// @Tags 广告管理
// @Summary 修改广告位置信息
// @Description 修改广告位置信息
// @Accept json
// @Produce json
// @Security ApiKeyAuth
// @Param param body proto.UpdateAppLocReq true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/stat/appLoc/update [POST]
func UpdateAppLoc(ctx *gin.Context) {
param := proto.UpdateAppLocReq{}
if err := ctx.ShouldBindJSON(&param); err != nil {
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
return
}
code, data, err := applicationser.UpdateAppLoc(ctx, param)
if err != nil {
stdLog.ServerJSON(ctx, code, err)
return
}
account, err := utils.GetAdmin(ctx)
if err != nil {
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
return
}
// 增加操作日志
opLogSer.AddOpLog(ctx, account, true, param)
stdLog.ServerJSON(ctx, code, data)
}
// @Tags 广告管理
// @Summary 删除广告位置信息
// @Description 删除广告位置信息
// @Accept json
// @Produce json
// @Security ApiKeyAuth
// @Param param body proto.DelAppLocReq true "参数"
// @Success 200 {string} string "成功"
// @Success 400 {string} string "失败"
// @Security ApiKeyAuth
// @Router /api/stat/appLoc/del [POST]
func DelAppLoc(ctx *gin.Context) {
param := proto.DelAppLocReq{}
if err := ctx.ShouldBindJSON(&param); err != nil {
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
return
}
code, data, err := applicationser.DelAppLoc(ctx, param)
if err != nil {
stdLog.ServerJSON(ctx, code, err)
return
}
account, err := utils.GetAdmin(ctx)
if err != nil {
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
return
}
// 增加操作日志
opLogSer.AddOpLog(ctx, account, true, param)
stdLog.ServerJSON(ctx, code, data)
}