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/info/list [POST] // @Param param body proto.AdvitiseInfoListReq true "参数" // @Success 200 {object} proto.AdvitiseInfoListResp "成功" // @Security ApiKeyAuth func InfoList(ctx *gin.Context) { req := &proto.AdvitiseInfoListReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } resp, err := advitiseV2Ser.InfoList(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/info/add [POST] // @Param param body proto.AddAdvitiseInfoReq true "参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth func InfoAdd(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.AddAdvitiseInfoReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := advitiseV2Ser.InfoAdd(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/info/update [POST] // @Param param body proto.UpdateAdvitiseInfoReq true "参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth func InfoUpdate(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.UpdateAdvitiseInfoReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := advitiseV2Ser.InfoUpdate(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/info/del [POST] // @Param param body proto.DelAdvitiseInfoReq true "参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth func InfoDel(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.DelAdvitiseInfoReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := advitiseV2Ser.InfoDel(ctx, req.Id); err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, "") }