package advitiseV2Api import ( "stat/api/proto" "stat/common/stdLog" "stat/common/utils" "stat/service/advitiseV2Ser" "stat/service/opLogSer" "github.com/gin-gonic/gin" ) // @Tags 广告管理V2/位置 // @Summary 广告位列表 // @Router /api/stat/advitise/v2/location/list [POST] // @Param param body proto.AdvitiseLocationListReq true "参数" // @Success 200 {object} proto.AdvitiseLocationListResp "成功" // @Security ApiKeyAuth func LocationList(ctx *gin.Context) { req := &proto.AdvitiseLocationListReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } resp, err := advitiseV2Ser.LocationList(ctx, req) if err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } stdLog.ServerJSON(ctx, stdLog.Success, resp) } // @Tags 广告管理V2/位置 // @Summary 新增广告位 // @Router /api/stat/advitise/v2/location/add [POST] // @Param param body proto.AddAdvitiseLocationReq true "参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth func LocationAdd(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.AddAdvitiseLocationReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := advitiseV2Ser.LocationAdd(ctx, req); err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, "") } // @Tags 广告管理V2/位置 // @Summary 更新广告位 // @Router /api/stat/advitise/v2/location/update [POST] // @Param param body proto.UpdateAdvitiseLocationReq true "参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth func LocationUpdate(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.UpdateAdvitiseLocationReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := advitiseV2Ser.LocationUpdate(ctx, req); err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, "") } // @Tags 广告管理V2/位置 // @Summary 删除广告位 // @Router /api/stat/advitise/v2/location/del [POST] // @Param param body proto.DelAdvitiseLocationReq true "参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth func LocationDel(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.DelAdvitiseLocationReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := advitiseV2Ser.LocationDel(ctx, req.Id); err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, "") }