package versionApi import ( "stat/api/proto" "stat/common/stdLog" "stat/common/utils" "stat/service/cpcDownloadCfgSer" "stat/service/opLogSer" "github.com/gin-gonic/gin" ) // @Tags CPC下载配置 // @Summary CPC下载配置列表 // @Description CPC下载配置列表 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param param body proto.CpcDownloadCfgListReq true "参数列表" // @Success 200 {object} proto.CpcDownloadCfgListResp "成功" // @Failure 400 {string} string "失败" // @Router /api/stat/cpc/download/list [POST] func CpcDownloadCfgList(ctx *gin.Context) { req := &proto.CpcDownloadCfgListReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } resp, err := cpcDownloadCfgSer.List(ctx, req) if err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } stdLog.ServerJSON(ctx, stdLog.Success, resp) } // @Tags CPC下载配置 // @Summary 新增CPC下载配置 // @Description 新增CPC下载配置 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param param body proto.AddCpcDownloadCfgReq true "参数" // @Success 200 {string} string "成功" // @Failure 400 {string} string "失败" // @Router /api/stat/cpc/download/add [POST] func CpcDownloadCfgAdd(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.AddCpcDownloadCfgReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := cpcDownloadCfgSer.Add(ctx, req); err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, "") } // @Tags CPC下载配置 // @Summary 更新CPC下载配置 // @Description 更新CPC下载配置 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param param body proto.UpdateCpcDownloadCfgReq true "参数" // @Success 200 {string} string "成功" // @Failure 400 {string} string "失败" // @Router /api/stat/cpc/download/update [POST] func CpcDownloadCfgUpdate(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.UpdateCpcDownloadCfgReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := cpcDownloadCfgSer.Update(ctx, req); err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, "") } // @Tags CPC下载配置 // @Summary 删除CPC下载配置 // @Description 删除CPC下载配置 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param param body proto.DelCpcDownloadCfgReq true "参数" // @Success 200 {string} string "成功" // @Failure 400 {string} string "失败" // @Router /api/stat/cpc/download/del [POST] func CpcDownloadCfgDel(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.DelCpcDownloadCfgReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := cpcDownloadCfgSer.Del(ctx, req.Id); err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, "") }