forked from all_user/stat_center
192 lines
5.8 KiB
Go
192 lines
5.8 KiB
Go
package channelApi
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"path/filepath"
|
|
"stat/api/proto"
|
|
"stat/common/stdLog"
|
|
"stat/service/channelSer"
|
|
"stat/service/statSer"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// @Tags 渠道管理
|
|
// @Summary 获取渠道统计列表
|
|
// @Description 获取渠道统计列表
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ChannelStatSearch true "参数列表"
|
|
// @Success 200 {object} proto.ChannelStatSearchResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelStat/list [POST]
|
|
func GetChannelStat(ctx *gin.Context) {
|
|
var req = &proto.ChannelStatSearch{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
resp, serr := channelSer.SearchChannelStat(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.SearchChannelStatComparedReq true "参数列表"
|
|
// @Success 200 {object} proto.SearchChannelStatComparedResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelStat/compare/list [POST]
|
|
func SearchChannelStatCompared(ctx *gin.Context) {
|
|
var req = &proto.SearchChannelStatComparedReq{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
resp, serr := channelSer.SearchChannelStatCompared(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.ChannelStatSettlementSearch true "参数列表"
|
|
// @Success 200 {object} proto.ChannelStatSettlementSearchResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelStat/settlement/list [POST]
|
|
func GetChannelSettlementStat(ctx *gin.Context) {
|
|
var req = &proto.ChannelStatSettlementSearch{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
resp, serr := channelSer.SearchChannelSettlementStat(ctx, req)
|
|
if serr != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
|
}
|
|
|
|
// @Tags 渠道结算
|
|
// @Summary 获取渠道统计信息v2
|
|
// @Description 获取渠道统计信息v2
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ChannelStatSettlementSearch true "参数列表"
|
|
// @Success 200 {object} proto.ChannelStatSettlementSearchResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelStat/settlement/v2/list [POST]
|
|
func GetChannelSettlementStat2(ctx *gin.Context) {
|
|
var req = &proto.ChannelStatSettlementSearch2{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
resp, serr := channelSer.SearchChannelSettlementStat2(ctx, req)
|
|
if serr != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
|
}
|
|
|
|
// @Tags 渠道结算
|
|
// @Summary 对结算页用户选择的结算项目进行计算
|
|
// @Description 对结算页用户选择的结算项目进行计算
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.SettlementCalcReq true "参数列表"
|
|
// @Success 200 {object} proto.SettlementCalcResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelStat/settlement/v2/calc [POST]
|
|
func GetChannelSettlementCalc(ctx *gin.Context) {
|
|
var req = &proto.SettlementCalcReq{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
resp, serr := channelSer.ChannelSettlementCalc(ctx, req)
|
|
if serr != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.Failure, serr.Error())
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
|
}
|
|
|
|
// @Tags 渠道管理
|
|
// @Summary 分组分页获取渠道结算表
|
|
// @Description 分组分页获取渠道结算表
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ChannelSettlementSearch true "参数列表"
|
|
// @Success 200 {object} proto.ChannelSettlementSearchResp "成功"
|
|
// @Failure 400 {string} string "获取失败的返回结果"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelSettlement/list [POST]
|
|
func GetChannelSettlement(ctx *gin.Context) {
|
|
var req = &proto.ChannelSettlementSearch{}
|
|
if err := ctx.ShouldBind(req); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
resp, serr := channelSer.SearchChannelSettlement(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
|
|
// @Security ApiKeyAuth
|
|
// @Param param body proto.ChannelStatExportReq true "参数列表"
|
|
// @Failure 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/channelStat/export [POST]
|
|
func ListChannelStatExport(ctx *gin.Context) {
|
|
param := proto.ChannelStatExportReq{}
|
|
if err := ctx.ShouldBind(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
|
return
|
|
}
|
|
|
|
fPath, serr := statSer.ChannelStatExport(ctx, param)
|
|
if serr != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
|
return
|
|
}
|
|
ctx.Writer.WriteHeader(http.StatusOK)
|
|
ctx.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", filepath.Base(fPath)))
|
|
ctx.Header("Content-Type", "application/octet-stream")
|
|
ctx.File(fPath)
|
|
}
|