forked from all_user/stat_center
110 lines
3.1 KiB
Go
110 lines
3.1 KiB
Go
package channelApi
|
|
|
|
import (
|
|
"stat/api/proto"
|
|
"stat/common/stdLog"
|
|
"stat/service/channelSer"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// @Tags 渠道管理
|
|
// @Summary 获取渠道扣量规则列表
|
|
// @Description 获取渠道扣量规则列表
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ChannelDeductionRuleSearch true "参数列表"
|
|
// @Success 200 {object} proto.ChannelDeductionRuleSearchResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelRule/list [POST]
|
|
func GetChannelDeductionRule(ctx *gin.Context) {
|
|
var req = &proto.ChannelDeductionRuleSearch{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
resp, serr := channelSer.SearchChannelDeductionRule(ctx, req)
|
|
if serr != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
|
}
|
|
|
|
// @Tags 渠道管理
|
|
// @Summary 添加一个渠道管理
|
|
// @Description 添加一个渠道管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ChannelDeductionRuleAdd true "参数列表"
|
|
// @Success 200 {string} string "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelRule/add [POST]
|
|
func AddOneChannelDeductionRule(ctx *gin.Context) {
|
|
var req = &proto.ChannelDeductionRuleAdd{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
|
|
resp, serr := channelSer.AddChannelDeductionRule(ctx, req)
|
|
if serr != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
|
}
|
|
|
|
// @Tags 渠道管理
|
|
// @Summary 删除一个渠道管理
|
|
// @Description 删除一个渠道管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ChannelDeductionRuleDelete true "参数列表"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelRule/del [POST]
|
|
func DelOneChannelDeductionRule(ctx *gin.Context) {
|
|
var req = &proto.ChannelDeductionRuleDelete{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
serr := channelSer.DelChannelDeductionRule(ctx, req.ID)
|
|
if serr != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
|
}
|
|
|
|
// @Tags 渠道管理
|
|
// @Summary 更新一个渠道管理
|
|
// @Description 更新一个渠道管理
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ChannelDeductionRuleUpdate true "参数列表"
|
|
// @Success 200 {string} string "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelRule/update [POST]
|
|
func UpdateOneChannelDeductionRule(ctx *gin.Context) {
|
|
var req = &proto.ChannelDeductionRuleUpdate{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
|
return
|
|
}
|
|
serr := channelSer.UpdateChannelDeductionRule(ctx, req.ID, *req)
|
|
if serr != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
|
}
|