Initial commit
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
package web_application
|
||||
|
||||
import (
|
||||
"stat/api/proto"
|
||||
"stat/common/stdLog"
|
||||
"stat/common/utils"
|
||||
"stat/models/applicationmod"
|
||||
"stat/service/applicationser"
|
||||
"stat/service/opLogSer"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags 应用中心
|
||||
// @Summary 添加应用
|
||||
// @Description 添加应用
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body applicationmod.Application true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/web/apps/add [POST]
|
||||
func AddApplication(ctx *gin.Context) {
|
||||
params := &applicationmod.Application{}
|
||||
err := ctx.ShouldBind(params)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
serr := applicationser.AddApplication(ctx, params, account)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, serr.Code, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, params)
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, nil)
|
||||
|
||||
}
|
||||
|
||||
// @Tags 应用中心
|
||||
// @Summary 删除应用
|
||||
// @Description 删除应用
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.DelAppReq true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/web/apps/del [POST]
|
||||
func DelApplication(ctx *gin.Context) {
|
||||
param := &proto.DelAppReq{}
|
||||
err := ctx.ShouldBind(param)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
serr := applicationser.DelApplication(ctx, param.Id, account)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, serr.Code, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, param)
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, nil)
|
||||
}
|
||||
|
||||
// @Tags 应用中心
|
||||
// @Summary 更新应用
|
||||
// @Description 更新应用
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body applicationmod.AppUpdate true "参数列表"
|
||||
// @Success 200 {string} string "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/web/apps/update [POST]
|
||||
func UpdateApplication(ctx *gin.Context) {
|
||||
req := &applicationmod.AppUpdate{}
|
||||
err := ctx.ShouldBind(req)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
account, err := utils.GetAdmin(ctx)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error())
|
||||
return
|
||||
}
|
||||
serr := applicationser.UpdateApplication(ctx, req, account)
|
||||
if serr != nil {
|
||||
stdLog.ServerJSON(ctx, serr.Code, serr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 增加操作日志
|
||||
opLogSer.AddOpLog(ctx, account, true, req)
|
||||
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, nil)
|
||||
}
|
||||
|
||||
// @Tags 应用中心
|
||||
// @Summary 查询应用列表
|
||||
// @Description 查询应用列表
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body proto.GetApplicationsReq true "参数列表"
|
||||
// @Success 200 {object} proto.GetApplicationsResp "成功"
|
||||
// @Failure 400 {string} string "获取失败的返回结果"
|
||||
// @Router /api/stat/web/apps/list [POST]
|
||||
func GetApplications(ctx *gin.Context) {
|
||||
param := &proto.GetApplicationsReq{}
|
||||
err := ctx.ShouldBind(¶m)
|
||||
if err != nil {
|
||||
stdLog.ServerJSON(ctx, stdLog.ParamError, nil)
|
||||
return
|
||||
}
|
||||
result, sErr := applicationser.GetAppList(ctx, param)
|
||||
if sErr != nil {
|
||||
stdLog.ServerJSON(ctx, sErr.Code, sErr.Error())
|
||||
return
|
||||
}
|
||||
stdLog.ServerJSON(ctx, stdLog.Success, result)
|
||||
}
|
||||
Reference in New Issue
Block a user