Initial commit
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
package advertiseApi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/common/utils"
|
||||
"stat/service/advertiseSer"
|
||||
"stat/service/opLogSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 广告列表
|
||||
// @Description 广告列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.ListAdsReq true "参数"
|
||||
// @Success 200 {object} proto.ListAdsRes "成功"
|
||||
// @Success 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/ads/list [POST]
|
||||
func ListAds(ctx *gin.Context) {
|
||||
param := proto.ListAdsReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.ListAds(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 新增广告信息
|
||||
// @Description 新增广告信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.AddAdsReq true "参数"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Success 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/ads/add [POST]
|
||||
func AddAds(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
param := proto.AddAdsReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.AddAds(ctx, param, account)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 修改广告信息
|
||||
// @Description 修改广告信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.UpdateAdsReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/ads/update [POST]
|
||||
func UpdateAds(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
param := proto.UpdateAdsReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.UpdateAds(ctx, param, account)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 删除广告信息
|
||||
// @Description 删除广告信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.DelAdsReq true "参数"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Success 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/ads/del [POST]
|
||||
func DelAds(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
param := proto.DelAdsReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.DelAds(ctx, param, account)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 外部获取广告信息
|
||||
// @Description 外部获取广告信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.AdvertiseReq true "参数"
|
||||
// @Success 200 {object} proto.AdvertiseRes "成功"
|
||||
// @Success 400 {string} string "失败"
|
||||
// @Router /api/stat/ads/get [POST]
|
||||
func GetAds(ctx *gin.Context) {
|
||||
param := proto.AdvertiseReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.GetAdvertise(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, data)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 广告点击
|
||||
// @Description 广告点击
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.AdsClickReq true "参数"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Success 400 {string} string "失败"
|
||||
// @Router /api/stat/ads/click [POST]
|
||||
func ClickAds(ctx *gin.Context) {
|
||||
param := proto.AdsClickReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.IncAdsClickCount(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package advertiseApi
|
||||
|
||||
import (
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/common/utils"
|
||||
"stat/service/advertiseSer"
|
||||
"stat/service/opLogSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 广告位置列表
|
||||
// @Description 广告位置列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.ListAdsLocReq true "参数"
|
||||
// @Success 200 {object} proto.ListAdsLocRes "成功"
|
||||
// @Success 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/adsLoc/list [POST]
|
||||
func ListAdsLoc(ctx *gin.Context) {
|
||||
param := proto.ListAdsLocReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.ListAdsLoc(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 新增广告位置信息
|
||||
// @Description 谷歌验证
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.AddAdsLocReq true "参数"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Success 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/adsLoc/add [POST]
|
||||
func AddAdsLoc(ctx *gin.Context) {
|
||||
param := proto.AddAdsLocReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.AddAdsLoc(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 修改广告位置信息
|
||||
// @Description 修改广告位置信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.UpdateAdsLocReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/adsLoc/update [POST]
|
||||
func UpdateAdsLoc(ctx *gin.Context) {
|
||||
param := proto.UpdateAdsLocReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
code, data, err := advertiseSer.UpdateAdsLoc(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 删除广告位置信息
|
||||
// @Description 删除广告位置信息
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.DelAdsLocReq true "参数"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Success 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/adsLoc/del [POST]
|
||||
func DelAdsLoc(ctx *gin.Context) {
|
||||
param := proto.DelAdsLocReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := advertiseSer.DelAdsLoc(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package advertiseApi
|
||||
|
||||
import (
|
||||
"stat/common/stdLog"
|
||||
"stat/service/advertiseSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 广告统计
|
||||
// @Description 广告统计
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body advertiseSer.GetAdvertiseStatReq true "参数列表"
|
||||
// @Success 200 {object} advertiseSer.GetAdvertiseStatResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/ads/stat [POST]
|
||||
func GetAdvertiseStat(ctx *gin.Context) {
|
||||
param := &advertiseSer.GetAdvertiseStatReq{}
|
||||
err := ctx.ShouldBind(¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
result, err := advertiseSer.GetAdvertiseStatList(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.QueryError, err.Error())
|
||||
return
|
||||
}
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, result)
|
||||
}
|
||||
|
||||
// @Tags 广告管理
|
||||
// @Summary 广告统计不分时统计
|
||||
// @Description 广告统计不分时统计
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body advertiseSer.GetAdvertiseTotalStatReq true "参数列表"
|
||||
// @Success 200 {object} advertiseSer.GetAdvertiseTotalStatResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/ads/stattotal [POST]
|
||||
func GetAdvertiseTotalStat(ctx *gin.Context) {
|
||||
param := &advertiseSer.GetAdvertiseTotalStatReq{}
|
||||
err := ctx.ShouldBind(¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
result, err := advertiseSer.GetAdvertiseTotalStatList(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.QueryError, err.Error())
|
||||
return
|
||||
}
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, result)
|
||||
}
|
||||
Reference in New Issue
Block a user