Initial commit
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
package versionApi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/models/landingPage"
|
||||
"stat/service/versionSer"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 落地页
|
||||
// @Summary 点击下载[跨服支持所有app]
|
||||
// @Description 点击下载事件[跨服支持所有app]
|
||||
// @Param req body proto.PageButtonClickReq true "参数页码"
|
||||
// @Success 200 {object} proto.PageButtonClickResp "ok"
|
||||
// @Router /api/stat/version/crossbottonclick [post]
|
||||
func CrossButtonClick(ctx *gin.Context) {
|
||||
param := proto.PageButtonClickReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
ip := ctx.ClientIP()
|
||||
userAgent := ctx.Request.Header.Get("User-Agent")
|
||||
data, err := versionSer.CrossButtonClick(ctx, userAgent, ip, ¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, data)
|
||||
}
|
||||
|
||||
// @Tags 落地页
|
||||
// @Summary 点击下载事件
|
||||
// @Description 点击下载事件
|
||||
// @Param req body proto.PageButtonClickReq true "参数页码"
|
||||
// @Success 200 {object} proto.PageButtonClickResp "ok"
|
||||
// @Router /api/stat/version/bottonclick [post]
|
||||
func LandingpageButtonClick(ctx *gin.Context) {
|
||||
param := proto.PageButtonClickReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
userAgent := ctx.Request.Header.Get("User-Agent")
|
||||
ip := ctx.ClientIP()
|
||||
data, err := versionSer.PageButtonClick(ctx, userAgent, ip, ¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, data)
|
||||
}
|
||||
|
||||
// @Tags 落地页
|
||||
// @Summary 下载按钮
|
||||
// @Description 下载按钮
|
||||
// @Param req body proto.PageButtonListReq true "参数页码"
|
||||
// @Success 200 {object} proto.PageButtonListResp "ok"
|
||||
// @Router /api/stat/version/bottonlist [post]
|
||||
func LandingpageButtonList(ctx *gin.Context) {
|
||||
param := proto.PageButtonListReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
userAgent := ctx.Request.Header.Get("User-Agent")
|
||||
isIos := strings.Contains(userAgent, "iPhone")
|
||||
ip := ctx.ClientIP()
|
||||
data, err := versionSer.PageButtonList(ctx, isIos, ip, ¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, data)
|
||||
}
|
||||
|
||||
// @Tags 落地页
|
||||
// @Summary 下载按钮
|
||||
// @Description 下载按钮
|
||||
// @Param req body proto.ShareUrlReq true "参数页码"
|
||||
// @Success 200 {object} proto.PageButtonListResp "ok"
|
||||
// @Router /api/stat/share/list [post]
|
||||
func ShareUrlList(ctx *gin.Context) {
|
||||
param := proto.ShareUrlReq{}
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
data, err := landingPage.FindShareLandingPage(ctx, param.AppId)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
resp := proto.ShareUrlResp{
|
||||
Url: make([]string, 0),
|
||||
}
|
||||
for _, v := range data {
|
||||
resp.Url = append(resp.Url, v.Url)
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Tags 落地页
|
||||
// @Summary 获取H5下载
|
||||
// @Description 获取H5下载
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.H5ConfigReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/version/h5/config [POST]
|
||||
func GetH5Config(ctx *gin.Context) {
|
||||
ip := ctx.ClientIP()
|
||||
var req = &proto.H5ConfigReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
userAgent := ctx.Request.Header.Get("User-Agent")
|
||||
data, fileName := versionSer.GetH5Config(ctx, req, userAgent, ip)
|
||||
|
||||
ctx.Header("Content-Type", "application/octet-stream")
|
||||
ctx.Header("Content-Disposition", "attachment; filename="+fileName)
|
||||
ctx.Header("Content-Transfer-Encoding", "binary")
|
||||
ctx.Writer.Write(data)
|
||||
}
|
||||
|
||||
// @Tags 落地页
|
||||
// @Summary 获取H5下载
|
||||
// @Description 获取H5下载
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.ChannelDownLoadLinkReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/version/channel/newLink [POST]
|
||||
func NewChannelDownLoadLink(ctx *gin.Context) {
|
||||
var req = &proto.ChannelDownLoadLinkReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
resp := versionSer.NewChannelDownLoadLink(ctx, req)
|
||||
|
||||
if resp == nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, "")
|
||||
return
|
||||
}
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
|
||||
// @Tags 落地页
|
||||
// @Summary 获取H5下载
|
||||
// @Description 获取H5下载
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.H5ConfigReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/version/h5/config/v2 [POST]
|
||||
func GetH5ConfigV2(ctx *gin.Context) {
|
||||
ip := ctx.ClientIP()
|
||||
var req = &proto.H5ConfigReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
resp := versionSer.GetH5ConfigV2(ctx, req, ip)
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, resp)
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package versionApi
|
||||
|
||||
import (
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/service/landpageSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 落地页资源
|
||||
// @Summary 分组分页获取落地页资源
|
||||
// @Description 分组分页获取落地页资源
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.LandpagePictureSearch true "参数列表"
|
||||
// @Success 200 {object} proto.LandpagePictureSearchResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/web/landpage/picture/list [POST]
|
||||
func GetLandpagePicture(ctx *gin.Context) {
|
||||
var req = &proto.LandpagePictureSearch{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
resp, serr := landpageSer.LandpagePicture(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.LandpagePictureAddReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/web/landpage/picture/add [POST]
|
||||
func AddOneLandpage(ctx *gin.Context) {
|
||||
var req = &proto.LandpagePictureAddReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
|
||||
serr := landpageSer.AddLandpagePicture(ctx, req)
|
||||
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.LandpagePictureDelReq true "参数列表"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/landpage/picture/del [POST]
|
||||
func DelOneLandpage(ctx *gin.Context) {
|
||||
var req = &proto.LandpagePictureDelReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err)
|
||||
return
|
||||
}
|
||||
serr := landpageSer.DelLandpagePicture(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.LandpagePictureUpdateReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/landpage/picture/update [POST]
|
||||
func UpdateOneLandpage(ctx *gin.Context) {
|
||||
var req = &proto.LandpagePictureUpdateReq{}
|
||||
if err := ctx.ShouldBind(req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
serr := landpageSer.UpdateLandpagePicture(ctx, req)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, serr)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package versionApi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/common/utils"
|
||||
"stat/service/opLogSer"
|
||||
"stat/service/versionSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 版本管理
|
||||
// @Summary 版本列表
|
||||
// @Description 版本列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body common.Page true "参数列表"
|
||||
// @Success 200 {object} proto.VersionListResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/version/list [POST]
|
||||
func VersionList(ctx *gin.Context) {
|
||||
var req proto.VersionListReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
data, err := versionSer.ListVersion(ctx, &req)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, data)
|
||||
}
|
||||
|
||||
// @Tags 版本管理
|
||||
// @Summary 版本删除
|
||||
// @Description 版本删除
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.VersionDelReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/version/del [POST]
|
||||
func VersionDelete(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var param proto.VersionDelReq
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
err = versionSer.DeleteVersion(ctx, param.Id)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 版本管理
|
||||
// @Summary 版本添加
|
||||
// @Description 版本添加
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.VersionAddReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/version/add [POST]
|
||||
func VersionAdd(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var param proto.VersionAddReq
|
||||
if err := ctx.ShouldBindJSON(¶m); nil != err {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = versionSer.AddVersion(ctx, ¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 版本管理
|
||||
// @Summary 版本更新
|
||||
// @Description 版本更新
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.VersionUpdateReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/version/update [POST]
|
||||
func VersionUpdate(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
var param proto.VersionUpdateReq
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
err = versionSer.UpdateVersion(ctx, ¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, "")
|
||||
}
|
||||
|
||||
// @Tags 版本管理
|
||||
// @Summary App获取版本
|
||||
// @Description app获取版本
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.VersionUpdateReq true "参数列表"
|
||||
// @Success 200 {object} proto.AppVersionResp "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Router /api/stat/version/app [POST]
|
||||
func AppVersion(ctx *gin.Context) {
|
||||
|
||||
var param proto.AppVersionReq
|
||||
if err := ctx.ShouldBindJSON(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
data, err := versionSer.AppVersion(ctx, ¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.Failure, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, data)
|
||||
}
|
||||
Reference in New Issue
Block a user