Initial commit
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
package appInfoApi
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/common/utils"
|
||||
"stat/service/appInfoSer"
|
||||
"stat/service/opLogSer"
|
||||
)
|
||||
|
||||
// @Tags 应用管理
|
||||
// @Summary app列表
|
||||
// @Description app列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.ListAppInfoReq true "参数列表"
|
||||
// @Success 200 {object} proto.ListAppInfoRes "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/appInfo/list [POST]
|
||||
func ListAppInfo(ctx *gin.Context) {
|
||||
param := proto.ListAppInfoReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
code, data, err := appInfoSer.GetAppInfoList(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 应用管理
|
||||
// @Summary 添加app
|
||||
// @Description 添加app
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.AddAppInfoReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/appInfo/add [POST]
|
||||
func AddAppInfo(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
param := proto.AddAppInfoReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
code, data, err := appInfoSer.AddAppInfo(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 应用管理
|
||||
// @Summary 修改app
|
||||
// @Description 修改app
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.UpdateAppInfoReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/appInfo/update [POST]
|
||||
func UpdateAppInfo(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
param := proto.UpdateAppInfoReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
code, data, err := appInfoSer.UpdateAppInfo(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
|
||||
// @Tags 应用管理
|
||||
// @Summary 删除app
|
||||
// @Description 删除app
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security ApiKeyAuth
|
||||
// @Param param body proto.DelAppInfoReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "失败"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/stat/appInfo/del [DELETE]
|
||||
func DelAppInfo(ctx *gin.Context) {
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
param := proto.DelAppInfoReq{}
|
||||
if err := ctx.ShouldBind(¶m); err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error())
|
||||
return
|
||||
}
|
||||
code, data, err := appInfoSer.DelAppInfo(ctx, param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
|
||||
stdLog.ServerJSON(ctx, code, data)
|
||||
}
|
||||
Reference in New Issue
Block a user