Initial commit
This commit is contained in:
@@ -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