forked from all_user/stat_center
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)
|
||||
}
|
||||
Reference in New Issue
Block a user