167 lines
4.1 KiB
Go
167 lines
4.1 KiB
Go
package activityApi
|
|
|
|
import (
|
|
"stat/api/proto"
|
|
"stat/common/stdLog"
|
|
"stat/service/activitySer"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// @Tags 活动管理
|
|
// @Summary 活动信息列表
|
|
// @Description 活动信息列表
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ActivityListReq true "参数"
|
|
// @Success 200 {object} proto.ActivityListResp "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/activity/list [GET]
|
|
func ActivityList(ctx *gin.Context) {
|
|
|
|
var param proto.ActivityListReq
|
|
|
|
if err := ctx.ShouldBind(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
code, data, err := activitySer.GetActivityList(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, data)
|
|
}
|
|
|
|
// @Tags 活动管理
|
|
// @Summary 添加活动
|
|
// @Description 添加活动
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.AddActivityReq true "参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/activity/add [POST]
|
|
func AddActivity(ctx *gin.Context) {
|
|
param := proto.AddActivityReq{}
|
|
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
|
|
code, err := activitySer.AddOneAct(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, "")
|
|
}
|
|
|
|
// @Tags 活动管理
|
|
// @Summary 更新一个活动
|
|
// @Description 更新一个活动
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.UpdateActivityReq true "参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/activity/update [POST]
|
|
func ActUpdate(ctx *gin.Context) {
|
|
param := proto.UpdateActivityReq{}
|
|
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
|
|
code, err := activitySer.UpdateOneAct(ctx, ¶m)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, "")
|
|
}
|
|
|
|
// @Tags 活动管理
|
|
// @Summary 删除一个活动
|
|
// @Description 删除一个活动
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.DelActivityReq true "参数列表"
|
|
// @Success 200 {string} string "成功"
|
|
// @Failure 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/activity/del [POST]
|
|
func DelOneAct(ctx *gin.Context) {
|
|
param := proto.DelActivityReq{}
|
|
if err := ctx.ShouldBind(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
|
return
|
|
}
|
|
code, err := activitySer.DeleteOneAct(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, "")
|
|
}
|
|
|
|
// @Tags 活动管理
|
|
// @Summary 活动访问量
|
|
// @Description 活动访问量
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ActivityVisitCountReq true "参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/activity/visit [POST]
|
|
func ActivityVisitCount(ctx *gin.Context) {
|
|
|
|
var param proto.ActivityVisitCountReq
|
|
|
|
if err := ctx.ShouldBind(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
code, err := activitySer.UpdateActivityVisitCount(ctx, ctx.ClientIP(), param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, "")
|
|
}
|
|
|
|
// @Tags 活动管理
|
|
// @Summary 活动访问量
|
|
// @Description 活动访问量
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param param body proto.ActivityVisitCountReq true "参数"
|
|
// @Success 200 {string} string "成功"
|
|
// @Success 400 {string} string "失败"
|
|
// @Security ApiKeyAuth
|
|
// @Router /api/stat/activity/visit/list [GET]
|
|
func ActivityVisitCountList(ctx *gin.Context) {
|
|
var param proto.ActivityVisitCountListReq
|
|
|
|
if err := ctx.ShouldBind(¶m); err != nil {
|
|
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
|
return
|
|
}
|
|
code, resp, err := activitySer.GetActivityVisitList(ctx, param)
|
|
if err != nil {
|
|
stdLog.ServerJSON(ctx, code, err)
|
|
return
|
|
}
|
|
|
|
stdLog.ServerJSON(ctx, code, resp)
|
|
}
|