Refactor error handling in system and trace controllers

- Updated error response codes for various validation errors from 400 to 422 to better reflect the nature of the errors.
- Changed error messages for empty parameters (e.g., userId, menuId, roleId) to use a consistent error code format.
- Improved error handling in the IPerf, Ping, and WS controllers to provide more informative error messages.
- Ensured that all controllers return appropriate error messages when binding JSON or query parameters fails.
This commit is contained in:
TsMask
2025-04-27 16:38:19 +08:00
parent 56991a0b49
commit 80d612c56c
67 changed files with 424 additions and 410 deletions

View File

@@ -1,8 +1,10 @@
package services package services
import "be.ems/src/framework/resp"
const ( const (
CODE_FAIL = 0 CODE_FAIL = resp.CODE_ERROR
CODE_SUCC = 1 CODE_SUCC = resp.CODE_SUCCESS
) )
func ErrResp(msg string) map[string]any { func ErrResp(msg string) map[string]any {

View File

@@ -1,11 +0,0 @@
package constants
// 验证码常量信息
const (
// CAPTCHA_EXPIRATION 验证码有效期,单位秒
CAPTCHA_EXPIRATION = 2 * 60
// CAPTCHA_TYPE_CHAR 验证码类型-数值计算
CAPTCHA_TYPE_CHAR = "char"
// CAPTCHA_TYPE_MATH 验证码类型-字符验证
CAPTCHA_TYPE_MATH = "math"
)

View File

@@ -20,14 +20,14 @@ func ErrorCatch() gin.HandlerFunc {
// 返回错误响应给客户端 // 返回错误响应给客户端
if config.Env() == "prod" { if config.Env() == "prod" {
c.JSON(500, resp.CodeMsg(500, "Internal Server Errors")) c.JSON(500, resp.CodeMsg(500001, "Internal Server Errors"))
} else { } else {
// 通过实现 error 接口的 Error() 方法自定义错误类型进行捕获 // 通过实现 error 接口的 Error() 方法自定义错误类型进行捕获
switch v := err.(type) { switch v := err.(type) {
case error: case error:
c.JSON(500, resp.CodeMsg(500, v.Error())) c.JSON(500, resp.CodeMsg(500001, v.Error()))
default: default:
c.JSON(500, resp.CodeMsg(500, fmt.Sprint(err))) c.JSON(500, resp.CodeMsg(500001, fmt.Sprint(err)))
} }
} }

View File

@@ -103,7 +103,7 @@ func OperateLog(options Options) gin.HandlerFunc {
// 获取登录用户信息 // 获取登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
c.Abort() // 停止执行后续的处理函数 c.Abort() // 停止执行后续的处理函数
return return
} }

View File

@@ -51,7 +51,7 @@ func CryptoApi(requestDecrypt, responseEncrypt bool) gin.HandlerFunc {
// 是否存在data字段数据 // 是否存在data字段数据
if contentDe == "" { if contentDe == "" {
c.JSON(400, resp.ErrMsg("decrypt not found field data")) c.JSON(422, resp.CodeMsg(422002, "decrypt not found field data"))
c.Abort() // 停止执行后续的处理函数 c.Abort() // 停止执行后续的处理函数
return return
} }
@@ -61,7 +61,7 @@ func CryptoApi(requestDecrypt, responseEncrypt bool) gin.HandlerFunc {
dataBodyStr, err := crypto.AESDecryptBase64(contentDe, apiKey) dataBodyStr, err := crypto.AESDecryptBase64(contentDe, apiKey)
if err != nil { if err != nil {
logger.Errorf("CryptoApi decrypt err => %v", err) logger.Errorf("CryptoApi decrypt err => %v", err)
c.JSON(400, resp.ErrMsg("decrypted data could not be parsed")) c.JSON(422, resp.CodeMsg(422001, "decrypted data could not be parsed"))
c.Abort() // 停止执行后续的处理函数 c.Abort() // 停止执行后续的处理函数
return return
} }

View File

@@ -88,7 +88,7 @@ func OperateLog(options Options) gin.HandlerFunc {
// 获取登录用户信息 // 获取登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, "无效身份授权")) c.JSON(401, resp.CodeMsg(401002, "invalid login user information"))
c.Abort() // 停止执行后续的处理函数 c.Abort() // 停止执行后续的处理函数
return return
} }

View File

@@ -64,7 +64,7 @@ func RateLimit(option LimitOption) gin.HandlerFunc {
if option.Type == LIMIT_USER { if option.Type == LIMIT_USER {
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(40003, err.Error())) c.JSON(401, resp.CodeMsg(401002, "invalid login user information"))
c.Abort() // 停止执行后续的处理函数 c.Abort() // 停止执行后续的处理函数
return return
} }
@@ -80,13 +80,13 @@ func RateLimit(option LimitOption) gin.HandlerFunc {
// 在Redis查询并记录请求次数 // 在Redis查询并记录请求次数
rateCount, err := redis.RateLimit("", limitKey, option.Time, option.Count) rateCount, err := redis.RateLimit("", limitKey, option.Time, option.Count)
if err != nil { if err != nil {
c.JSON(200, resp.CodeMsg(4013, "访问过于频繁,请稍候再试")) c.JSON(200, resp.ErrMsg("access too often, please try again later"))
c.Abort() // 停止执行后续的处理函数 c.Abort() // 停止执行后续的处理函数
return return
} }
rateTime, err := redis.GetExpire("", limitKey) rateTime, err := redis.GetExpire("", limitKey)
if err != nil { if err != nil {
c.JSON(200, resp.CodeMsg(4013, "访问过于频繁,请稍候再试")) c.JSON(200, resp.ErrMsg("access too often, please try again later"))
c.Abort() // 停止执行后续的处理函数 c.Abort() // 停止执行后续的处理函数
return return
} }
@@ -97,7 +97,7 @@ func RateLimit(option LimitOption) gin.HandlerFunc {
c.Header("X-RateLimit-Reset", fmt.Sprintf("%d", time.Now().Unix()+rateTime)) // 重置时间戳 c.Header("X-RateLimit-Reset", fmt.Sprintf("%d", time.Now().Unix()+rateTime)) // 重置时间戳
if rateCount >= option.Count { if rateCount >= option.Count {
c.JSON(200, resp.CodeMsg(4013, "访问过于频繁,请稍候再试")) c.JSON(200, resp.ErrMsg("access too often, please try again later"))
c.Abort() // 停止执行后续的处理函数 c.Abort() // 停止执行后续的处理函数
return return
} }

View File

@@ -60,7 +60,7 @@ func RepeatSubmit(interval int64) gin.HandlerFunc {
// 小于间隔时间且参数内容一致 // 小于间隔时间且参数内容一致
if compareTime < interval && compareParams { if compareTime < interval && compareParams {
c.JSON(200, resp.ErrMsg("不允许重复提交,请稍候再试")) c.JSON(200, resp.ErrMsg("repeat submissions are not allowed. Please try again later."))
c.Abort() c.Abort()
return return
} }

View File

@@ -1,8 +1,9 @@
package controller package controller
import ( import (
"fmt"
"be.ems/src/framework/constants" "be.ems/src/framework/constants"
"be.ems/src/framework/i18n"
"be.ems/src/framework/reqctx" "be.ems/src/framework/reqctx"
"be.ems/src/framework/resp" "be.ems/src/framework/resp"
"be.ems/src/framework/token" "be.ems/src/framework/token"
@@ -140,7 +141,8 @@ func (s *BootloaderController) Account(c *gin.Context) {
Password string `json:"password" binding:"required"` Password string `json:"password" binding:"required"`
} }
if err := c.ShouldBindJSON(&body); err != nil { if err := c.ShouldBindJSON(&body); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -1,8 +1,12 @@
package controller package controller
import ( import (
"strings"
"time" "time"
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
"be.ems/src/framework/config" "be.ems/src/framework/config"
"be.ems/src/framework/constants" "be.ems/src/framework/constants"
"be.ems/src/framework/database/redis" "be.ems/src/framework/database/redis"
@@ -10,42 +14,30 @@ import (
"be.ems/src/framework/resp" "be.ems/src/framework/resp"
"be.ems/src/framework/utils/parse" "be.ems/src/framework/utils/parse"
systemService "be.ems/src/modules/system/service" systemService "be.ems/src/modules/system/service"
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
) )
// 实例化控制层 CaptchaController 结构体 // NewCaptcha 实例化控制层
var NewCaptcha = &CaptchaController{ var NewCaptcha = &CaptchaController{
sysConfigService: systemService.NewSysConfig, sysConfigService: systemService.NewSysConfig,
} }
// 验证码操作处理 // CaptchaController 验证码操作 控制层处理
// //
// PATH / // PATH /
type CaptchaController struct { type CaptchaController struct {
sysConfigService *systemService.SysConfig // 参数配置服务 sysConfigService *systemService.SysConfig // 参数配置服务
} }
// 获取验证码 // Image 获取验证码-图片
// //
// GET /captchaImage // GET /captcha-image
// func (s CaptchaController) Image(c *gin.Context) {
// @Tags common
// @Accept json
// @Produce json
// @Success 200 {object} object "Response Results"
// @Security TokenAuth
// @Summary Get CAPTCHA
// @Description Get CAPTCHA
// @Router /captchaImage [get]
func (s *CaptchaController) Image(c *gin.Context) {
// 从数据库配置获取验证码开关 true开启false关闭 // 从数据库配置获取验证码开关 true开启false关闭
captchaEnabledStr := s.sysConfigService.FindValueByKey("sys.account.captchaEnabled") captchaEnabledStr := s.sysConfigService.FindValueByKey("sys.account.captchaEnabled")
captchaEnabled := parse.Boolean(captchaEnabledStr) captchaEnabled := parse.Boolean(captchaEnabledStr)
if !captchaEnabled { if !captchaEnabled {
c.JSON(200, resp.Ok(map[string]any{ c.JSON(200, resp.OkData(map[string]any{
"captchaEnabled": captchaEnabled, "enabled": captchaEnabled,
})) }))
return return
} }
@@ -53,14 +45,16 @@ func (s *CaptchaController) Image(c *gin.Context) {
// 生成唯一标识 // 生成唯一标识
verifyKey := "" verifyKey := ""
data := map[string]any{ data := map[string]any{
"captchaEnabled": captchaEnabled, "enabled": captchaEnabled,
"uuid": "", "uuid": "",
"img": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", "img": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
} }
// 验证码有效期,单位秒
captchaExpiration := 2 * 60 * time.Second
// 从数据库配置获取验证码类型 math 数值计算 char 字符验证 // 从数据库配置获取验证码类型 math 数值计算 char 字符验证
captchaType := s.sysConfigService.FindValueByKey("sys.account.captchaType") captchaType := s.sysConfigService.FindValueByKey("sys.account.captchaType")
if captchaType == constants.CAPTCHA_TYPE_MATH { if captchaType == "math" {
math := config.Get("mathCaptcha").(map[string]any) math := config.Get("mathCaptcha").(map[string]any)
driverCaptcha := &base64Captcha.DriverMath{ driverCaptcha := &base64Captcha.DriverMath{
//Height png height in pixel. //Height png height in pixel.
@@ -81,16 +75,15 @@ func (s *CaptchaController) Image(c *gin.Context) {
// 验证码表达式解析输出 // 验证码表达式解析输出
item, err := driverCaptcha.DrawCaptcha(question) item, err := driverCaptcha.DrawCaptcha(question)
if err != nil { if err != nil {
logger.Infof("Generate Id Question Answer %s %s : %v", captchaType, question, err) logger.Infof("generate id question answer %s %s : %v", captchaType, question, err)
} else { } else {
data["uuid"] = id data["uuid"] = id
data["img"] = item.EncodeB64string() data["img"] = item.EncodeB64string()
expiration := constants.CAPTCHA_EXPIRATION * time.Second
verifyKey = constants.CACHE_CAPTCHA_CODE + ":" + id verifyKey = constants.CACHE_CAPTCHA_CODE + ":" + id
redis.Set("", verifyKey, answer, expiration) _ = redis.Set("", verifyKey, answer, captchaExpiration)
} }
} }
if captchaType == constants.CAPTCHA_TYPE_CHAR { if captchaType == "char" {
char := config.Get("charCaptcha").(map[string]any) char := config.Get("charCaptcha").(map[string]any)
driverCaptcha := &base64Captcha.DriverString{ driverCaptcha := &base64Captcha.DriverString{
//Height png height in pixel. //Height png height in pixel.
@@ -115,13 +108,12 @@ func (s *CaptchaController) Image(c *gin.Context) {
// 验证码表达式解析输出 // 验证码表达式解析输出
item, err := driverCaptcha.DrawCaptcha(question) item, err := driverCaptcha.DrawCaptcha(question)
if err != nil { if err != nil {
logger.Infof("Generate Id Question Answer %s %s : %v", captchaType, question, err) logger.Infof("generate id question answer %s %s : %v", captchaType, question, err)
} else { } else {
data["uuid"] = id data["uuid"] = id
data["img"] = item.EncodeB64string() data["img"] = item.EncodeB64string()
expiration := constants.CAPTCHA_EXPIRATION * time.Second
verifyKey = constants.CACHE_CAPTCHA_CODE + ":" + id verifyKey = constants.CACHE_CAPTCHA_CODE + ":" + id
redis.Set("", verifyKey, answer, expiration) _ = redis.Set("", verifyKey, strings.ToLower(answer), captchaExpiration)
} }
} }
@@ -129,8 +121,8 @@ func (s *CaptchaController) Image(c *gin.Context) {
if config.Env() == "local" { if config.Env() == "local" {
text, _ := redis.Get("", verifyKey) text, _ := redis.Get("", verifyKey)
data["text"] = text data["text"] = text
c.JSON(200, resp.Ok(data)) c.JSON(200, resp.OkData(data))
return return
} }
c.JSON(200, resp.Ok(data)) c.JSON(200, resp.OkData(data))
} }

View File

@@ -3,8 +3,6 @@ package controller
import ( import (
"fmt" "fmt"
"be.ems/src/framework/i18n"
"be.ems/src/framework/reqctx"
"be.ems/src/framework/resp" "be.ems/src/framework/resp"
"be.ems/src/modules/chart/service" "be.ems/src/modules/chart/service"
@@ -62,7 +60,7 @@ func (s *ChartGraphController) Load(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -94,7 +92,7 @@ func (s *ChartGraphController) Save(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -125,10 +123,9 @@ func (s *ChartGraphController) Save(c *gin.Context) {
// @Description Deleting Relationship Diagram Data // @Description Deleting Relationship Diagram Data
// @Router /chart/graph/{group} [delete] // @Router /chart/graph/{group} [delete]
func (s *ChartGraphController) Delete(c *gin.Context) { func (s *ChartGraphController) Delete(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
group := c.Param("group") group := c.Param("group")
if group == "" { if group == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: group is empty"))
return return
} }

View File

@@ -11,6 +11,7 @@ import (
"be.ems/src/framework/i18n" "be.ems/src/framework/i18n"
"be.ems/src/framework/reqctx" "be.ems/src/framework/reqctx"
"be.ems/src/framework/resp"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@@ -31,10 +32,8 @@ func (s CommonController) Hash(c *gin.Context) {
Str string `json:"str" binding:"required"` Str string `json:"str" binding:"required"`
} }
if err := c.ShouldBindJSON(&body); err != nil { if err := c.ShouldBindJSON(&body); err != nil {
c.JSON(200, gin.H{ errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
"code": 400, c.JSON(422, resp.CodeMsg(422001, errMsgs))
"msg": "参数错误",
})
return return
} }

View File

@@ -34,13 +34,13 @@ func (s *FileController) Download(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
filePath := c.Param("filePath") filePath := c.Param("filePath")
if len(filePath) < 8 { if len(filePath) < 8 {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, i18n.TKey(language, "app.common.err400")))
return return
} }
// base64解析出地址 // base64解析出地址
decodedBytes, err := base64.StdEncoding.DecodeString(filePath) decodedBytes, err := base64.StdEncoding.DecodeString(filePath)
if err != nil { if err != nil {
c.JSON(400, resp.CodeMsg(400, err.Error())) c.JSON(422, resp.CodeMsg(422002, err.Error()))
return return
} }
routerPath := string(decodedBytes) routerPath := string(decodedBytes)
@@ -87,14 +87,14 @@ func (s *FileController) Upload(c *gin.Context) {
// 上传的文件 // 上传的文件
formFile, err := c.FormFile("file") formFile, err := c.FormFile("file")
if err != nil { if err != nil {
c.JSON(400, resp.CodeMsg(40010, "bind err: file is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: file is empty"))
return return
} }
// 子路径需要在指定范围内 // 子路径需要在指定范围内
subPath := c.PostForm("subPath") subPath := c.PostForm("subPath")
_, ok := constants.UPLOAD_SUB_PATH[subPath] _, ok := constants.UPLOAD_SUB_PATH[subPath]
if subPath != "" && !ok { if subPath != "" && !ok {
c.JSON(400, resp.CodeMsg(40010, "bind err: subPath not in range")) c.JSON(422, resp.CodeMsg(422002, "bind err: subPath not in range"))
return return
} }
if subPath == "" { if subPath == "" {
@@ -136,7 +136,7 @@ func (s *FileController) ChunkCheck(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -170,12 +170,12 @@ func (s *FileController) ChunkMerge(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 子路径需要在指定范围内 // 子路径需要在指定范围内
if _, ok := constants.UPLOAD_SUB_PATH[body.SubPath]; body.SubPath != "" && !ok { if _, ok := constants.UPLOAD_SUB_PATH[body.SubPath]; body.SubPath != "" && !ok {
c.JSON(400, resp.CodeMsg(40010, "bind err: subPath not in range")) c.JSON(422, resp.CodeMsg(422002, "bind err: subPath not in range"))
return return
} }
if body.SubPath == "" { if body.SubPath == "" {
@@ -218,13 +218,13 @@ func (s *FileController) ChunkUpload(c *gin.Context) {
// 切片唯一标识 // 切片唯一标识
identifier := c.PostForm("identifier") identifier := c.PostForm("identifier")
if index == "" || identifier == "" { if index == "" || identifier == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: index and identifier must be set")) c.JSON(422, resp.CodeMsg(422002, "bind err: index and identifier must be set"))
return return
} }
// 上传的文件 // 上传的文件
formFile, err := c.FormFile("file") formFile, err := c.FormFile("file")
if err != nil { if err != nil {
c.JSON(400, resp.CodeMsg(40010, "bind err: file is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: file is empty"))
return return
} }
@@ -262,7 +262,7 @@ func (s *FileController) List(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -322,7 +322,7 @@ func (s *FileController) File(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -373,7 +373,7 @@ func (s *FileController) Remove(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -418,7 +418,7 @@ func (s *FileController) TransferStaticFile(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -429,7 +429,7 @@ func (s *FileController) TransferStaticFile(c *gin.Context) {
static := config.Get("staticFile.default").(map[string]any) static := config.Get("staticFile.default").(map[string]any)
dir, err := filepath.Abs(static["dir"].(string)) dir, err := filepath.Abs(static["dir"].(string))
if err != nil { if err != nil {
c.JSON(400, resp.CodeMsg(400, err.Error())) c.JSON(200, resp.ErrMsg(err.Error()))
return return
} }
@@ -439,7 +439,7 @@ func (s *FileController) TransferStaticFile(c *gin.Context) {
err = file.CopyUploadFile(body.UploadPath, newFile) err = file.CopyUploadFile(body.UploadPath, newFile)
if err != nil { if err != nil {
c.JSON(400, resp.CodeMsg(400, err.Error())) c.JSON(200, resp.ErrMsg(err.Error()))
return return
} }

View File

@@ -50,7 +50,7 @@ func (s *MonitorController) Load(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -73,7 +73,7 @@ func (s SysCacheController) Keys(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -96,7 +96,7 @@ func (s SysCacheController) Value(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -165,7 +165,7 @@ func (s SysCacheController) CleanKeys(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if constants.CACHE_TOKEN_DEVICE == query.CacheName { if constants.CACHE_TOKEN_DEVICE == query.CacheName {
@@ -196,7 +196,7 @@ func (s SysCacheController) CleanValue(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -64,7 +64,7 @@ func (s *SysJobController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
jobId := parse.Number(c.Param("jobId")) jobId := parse.Number(c.Param("jobId"))
if jobId <= 0 { if jobId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: jobId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: jobId is empty"))
return return
} }
@@ -87,11 +87,11 @@ func (s *SysJobController) Add(c *gin.Context) {
var body model.SysJob var body model.SysJob
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.JobId > 0 { if body.JobId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: jobId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: jobId not is empty"))
return return
} }
@@ -143,11 +143,11 @@ func (s *SysJobController) Edit(c *gin.Context) {
var body model.SysJob var body model.SysJob
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.JobId <= 0 { if body.JobId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: jobId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: jobId is empty"))
return return
} }
@@ -229,7 +229,7 @@ func (s *SysJobController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
jobId := c.Param("jobId") jobId := c.Param("jobId")
if jobId == "" { if jobId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: jobId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: jobId is empty"))
return return
} }
@@ -261,7 +261,7 @@ func (s *SysJobController) Status(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -299,7 +299,7 @@ func (s *SysJobController) Run(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
jobId := parse.Number(c.Param("jobId")) jobId := parse.Number(c.Param("jobId"))
if jobId <= 0 { if jobId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: jobId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: jobId is empty"))
return return
} }

View File

@@ -73,7 +73,7 @@ func (s *SysJobLogController) List(c *gin.Context) {
func (s *SysJobLogController) Info(c *gin.Context) { func (s *SysJobLogController) Info(c *gin.Context) {
logId := parse.Number(c.Param("logId")) logId := parse.Number(c.Param("logId"))
if logId <= 0 { if logId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: logId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: logId is empty"))
return return
} }
@@ -92,7 +92,7 @@ func (s *SysJobLogController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
logId := c.Param("logId") logId := c.Param("logId")
if logId == "" { if logId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: logId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: logId is empty"))
return return
} }
@@ -143,13 +143,6 @@ func (s *SysJobLogController) Export(c *gin.Context) {
return return
} }
// rows := s.sysJobLogService.SelectJobLogList(model.SysJobLog{})
if len(rows) <= 0 {
// 导出数据记录为空
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return
}
// 闭包函数处理多语言 // 闭包函数处理多语言
converI18n := func(language string, arr *[]model.SysJobLog) { converI18n := func(language string, arr *[]model.SysJobLog) {
for i := range *arr { for i := range *arr {

View File

@@ -57,7 +57,7 @@ func (s AlarmController) List(c *gin.Context) {
var query model.AlarmQuery var query model.AlarmQuery
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 查询数据 // 查询数据
@@ -72,7 +72,7 @@ func (s AlarmController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -102,7 +102,7 @@ func (s AlarmController) Clear(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -125,7 +125,7 @@ func (s AlarmController) Ack(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -168,7 +168,7 @@ func (s AlarmController) Export(c *gin.Context) {
var query model.AlarmQuery var query model.AlarmQuery
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 限制导出数据集 // 限制导出数据集

View File

@@ -43,7 +43,7 @@ func (s AlarmForwardController) List(c *gin.Context) {
var query model.AlarmForwardLogQuery var query model.AlarmForwardLogQuery
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 查询数据 // 查询数据

View File

@@ -49,7 +49,7 @@ func (s AlarmLogController) List(c *gin.Context) {
var query model.AlarmLogQuery var query model.AlarmLogQuery
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 查询数据 // 查询数据
@@ -82,7 +82,7 @@ func (s AlarmLogController) Event(c *gin.Context) {
var query model.AlarmEventQuery var query model.AlarmEventQuery
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 查询数据 // 查询数据

View File

@@ -35,7 +35,7 @@ func (s BackupController) FTPUpdate(c *gin.Context) {
var body model.BackupDataFTP var body model.BackupDataFTP
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -72,7 +72,7 @@ func (s BackupController) FTPPush(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 判断路径是否合法 // 判断路径是否合法

View File

@@ -49,7 +49,7 @@ func (s KPIController) KPIData(c *gin.Context) {
var querys model.KPIQuery var querys model.KPIQuery
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -82,7 +82,7 @@ func (s KPIController) KPIData(c *gin.Context) {
func (s KPIController) KPITitle(c *gin.Context) { func (s KPIController) KPITitle(c *gin.Context) {
neType := c.Query("neType") neType := c.Query("neType")
if neType == "" { if neType == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: neType is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: neType is empty"))
return return
} }
kpiTitles := s.kpiReportService.FindTitle(neType) kpiTitles := s.kpiReportService.FindTitle(neType)

View File

@@ -53,7 +53,7 @@ func (s NBStateController) List(c *gin.Context) {
var query model.NBStateQuery var query model.NBStateQuery
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -89,7 +89,7 @@ func (s NBStateController) Export(c *gin.Context) {
var querys model.NBStateQuery var querys model.NBStateQuery
if err := c.ShouldBindBodyWithJSON(&querys); err != nil { if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 限制导出数据集 // 限制导出数据集

View File

@@ -52,7 +52,7 @@ func (s *AMFController) UEList(c *gin.Context) {
var querys model.UEEventAMFQuery var querys model.UEEventAMFQuery
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -86,7 +86,7 @@ func (s *AMFController) UERemove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -126,7 +126,7 @@ func (s *AMFController) UEExport(c *gin.Context) {
var querys model.UEEventAMFQuery var querys model.UEEventAMFQuery
if err := c.ShouldBindBodyWithJSON(&querys); err != nil { if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 限制导出数据集 // 限制导出数据集
@@ -181,7 +181,7 @@ func (s *AMFController) NbInfoList(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -221,7 +221,7 @@ func (s *AMFController) NbStateList(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Query("neId") neId := c.Query("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: neId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }

View File

@@ -53,7 +53,7 @@ func (s *IMSController) CDRList(c *gin.Context) {
var querys model.CDREventIMSQuery var querys model.CDREventIMSQuery
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -87,7 +87,7 @@ func (s *IMSController) CDRRemove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(442002, "bind err: id is empty"))
return return
} }
@@ -127,7 +127,7 @@ func (s *IMSController) CDRExport(c *gin.Context) {
var querys model.CDREventIMSQuery var querys model.CDREventIMSQuery
if err := c.ShouldBindBodyWithJSON(&querys); err != nil { if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 限制导出数据集 // 限制导出数据集
@@ -177,7 +177,7 @@ func (s *IMSController) UeSessionNum(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Query("neId") neId := c.Query("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: neId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
@@ -222,7 +222,7 @@ func (s *IMSController) UeSessionList(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -52,7 +52,7 @@ func (s *MMEController) UEList(c *gin.Context) {
var querys model.UEEventMMEQuery var querys model.UEEventMMEQuery
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -86,7 +86,7 @@ func (s *MMEController) UERemove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -126,7 +126,7 @@ func (s *MMEController) UEExport(c *gin.Context) {
var querys model.UEEventMMEQuery var querys model.UEEventMMEQuery
if err := c.ShouldBindBodyWithJSON(&querys); err != nil { if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 限制导出数据集 // 限制导出数据集
@@ -181,7 +181,7 @@ func (s *MMEController) NbInfoList(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -221,7 +221,7 @@ func (s *MMEController) NbStateList(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Query("neId") neId := c.Query("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: neId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }

View File

@@ -53,7 +53,7 @@ func (s *SGWCController) CDRList(c *gin.Context) {
var querys model.CDREventSGWCQuery var querys model.CDREventSGWCQuery
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -87,7 +87,7 @@ func (s *SGWCController) CDRRemove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -127,7 +127,7 @@ func (s *SGWCController) CDRExport(c *gin.Context) {
var querys model.CDREventSGWCQuery var querys model.CDREventSGWCQuery
if err := c.ShouldBindBodyWithJSON(&querys); err != nil { if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 限制导出数据集 // 限制导出数据集

View File

@@ -55,7 +55,7 @@ func (s *SMFController) CDRList(c *gin.Context) {
var querys model.CDREventSMFQuery var querys model.CDREventSMFQuery
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -89,7 +89,7 @@ func (s *SMFController) CDRRemove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -129,7 +129,7 @@ func (s *SMFController) CDRExport(c *gin.Context) {
var querys model.CDREventSMFQuery var querys model.CDREventSMFQuery
if err := c.ShouldBindBodyWithJSON(&querys); err != nil { if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 限制导出数据集 // 限制导出数据集
@@ -181,7 +181,8 @@ func (s *SMFController) SubUserNum(c *gin.Context) {
NeId string `form:"neId" binding:"required"` NeId string `form:"neId" binding:"required"`
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -229,7 +230,8 @@ func (s *SMFController) SubUserList(c *gin.Context) {
PageNum string `form:"pageNum"` PageNum string `form:"pageNum"`
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -52,7 +52,7 @@ func (s *SMSCController) CDRList(c *gin.Context) {
var querys model.CDREventSMSCQuery var querys model.CDREventSMSCQuery
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -86,7 +86,7 @@ func (s *SMSCController) CDRRemove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -126,7 +126,7 @@ func (s *SMSCController) CDRExport(c *gin.Context) {
var querys model.CDREventSMSCQuery var querys model.CDREventSMSCQuery
if err := c.ShouldBindBodyWithJSON(&querys); err != nil { if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 限制导出数据集 // 限制导出数据集

View File

@@ -49,10 +49,9 @@ type UDMAuthController struct {
// @Description UDM Authenticated User Data List Refresh Synchronization Latest // @Description UDM Authenticated User Data List Refresh Synchronization Latest
// @Router /neData/udm/auth/resetData/{neId} [put] // @Router /neData/udm/auth/resetData/{neId} [put]
func (s *UDMAuthController) ResetData(c *gin.Context) { func (s *UDMAuthController) ResetData(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
@@ -101,7 +100,7 @@ func (s *UDMAuthController) Info(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
imsi := c.Param("imsi") imsi := c.Param("imsi")
if neId == "" || imsi == "" { if neId == "" || imsi == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi is empty"))
return return
} }
@@ -156,14 +155,18 @@ func (s *UDMAuthController) Add(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
var body model.UDMAuthUser var body model.UDMAuthUser
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil || body.IMSI == "" { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return
}
if body.IMSI == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
return return
} }
@@ -217,14 +220,18 @@ func (s *UDMAuthController) Adds(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
num := c.Param("num") num := c.Param("num")
if neId == "" || num == "" { if neId == "" || num == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/num is empty"))
return return
} }
var body model.UDMAuthUser var body model.UDMAuthUser
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil || body.IMSI == "" { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return
}
if body.IMSI == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
return return
} }
@@ -276,14 +283,18 @@ func (s *UDMAuthController) Edit(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
var body model.UDMAuthUser var body model.UDMAuthUser
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil || body.IMSI == "" { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return
}
if body.IMSI == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
return return
} }
@@ -336,7 +347,7 @@ func (s *UDMAuthController) Remove(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
imsi := c.Param("imsi") imsi := c.Param("imsi")
if neId == "" || imsi == "" { if neId == "" || imsi == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi is empty"))
return return
} }
@@ -402,7 +413,7 @@ func (s *UDMAuthController) Removes(c *gin.Context) {
imsi := c.Param("imsi") imsi := c.Param("imsi")
num := c.Param("num") num := c.Param("num")
if neId == "" || imsi == "" || num == "" { if neId == "" || imsi == "" || num == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi/num is empty"))
return return
} }
@@ -458,7 +469,7 @@ func (s *UDMAuthController) Export(c *gin.Context) {
neId := c.Query("neId") neId := c.Query("neId")
fileType := c.Query("type") fileType := c.Query("type")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
if !(fileType == "csv" || fileType == "txt") { if !(fileType == "csv" || fileType == "txt") {
@@ -546,7 +557,7 @@ func (s *UDMAuthController) Import(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -48,10 +48,9 @@ type UDMSubController struct {
// @Description UDM Subscriber User Reload Data // @Description UDM Subscriber User Reload Data
// @Router /neData/udm/sub/resetData/{neId} [put] // @Router /neData/udm/sub/resetData/{neId} [put]
func (s *UDMSubController) ResetData(c *gin.Context) { func (s *UDMSubController) ResetData(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
@@ -101,7 +100,7 @@ func (s *UDMSubController) Info(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
imsi := c.Param("imsi") imsi := c.Param("imsi")
if neId == "" || imsi == "" { if neId == "" || imsi == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId or imsi is empty"))
return return
} }
@@ -156,18 +155,18 @@ func (s *UDMSubController) Add(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
var body model.UDMSubUser var body model.UDMSubUser
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if len(body.IMSI) != 15 { if len(body.IMSI) != 15 {
c.JSON(400, resp.CodeMsg(40010, "bind err: IMSI length is not 15 bits")) c.JSON(422, resp.CodeMsg(422002, "bind err: IMSI length is not 15 bits"))
return return
} }
@@ -222,18 +221,18 @@ func (s *UDMSubController) Adds(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
num := c.Param("num") num := c.Param("num")
if neId == "" || num == "" { if neId == "" || num == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/num is empty"))
return return
} }
var body model.UDMSubUser var body model.UDMSubUser
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if len(body.IMSI) != 15 { if len(body.IMSI) != 15 {
c.JSON(400, resp.CodeMsg(40010, "bind err: IMSI length is not 15 bits")) c.JSON(422, resp.CodeMsg(422002, "bind err: IMSI length is not 15 bits"))
return return
} }
@@ -288,18 +287,18 @@ func (s *UDMSubController) Edit(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
var body model.UDMSubUser var body model.UDMSubUser
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if len(body.IMSI) != 15 { if len(body.IMSI) != 15 {
c.JSON(400, resp.CodeMsg(40010, "bind err: IMSI length is not 15 bits")) c.JSON(422, resp.CodeMsg(422002, "bind err: IMSI length is not 15 bits"))
return return
} }
@@ -353,7 +352,7 @@ func (s *UDMSubController) Remove(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
imsi := c.Param("imsi") imsi := c.Param("imsi")
if neId == "" || len(imsi) < 15 { if neId == "" || len(imsi) < 15 {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi is empty"))
return return
} }
@@ -419,7 +418,7 @@ func (s *UDMSubController) Removes(c *gin.Context) {
imsi := c.Param("imsi") imsi := c.Param("imsi")
num := c.Param("num") num := c.Param("num")
if neId == "" || len(imsi) < 15 || num == "" { if neId == "" || len(imsi) < 15 || num == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi/num is empty"))
return return
} }
@@ -476,7 +475,7 @@ func (s *UDMSubController) Export(c *gin.Context) {
neId := c.Query("neId") neId := c.Query("neId")
fileType := c.Query("type") fileType := c.Query("type")
if neId == "" || fileType == "" { if neId == "" || fileType == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId or type is empty"))
return return
} }
if !(fileType == "csv" || fileType == "txt") { if !(fileType == "csv" || fileType == "txt") {
@@ -556,7 +555,7 @@ func (s *UDMSubController) Import(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -48,10 +48,9 @@ type UDMVOIPController struct {
// @Description UDM VOIP User Data List Refresh Synchronization Latest // @Description UDM VOIP User Data List Refresh Synchronization Latest
// @Router /neData/udm/voip/resetData/{neId} [put] // @Router /neData/udm/voip/resetData/{neId} [put]
func (s *UDMVOIPController) ResetData(c *gin.Context) { func (s *UDMVOIPController) ResetData(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
@@ -100,7 +99,7 @@ func (s *UDMVOIPController) Info(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
username := c.Param("username") username := c.Param("username")
if neId == "" || username == "" { if neId == "" || username == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId or username is empty"))
return return
} }
@@ -159,14 +158,18 @@ func (s *UDMVOIPController) Add(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
var body model.UDMVOIPUser var body model.UDMVOIPUser
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil || body.UserName == "" { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return
}
if body.UserName == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: username is empty"))
return return
} }
@@ -219,14 +222,18 @@ func (s *UDMVOIPController) Adds(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
num := c.Param("num") num := c.Param("num")
if neId == "" || num == "" { if neId == "" || num == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId or num is empty"))
return return
} }
var body model.UDMVOIPUser var body model.UDMVOIPUser
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil || body.UserName == "" { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return
}
if body.UserName == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: username is empty"))
return return
} }
@@ -278,7 +285,7 @@ func (s *UDMVOIPController) Remove(c *gin.Context) {
neId := c.Param("neId") neId := c.Param("neId")
username := c.Param("username") username := c.Param("username")
if neId == "" || username == "" { if neId == "" || username == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId or username is empty"))
return return
} }
@@ -344,7 +351,7 @@ func (s *UDMVOIPController) Removes(c *gin.Context) {
username := c.Param("username") username := c.Param("username")
num := c.Param("num") num := c.Param("num")
if neId == "" || username == "" || num == "" { if neId == "" || username == "" || num == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/username/num is empty"))
return return
} }
@@ -400,11 +407,11 @@ func (s *UDMVOIPController) Export(c *gin.Context) {
neId := c.Query("neId") neId := c.Query("neId")
fileType := c.Query("type") fileType := c.Query("type")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
if !(fileType == "csv" || fileType == "txt") { if !(fileType == "csv" || fileType == "txt") {
c.JSON(200, resp.ErrMsg("File Type Error, only support csv,txt")) c.JSON(200, resp.ErrMsg("file type error, only support csv,txt"))
return return
} }
@@ -478,7 +485,7 @@ func (s *UDMVOIPController) Import(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -48,10 +48,9 @@ type UDMVolteIMSController struct {
// @Description UDM Authenticated User Data List Refresh Synchronization Latest // @Description UDM Authenticated User Data List Refresh Synchronization Latest
// @Router /neData/udm/volte-ims/resetData/{neId} [put] // @Router /neData/udm/volte-ims/resetData/{neId} [put]
func (s *UDMVolteIMSController) ResetData(c *gin.Context) { func (s *UDMVolteIMSController) ResetData(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
@@ -102,11 +101,11 @@ func (s *UDMVolteIMSController) Info(c *gin.Context) {
imsi := c.Param("imsi") imsi := c.Param("imsi")
msisdn := c.Query("msisdn") msisdn := c.Query("msisdn")
if neId == "" || imsi == "" { if neId == "" || imsi == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId or imsi is empty"))
return return
} }
if msisdn == "" { if msisdn == "" {
c.JSON(400, resp.CodeMsg(400, "msisdn is required")) c.JSON(422, resp.CodeMsg(422002, "bind err: msisdn is required"))
return return
} }
@@ -165,14 +164,18 @@ func (s *UDMVolteIMSController) Add(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
neId := c.Param("neId") neId := c.Param("neId")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
var body model.UDMVolteIMSUser var body model.UDMVolteIMSUser
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil || body.IMSI == "" { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return
}
if body.IMSI == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
return return
} }
@@ -237,9 +240,13 @@ func (s *UDMVolteIMSController) Adds(c *gin.Context) {
} }
var body model.UDMVolteIMSUser var body model.UDMVolteIMSUser
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil || body.IMSI == "" { errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return
}
if body.IMSI == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
return return
} }
@@ -375,7 +382,7 @@ func (s *UDMVolteIMSController) Removes(c *gin.Context) {
imsi := c.Param("imsi") imsi := c.Param("imsi")
num := c.Param("num") num := c.Param("num")
if neId == "" || imsi == "" || num == "" { if neId == "" || imsi == "" || num == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi/num is empty"))
return return
} }
@@ -431,7 +438,7 @@ func (s *UDMVolteIMSController) Export(c *gin.Context) {
neId := c.Query("neId") neId := c.Query("neId")
fileType := c.Query("type") fileType := c.Query("type")
if neId == "" { if neId == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
return return
} }
if !(fileType == "csv" || fileType == "txt") { if !(fileType == "csv" || fileType == "txt") {
@@ -507,7 +514,7 @@ func (s *UDMVolteIMSController) Import(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -1,6 +1,8 @@
package controller package controller
import ( import (
"fmt"
"be.ems/src/framework/i18n" "be.ems/src/framework/i18n"
"be.ems/src/framework/reqctx" "be.ems/src/framework/reqctx"
"be.ems/src/framework/resp" "be.ems/src/framework/resp"
@@ -46,7 +48,8 @@ func (s UPFController) FlowTotal(c *gin.Context) {
Day int `form:"day"` Day int `form:"day"`
} }
if err := c.ShouldBindQuery(&querys); querys.Day < 0 || err != nil { if err := c.ShouldBindQuery(&querys); querys.Day < 0 || err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -54,7 +54,7 @@ func (s *NeActionController) PushFile(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -127,7 +127,7 @@ func (s *NeActionController) PullFile(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -199,7 +199,7 @@ func (s *NeActionController) PullDirZip(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -280,7 +280,7 @@ func (s *NeActionController) ViewFile(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -341,7 +341,7 @@ func (s *NeActionController) Files(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -413,7 +413,7 @@ func (s *NeActionController) Service(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -46,7 +46,7 @@ func (s NeConfigController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := parse.Number(c.Query("id")) id := parse.Number(c.Query("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -72,14 +72,14 @@ func (s NeConfigController) Add(c *gin.Context) {
var body model.NeConfig var body model.NeConfig
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 将json数据转字符串存储 // 将json数据转字符串存储
paramDataByte, err := json.Marshal(body.ParamData) paramDataByte, err := json.Marshal(body.ParamData)
if err != nil { if err != nil {
c.JSON(400, resp.CodeMsg(400, err.Error())) c.JSON(200, resp.ErrMsg(err.Error()))
return return
} }
body.ParamJson = string(paramDataByte) body.ParamJson = string(paramDataByte)
@@ -100,7 +100,7 @@ func (s NeConfigController) Edit(c *gin.Context) {
var body model.NeConfig var body model.NeConfig
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -115,7 +115,7 @@ func (s NeConfigController) Edit(c *gin.Context) {
// 将json数据转字符串存储 // 将json数据转字符串存储
paramDataByte, err := json.Marshal(body.ParamData) paramDataByte, err := json.Marshal(body.ParamData)
if err != nil { if err != nil {
c.JSON(400, resp.CodeMsg(400, err.Error())) c.JSON(200, resp.ErrMsg(err.Error()))
return return
} }
body.ParamJson = string(paramDataByte) body.ParamJson = string(paramDataByte)
@@ -135,7 +135,7 @@ func (s NeConfigController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Query("id") id := c.Query("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -170,10 +170,9 @@ func (s NeConfigController) Remove(c *gin.Context) {
// @Description Network Element Parameter Configuration Available Attribute Values List Specify Network Element Type All Unpaged // @Description Network Element Parameter Configuration Available Attribute Values List Specify Network Element Type All Unpaged
// @Router /ne/config/list/{neType} [get] // @Router /ne/config/list/{neType} [get]
func (s NeConfigController) ListByNeType(c *gin.Context) { func (s NeConfigController) ListByNeType(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
neType := c.Param("neType") neType := c.Param("neType")
if neType == "" { if neType == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(422, resp.CodeMsg(422002, "bind err: neType is empty"))
return return
} }
data := s.neConfigService.FindByNeType(neType) data := s.neConfigService.FindByNeType(neType)
@@ -204,7 +203,7 @@ func (s NeConfigController) DataInfo(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -259,7 +258,7 @@ func (s NeConfigController) DataEdit(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -312,20 +311,20 @@ func (s NeConfigController) DataAdd(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 检查是否array // 检查是否array
info := s.neConfigService.FindByNeTypeAndParamName(body.NeType, body.ParamName) info := s.neConfigService.FindByNeTypeAndParamName(body.NeType, body.ParamName)
if info.ParamType != "array" { if info.ParamType != "array" {
c.JSON(400, resp.CodeMsg(400, "this attribute does not support adding")) c.JSON(200, resp.ErrMsg("this attribute does not support adding"))
return return
} }
// 必须含有index // 必须含有index
_, idxOk := body.ParamData["index"] _, idxOk := body.ParamData["index"]
if info.ParamType == "array" && !idxOk { if info.ParamType == "array" && !idxOk {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) c.JSON(200, resp.ErrMsg("array data must contain index"))
return return
} }
@@ -369,14 +368,15 @@ func (s NeConfigController) DataRemove(c *gin.Context) {
Loc string `form:"loc" binding:"required"` // 与数据对象内index一致,有多层时划分嵌套层(index/subParamName/index) Loc string `form:"loc" binding:"required"` // 与数据对象内index一致,有多层时划分嵌套层(index/subParamName/index)
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 检查是否array // 检查是否array
info := s.neConfigService.FindByNeTypeAndParamName(query.NeType, query.ParamName) info := s.neConfigService.FindByNeTypeAndParamName(query.NeType, query.ParamName)
if info.ParamType != "array" { if info.ParamType != "array" {
c.JSON(400, resp.CodeMsg(400, "this attribute does not support adding")) c.JSON(200, resp.ErrMsg("this attribute does not support adding"))
return return
} }

View File

@@ -50,7 +50,7 @@ func (s NeConfigBackupController) Download(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := parse.Number(c.Query("id")) id := parse.Number(c.Query("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -80,7 +80,7 @@ func (s NeConfigBackupController) Edit(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -110,7 +110,7 @@ func (s NeConfigBackupController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Query("id") id := c.Query("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -144,7 +144,7 @@ func (s NeConfigBackupController) Import(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if !strings.HasSuffix(body.Path, ".zip") { if !strings.HasSuffix(body.Path, ".zip") {
@@ -181,7 +181,7 @@ func (s NeConfigBackupController) Export(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 查网元 // 查网元

View File

@@ -75,11 +75,11 @@ func (s NeHostController) Add(c *gin.Context) {
var body model.NeHost var body model.NeHost
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.ID == 0 { if body.ID == 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id not is empty"))
return return
} }
@@ -116,11 +116,11 @@ func (s NeHostController) Edit(c *gin.Context) {
var body model.NeHost var body model.NeHost
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.ID <= 0 { if body.ID <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -196,7 +196,7 @@ func (s NeHostController) Test(c *gin.Context) {
var body model.NeHost var body model.NeHost
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -278,7 +278,7 @@ func (s NeHostController) Cmd(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -358,7 +358,7 @@ func (s NeHostController) CheckBySSH(c *gin.Context) {
var body model.NeHost var body model.NeHost
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -460,11 +460,11 @@ func (s NeHostController) AuthorizedBySSH(c *gin.Context) {
var body model.NeHost var body model.NeHost
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.AuthMode == "2" { if body.AuthMode == "2" {
c.JSON(400, resp.CodeMsg(40010, "bind err: auth mode not equals 2")) c.JSON(422, resp.CodeMsg(422002, "bind err: auth mode not equals 2"))
return return
} }

View File

@@ -41,7 +41,7 @@ func (s NeHostCmdController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := parse.Number(c.Param("id")) id := parse.Number(c.Param("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -63,7 +63,7 @@ func (s NeHostCmdController) Add(c *gin.Context) {
var body model.NeHostCmd var body model.NeHostCmd
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -93,7 +93,7 @@ func (s NeHostCmdController) Edit(c *gin.Context) {
var body model.NeHostCmd var body model.NeHostCmd
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -130,7 +130,7 @@ func (s NeHostCmdController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }

View File

@@ -58,7 +58,7 @@ func (s NeInfoController) State(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -122,7 +122,7 @@ func (s NeInfoController) NeTypeAndID(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -160,7 +160,7 @@ func (s NeInfoController) ListAll(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -202,7 +202,7 @@ func (s NeInfoController) Para5GFileWrite(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -224,7 +224,7 @@ func (s NeInfoController) OAMFileRead(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -249,7 +249,7 @@ func (s NeInfoController) OAMFileWrite(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -312,7 +312,7 @@ func (s NeInfoController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := parse.Number(c.Param("id")) id := parse.Number(c.Param("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -345,11 +345,11 @@ func (s NeInfoController) Add(c *gin.Context) {
err := c.ShouldBindBodyWithJSON(&body) err := c.ShouldBindBodyWithJSON(&body)
if err != nil { if err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.ID != 0 { if body.ID != 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id not is empty"))
return return
} }
@@ -438,11 +438,11 @@ func (s NeInfoController) Edit(c *gin.Context) {
err := c.ShouldBindBodyWithJSON(&body) err := c.ShouldBindBodyWithJSON(&body)
if err != nil { if err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.ID <= 0 { if body.ID <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -549,7 +549,7 @@ func (s NeInfoController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }

View File

@@ -66,7 +66,7 @@ func (s *NeLicenseController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := parse.Number(c.Param("id")) id := parse.Number(c.Param("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -102,7 +102,7 @@ func (s *NeLicenseController) NeTypeAndID(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -137,7 +137,8 @@ func (s *NeLicenseController) Code(c *gin.Context) {
NeId string `form:"neId" binding:"required"` NeId string `form:"neId" binding:"required"`
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -183,7 +184,8 @@ func (s *NeLicenseController) Change(c *gin.Context) {
var body model.NeLicense var body model.NeLicense
err := c.ShouldBindBodyWithJSON(&body) err := c.ShouldBindBodyWithJSON(&body)
if err != nil || body.LicensePath == "" { if err != nil || body.LicensePath == "" {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -55,7 +55,7 @@ func (s NeSoftwareController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := parse.Number(c.Param("id")) id := parse.Number(c.Param("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -86,11 +86,11 @@ func (s NeSoftwareController) Add(c *gin.Context) {
var body model.NeSoftware var body model.NeSoftware
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.Path == "" || body.ID > 0 { if body.Path == "" || body.ID > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: path is empty or id is not empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: path is empty or id is not empty"))
return return
} }
// 找到已存在的删除后重新添加 // 找到已存在的删除后重新添加
@@ -130,11 +130,11 @@ func (s NeSoftwareController) Edit(c *gin.Context) {
var body model.NeSoftware var body model.NeSoftware
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.Path == "" || body.ID == 0 { if body.Path == "" || body.ID == 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: path or id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: path or id is empty"))
return return
} }
@@ -171,7 +171,7 @@ func (s NeSoftwareController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -209,7 +209,7 @@ func (s NeSoftwareController) NewNeVersion(c *gin.Context) {
var body model.NeSoftware var body model.NeSoftware
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -40,7 +40,7 @@ func (s *NeVersionController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := parse.Number(c.Param("id")) id := parse.Number(c.Param("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -77,7 +77,7 @@ func (s *NeVersionController) Operate(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -45,13 +45,13 @@ func (s Oauth2Controller) Authorize(c *gin.Context) {
// 是否存在clientId // 是否存在clientId
info := s.oauth2ClientService.FindByClientId(query.ClientId) info := s.oauth2ClientService.FindByClientId(query.ClientId)
if info.ClientId == "" || info.ClientId != query.ClientId { if info.ClientId == "" || info.ClientId != query.ClientId {
c.JSON(422, resp.CodeMsg(422002, "clientId not exist")) c.JSON(200, resp.ErrMsg("clientId not exist"))
return return
} }
// 判断IP白名单 // 判断IP白名单
if !strings.Contains(info.IPWhite, c.ClientIP()) { if !strings.Contains(info.IPWhite, c.ClientIP()) {
c.JSON(422, resp.CodeMsg(422002, "IP whitelist mismatch")) c.JSON(200, resp.ErrMsg("IP whitelist mismatch"))
return return
} }

View File

@@ -74,7 +74,7 @@ func (s *SysConfigController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
configId := parse.Number(c.Param("configId")) configId := parse.Number(c.Param("configId"))
if configId <= 0 { if configId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: configId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: configId is empty"))
return return
} }
@@ -98,11 +98,11 @@ func (s *SysConfigController) Add(c *gin.Context) {
var body model.SysConfig var body model.SysConfig
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.ConfigId > 0 { if body.ConfigId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: configId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: configId not is empty"))
return return
} }
@@ -132,11 +132,11 @@ func (s *SysConfigController) Edit(c *gin.Context) {
var body model.SysConfig var body model.SysConfig
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.ConfigId <= 0 { if body.ConfigId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: configId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: configId is empty"))
return return
} }
@@ -197,7 +197,7 @@ func (s SysConfigController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
configId := c.Param("configId") configId := c.Param("configId")
if configId == "" { if configId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: configId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: configId is empty"))
return return
} }
@@ -234,7 +234,7 @@ func (s SysConfigController) Refresh(c *gin.Context) {
func (s SysConfigController) ConfigKey(c *gin.Context) { func (s SysConfigController) ConfigKey(c *gin.Context) {
configKey := c.Param("configKey") configKey := c.Param("configKey")
if configKey == "" { if configKey == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: configKey is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: configKey is empty"))
return return
} }
key := s.sysConfigService.FindValueByKey(configKey) key := s.sysConfigService.FindValueByKey(configKey)
@@ -255,7 +255,7 @@ func (s SysConfigController) Export(c *gin.Context) {
rows, total := s.sysConfigService.FindByPage(query) rows, total := s.sysConfigService.FindByPage(query)
if total == 0 { if total == 0 {
// c.JSON(200, resp.CodeMsg(40016, "export data record as empty")) // c.JSON(200, resp.CodeMsg(40016, "export data record as empty"))
c.JSON(200, resp.CodeMsg(40016, i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return
} }
@@ -319,7 +319,7 @@ func (s *SysConfigController) ConfigValue(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -54,7 +54,7 @@ func (s *SysDeptController) List(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -90,7 +90,7 @@ func (s SysDeptController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
deptId := parse.Number(c.Param("deptId")) deptId := parse.Number(c.Param("deptId"))
if deptId <= 0 { if deptId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: deptId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty"))
return return
} }
data := s.sysDeptService.FindById(deptId) data := s.sysDeptService.FindById(deptId)
@@ -111,11 +111,11 @@ func (s SysDeptController) Add(c *gin.Context) {
var body model.SysDept var body model.SysDept
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.DeptId > 0 { if body.DeptId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: deptId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: deptId not is empty"))
return return
} }
@@ -169,11 +169,11 @@ func (s SysDeptController) Edit(c *gin.Context) {
var body model.SysDept var body model.SysDept
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.DeptId <= 0 { if body.DeptId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: deptId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty"))
return return
} }
@@ -253,7 +253,7 @@ func (s SysDeptController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
deptId := parse.Number(c.Param("deptId")) deptId := parse.Number(c.Param("deptId"))
if deptId <= 0 { if deptId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: deptId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty"))
return return
} }
@@ -299,7 +299,7 @@ func (s SysDeptController) Remove(c *gin.Context) {
func (s *SysDeptController) ExcludeChild(c *gin.Context) { func (s *SysDeptController) ExcludeChild(c *gin.Context) {
deptIdStr := c.Param("deptId") deptIdStr := c.Param("deptId")
if deptIdStr == "" { if deptIdStr == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: deptId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty"))
return return
} }
deptId := parse.Number(deptIdStr) deptId := parse.Number(deptIdStr)
@@ -333,7 +333,7 @@ func (s *SysDeptController) Tree(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
sysDept := model.SysDept{ sysDept := model.SysDept{
@@ -367,7 +367,7 @@ func (s *SysDeptController) TreeRole(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
roleId := parse.Number(c.Param("roleId")) roleId := parse.Number(c.Param("roleId"))
if roleId <= 0 { if roleId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: roleId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty"))
return return
} }

View File

@@ -78,7 +78,7 @@ func (s SysDictDataController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
dataId := parse.Number(c.Param("dataId")) dataId := parse.Number(c.Param("dataId"))
if dataId <= 0 { if dataId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: deptId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: deptId is empty"))
return return
} }
data := s.sysDictDataService.FindById(dataId) data := s.sysDictDataService.FindById(dataId)
@@ -102,11 +102,11 @@ func (s SysDictDataController) Add(c *gin.Context) {
var body model.SysDictData var body model.SysDictData
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.DataId > 0 { if body.DataId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: dataId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: dataId not is empty"))
return return
} }
@@ -153,11 +153,11 @@ func (s SysDictDataController) Edit(c *gin.Context) {
var body model.SysDictData var body model.SysDictData
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.DataId <= 0 { if body.DataId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: dataId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: dataId is empty"))
return return
} }
@@ -232,7 +232,7 @@ func (s SysDictDataController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
dataId := c.Param("dataId") dataId := c.Param("dataId")
if dataId == "" { if dataId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: dataId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: dataId is empty"))
return return
} }
@@ -261,7 +261,7 @@ func (s SysDictDataController) DictType(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
dictType := c.Param("dictType") dictType := c.Param("dictType")
if dictType == "" { if dictType == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: dictType is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: dictType is empty"))
return return
} }
@@ -289,7 +289,7 @@ func (s SysDictDataController) Export(c *gin.Context) {
rows, total := s.sysDictDataService.FindByPage(query) rows, total := s.sysDictDataService.FindByPage(query)
if total == 0 { if total == 0 {
// c.JSON(200, resp.CodeMsg(40016, "export data record as empty")) // c.JSON(200, resp.CodeMsg(40016, "export data record as empty"))
c.JSON(200, resp.CodeMsg(40016, i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return
} }

View File

@@ -73,7 +73,7 @@ func (s *SysDictTypeController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
dictId := parse.Number(c.Param("dictId")) dictId := parse.Number(c.Param("dictId"))
if dictId <= 0 { if dictId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: dictId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: dictId is empty"))
return return
} }
data := s.sysDictTypeService.FindById(dictId) data := s.sysDictTypeService.FindById(dictId)
@@ -95,11 +95,11 @@ func (s *SysDictTypeController) Add(c *gin.Context) {
var body model.SysDictType var body model.SysDictType
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.DictId > 0 { if body.DictId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: dictId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: dictId not is empty"))
return return
} }
@@ -138,11 +138,11 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
var body model.SysDictType var body model.SysDictType
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.DictId <= 0 { if body.DictId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: dictId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: dictId is empty"))
return return
} }
@@ -205,7 +205,7 @@ func (s SysDictTypeController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
dictId := c.Param("dictId") dictId := c.Param("dictId")
if dictId == "" { if dictId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: dictId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: dictId is empty"))
return return
} }
@@ -273,7 +273,7 @@ func (s SysDictTypeController) Export(c *gin.Context) {
rows, total := s.sysDictTypeService.FindByPage(query) rows, total := s.sysDictTypeService.FindByPage(query)
if total == 0 { if total == 0 {
// c.JSON(200, resp.CodeMsg(40016, "export data record as empty")) // c.JSON(200, resp.CodeMsg(40016, "export data record as empty"))
c.JSON(200, resp.CodeMsg(40016, i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return
} }

View File

@@ -81,7 +81,7 @@ func (s SysLogLoginController) Unlock(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
userName := c.Param("userName") userName := c.Param("userName")
if userName == "" { if userName == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: userName is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: userName is empty"))
return return
} }
ok := s.accountService.CleanLoginRecordCache(userName) ok := s.accountService.CleanLoginRecordCache(userName)
@@ -103,7 +103,7 @@ func (s SysLogLoginController) Export(c *gin.Context) {
rows, total := s.sysLogLoginService.FindByPage(query, dataScopeSQL) rows, total := s.sysLogLoginService.FindByPage(query, dataScopeSQL)
if total == 0 { if total == 0 {
// c.JSON(200, resp.CodeMsg(40016, "export data record as empty")) // c.JSON(200, resp.CodeMsg(40016, "export data record as empty"))
c.JSON(200, resp.CodeMsg(40016, i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return
} }

View File

@@ -85,7 +85,7 @@ func (s SysLogOperateController) Export(c *gin.Context) {
rows, total := s.sysLogOperateService.FindByPage(query, dataScopeSQL) rows, total := s.sysLogOperateService.FindByPage(query, dataScopeSQL)
if total == 0 { if total == 0 {
// c.JSON(200, resp.CodeMsg(40016, "export data record as empty")) // c.JSON(200, resp.CodeMsg(40016, "export data record as empty"))
c.JSON(200, resp.CodeMsg(40016, i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return
} }

View File

@@ -82,7 +82,7 @@ func (s *SysMenuController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
menuId := parse.Number(c.Param("menuId")) menuId := parse.Number(c.Param("menuId"))
if menuId <= 0 { if menuId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: menuId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: menuId is empty"))
return return
} }
@@ -105,11 +105,11 @@ func (s *SysMenuController) Add(c *gin.Context) {
var body model.SysMenu var body model.SysMenu
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.MenuId > 0 { if body.MenuId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: menuId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: menuId not is empty"))
return return
} }
@@ -158,11 +158,11 @@ func (s *SysMenuController) Edit(c *gin.Context) {
var body model.SysMenu var body model.SysMenu
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.MenuId <= 0 { if body.MenuId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: menuId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: menuId is empty"))
return return
} }
@@ -278,7 +278,7 @@ func (s SysMenuController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
menuId := parse.Number(c.Param("menuId")) menuId := parse.Number(c.Param("menuId"))
if menuId <= 0 { if menuId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: menuId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: menuId is empty"))
return return
} }
@@ -359,7 +359,7 @@ func (s *SysMenuController) TreeRole(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
roleId := parse.Number(c.Param("roleId")) roleId := parse.Number(c.Param("roleId"))
if roleId <= 0 { if roleId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: roleId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty"))
return return
} }

View File

@@ -95,11 +95,11 @@ func (s *SysPostController) Add(c *gin.Context) {
var body model.SysPost var body model.SysPost
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.PostId > 0 { if body.PostId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: postId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: postId not is empty"))
return return
} }
@@ -138,11 +138,11 @@ func (s *SysPostController) Edit(c *gin.Context) {
var body model.SysPost var body model.SysPost
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.PostId <= 0 { if body.PostId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: postId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: postId is empty"))
return return
} }
@@ -206,7 +206,7 @@ func (s SysPostController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
postId := c.Param("postId") postId := c.Param("postId")
if postId == "" { if postId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: postId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: postId is empty"))
return return
} }
@@ -238,7 +238,7 @@ func (s *SysPostController) Export(c *gin.Context) {
rows, total := s.sysPostService.FindByPage(query) rows, total := s.sysPostService.FindByPage(query)
if total == 0 { if total == 0 {
// c.JSON(200, resp.CodeMsg(40016, "export data record as empty")) // c.JSON(200, resp.CodeMsg(40016, "export data record as empty"))
c.JSON(200, resp.CodeMsg(40016, i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return
} }

View File

@@ -49,7 +49,7 @@ func (s *SysProfileController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }
@@ -264,7 +264,7 @@ func (s *SysProfileController) PasswordForce(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -278,7 +278,7 @@ func (s *SysProfileController) PasswordForce(c *gin.Context) {
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }

View File

@@ -75,7 +75,7 @@ func (s *SysRoleController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
roleId := parse.Number(c.Param("roleId")) roleId := parse.Number(c.Param("roleId"))
if roleId <= 0 { if roleId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: roleId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty"))
return return
} }
data := s.sysRoleService.FindById(roleId) data := s.sysRoleService.FindById(roleId)
@@ -96,11 +96,11 @@ func (s *SysRoleController) Add(c *gin.Context) {
var body model.SysRole var body model.SysRole
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.RoleId > 0 { if body.RoleId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: roleId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: roleId not is empty"))
return return
} }
@@ -139,11 +139,11 @@ func (s *SysRoleController) Edit(c *gin.Context) {
var body model.SysRole var body model.SysRole
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.RoleId <= 0 { if body.RoleId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: roleId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty"))
return return
} }
@@ -219,7 +219,7 @@ func (s *SysRoleController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
roleId := c.Param("roleId") roleId := c.Param("roleId")
if roleId == "" { if roleId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: roleId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty"))
return return
} }
@@ -261,7 +261,7 @@ func (s SysRoleController) Status(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -311,7 +311,7 @@ func (s *SysRoleController) DataScope(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -350,7 +350,7 @@ func (s SysRoleController) UserAuthList(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
roleId := parse.Number(c.Query("roleId")) roleId := parse.Number(c.Query("roleId"))
if roleId <= 0 { if roleId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: roleId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: roleId is empty"))
return return
} }
@@ -380,11 +380,11 @@ func (s SysRoleController) UserAuthChecked(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if len(body.UserIds) <= 0 { if len(body.UserIds) <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: userIds is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: userIds is empty"))
return return
} }
@@ -419,7 +419,7 @@ func (s *SysRoleController) Export(c *gin.Context) {
rows, total := s.sysRoleService.FindByPage(query) rows, total := s.sysRoleService.FindByPage(query)
if total == 0 { if total == 0 {
// c.JSON(200, resp.CodeMsg(40016, "export data record as empty")) // c.JSON(200, resp.CodeMsg(40016, "export data record as empty"))
c.JSON(200, resp.CodeMsg(40016, i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return
} }

View File

@@ -81,7 +81,7 @@ func (s *SysUserController) Info(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
userId := parse.Number(c.Param("userId")) userId := parse.Number(c.Param("userId"))
if userId < 0 { if userId < 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: userId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: userId is empty"))
return return
} }
@@ -164,7 +164,8 @@ func (s *SysUserController) Add(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
var body model.SysUser var body model.SysUser
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
c.JSON(400, resp.ErrMsg(resp.FormatBindError(err))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -174,13 +175,13 @@ func (s *SysUserController) Add(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&bodyPassword); err != nil { if err := c.ShouldBindBodyWithJSON(&bodyPassword); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
body.Password = bodyPassword.Password body.Password = bodyPassword.Password
if body.UserId > 0 { if body.UserId > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: userId not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: userId not is empty"))
return return
} }
if !regular.ValidUsername(body.UserName) { if !regular.ValidUsername(body.UserName) {
@@ -278,11 +279,11 @@ func (s *SysUserController) Edit(c *gin.Context) {
var body model.SysUser var body model.SysUser
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.UserId <= 0 { if body.UserId <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: userId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: userId is empty"))
return return
} }
@@ -378,7 +379,7 @@ func (s *SysUserController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
userId := c.Param("userId") userId := c.Param("userId")
if userId == "" { if userId == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: userId is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: userId is empty"))
return return
} }
@@ -426,7 +427,7 @@ func (s *SysUserController) Password(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -477,7 +478,7 @@ func (s *SysUserController) Status(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -525,7 +526,7 @@ func (s *SysUserController) Export(c *gin.Context) {
rows, total := s.sysUserService.FindByPage(queryMap, dataScopeSQL) rows, total := s.sysUserService.FindByPage(queryMap, dataScopeSQL)
if total == 0 { if total == 0 {
// c.JSON(200, resp.CodeMsg(40016, "export data record as empty")) // c.JSON(200, resp.CodeMsg(40016, "export data record as empty"))
c.JSON(200, resp.CodeMsg(40016, i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return
} }
@@ -647,7 +648,7 @@ func (s *SysUserController) Import(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -54,7 +54,8 @@ func (s *IPerfController) Version(c *gin.Context) {
Version string `form:"version" binding:"required,oneof=V2 V3"` // 版本 Version string `form:"version" binding:"required,oneof=V2 V3"` // 版本
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -88,7 +89,8 @@ func (s *IPerfController) Install(c *gin.Context) {
Version string `form:"version" binding:"required,oneof=V2 V3"` // 版本 Version string `form:"version" binding:"required,oneof=V2 V3"` // 版本
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -125,14 +127,15 @@ func (s *IPerfController) Run(c *gin.Context) {
Rows int `form:"rows"` // 终端显示行数 Rows int `form:"rows"` // 终端显示行数
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }

View File

@@ -48,7 +48,8 @@ func (s *PingController) Statistics(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
var body model.Ping var body model.Ping
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -78,7 +79,7 @@ func (s *PingController) StatisticsOn(c *gin.Context) {
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }
@@ -122,7 +123,8 @@ func (s *PingController) Version(c *gin.Context) {
NeID string `form:"neId" binding:"required"` // 网元ID NeID string `form:"neId" binding:"required"` // 网元ID
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -160,14 +162,15 @@ func (s *PingController) Run(c *gin.Context) {
Rows int `form:"rows"` // 终端显示行数 Rows int `form:"rows"` // 终端显示行数
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }

View File

@@ -46,7 +46,7 @@ func (s *PacketController) Start(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -68,7 +68,7 @@ func (s *PacketController) Stop(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -90,7 +90,7 @@ func (s *PacketController) Filter(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -112,7 +112,7 @@ func (s *PacketController) KeepAlive(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -137,7 +137,7 @@ func (s *PacketController) FilePull(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
fileName := fmt.Sprintf("%s.pcap", querys.TaskNo) fileName := fmt.Sprintf("%s.pcap", querys.TaskNo)

View File

@@ -43,10 +43,9 @@ func (s *TCPdumpController) DumpStart(c *gin.Context) {
NeId string `json:"neId" binding:"required"` // 网元ID NeId string `json:"neId" binding:"required"` // 网元ID
Cmd string `json:"cmd" binding:"required"` // 命令 "-n -s 0 -v" Cmd string `json:"cmd" binding:"required"` // 命令 "-n -s 0 -v"
} }
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -78,10 +77,9 @@ func (s *TCPdumpController) DumpStop(c *gin.Context) {
NeId string `json:"neId" binding:"required"` // 网元ID NeId string `json:"neId" binding:"required"` // 网元ID
TaskCode string `json:"taskCode" binding:"required"` // 任务码,停止任务并查看日志信息 TaskCode string `json:"taskCode" binding:"required"` // 任务码,停止任务并查看日志信息
} }
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -113,10 +111,9 @@ func (s *TCPdumpController) UPFTrace(c *gin.Context) {
NeId string `json:"neId" binding:"required"` // 网元ID NeId string `json:"neId" binding:"required"` // 网元ID
Cmd string `json:"cmd" binding:"required"` // 命令 Cmd string `json:"cmd" binding:"required"` // 命令
} }
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -37,7 +37,7 @@ func (s *TraceDataController) List(c *gin.Context) {
func (s *TraceDataController) Info(c *gin.Context) { func (s *TraceDataController) Info(c *gin.Context) {
id := parse.Number(c.Param("id")) id := parse.Number(c.Param("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -56,7 +56,7 @@ func (s *TraceDataController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }

View File

@@ -43,7 +43,7 @@ func (s *TraceTaskController) List(c *gin.Context) {
func (s *TraceTaskController) Info(c *gin.Context) { func (s *TraceTaskController) Info(c *gin.Context) {
id := parse.Number(c.Param("id")) id := parse.Number(c.Param("id"))
if id <= 0 { if id <= 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -61,19 +61,18 @@ func (s *TraceTaskController) Info(c *gin.Context) {
func (s *TraceTaskController) Add(c *gin.Context) { func (s *TraceTaskController) Add(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
var body model.TraceTask var body model.TraceTask
err := c.ShouldBindBodyWithJSON(&body) if err := c.ShouldBindBodyWithJSON(&body); err != nil {
if err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.ID > 0 { if body.ID > 0 {
c.JSON(400, resp.CodeMsg(40010, "bind err: id not is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id not is empty"))
return return
} }
body.CreateBy = reqctx.LoginUserToUserName(c) body.CreateBy = reqctx.LoginUserToUserName(c)
if err = s.traceTaskService.Insert(body); err != nil { if err := s.traceTaskService.Insert(body); err != nil {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error()))) c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
return return
} }
@@ -87,7 +86,7 @@ func (s *TraceTaskController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -112,12 +111,12 @@ func (s *TraceTaskController) Remove(c *gin.Context) {
// //
// GET /filePull // GET /filePull
func (s *TraceTaskController) FilePull(c *gin.Context) { func (s *TraceTaskController) FilePull(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
var querys struct { var querys struct {
TraceId string `form:"traceId" binding:"required"` TraceId string `form:"traceId" binding:"required"`
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }

View File

@@ -36,10 +36,10 @@ type TraceTaskHlrController struct {
// //
// GET /list // GET /list
func (s *TraceTaskHlrController) List(c *gin.Context) { func (s *TraceTaskHlrController) List(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
var query model.TraceTaskHlrQuery var query model.TraceTaskHlrQuery
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -54,7 +54,7 @@ func (s *TraceTaskHlrController) Remove(c *gin.Context) {
language := reqctx.AcceptLanguage(c) language := reqctx.AcceptLanguage(c)
id := c.Param("id") id := c.Param("id")
if id == "" { if id == "" {
c.JSON(400, resp.CodeMsg(40010, "bind err: id is empty")) c.JSON(422, resp.CodeMsg(422002, "bind err: id is empty"))
return return
} }
@@ -79,7 +79,6 @@ func (s *TraceTaskHlrController) Remove(c *gin.Context) {
// //
// POST /start // POST /start
func (s *TraceTaskHlrController) Start(c *gin.Context) { func (s *TraceTaskHlrController) Start(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
var body struct { var body struct {
IMSI string `json:"imsi"` // IMSI IMSI string `json:"imsi"` // IMSI
MSISDN string `json:"msisdn"` // MSISDN MSISDN string `json:"msisdn"` // MSISDN
@@ -88,12 +87,13 @@ func (s *TraceTaskHlrController) Start(c *gin.Context) {
Remark string `json:"remark"` // 备注说明 Remark string `json:"remark"` // 备注说明
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if body.IMSI == "" && body.MSISDN == "" { if body.IMSI == "" && body.MSISDN == "" {
c.JSON(400, resp.CodeMsg(400, "imsi amd msisdn is empty")) c.JSON(422, resp.CodeMsg(422002, "imsi amd msisdn is empty"))
return return
} }
@@ -117,12 +117,12 @@ func (s *TraceTaskHlrController) Start(c *gin.Context) {
// //
// POST /stop // POST /stop
func (s *TraceTaskHlrController) Stop(c *gin.Context) { func (s *TraceTaskHlrController) Stop(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
var body struct { var body struct {
ID string `json:"id" binding:"required"` // 任务ID ID string `json:"id" binding:"required"` // 任务ID
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
@@ -162,13 +162,13 @@ func (s *TraceTaskHlrController) File(c *gin.Context) {
} }
if err := c.ShouldBindBodyWithJSON(&body); err != nil { if err := c.ShouldBindBodyWithJSON(&body); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
task := s.traceTaskHlrService.FindById(body.ID) task := s.traceTaskHlrService.FindById(body.ID)
if task.ID == 0 || task.ID != body.ID { if task.ID == 0 || task.ID != body.ID {
c.JSON(200, resp.CodeMsg(400, "task not found")) c.JSON(422, resp.CodeMsg(422002, "task not found"))
return return
} }
@@ -194,14 +194,14 @@ func (s *TraceTaskHlrController) FilePull(c *gin.Context) {
} }
if err := c.ShouldBindQuery(&querys); err != nil { if err := c.ShouldBindQuery(&querys); err != nil {
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err)) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(40422, errMsgs)) c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 查询网元获取IP // 查询网元获取IP
neInfo := s.neInfoService.FindByNeTypeAndNeID(querys.NeType, querys.NeID) neInfo := s.neInfoService.FindByNeTypeAndNeID(querys.NeType, querys.NeID)
if neInfo.NeId != querys.NeID || neInfo.IP == "" { if neInfo.NeId != querys.NeID || neInfo.IP == "" {
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo"))) c.JSON(422, resp.CodeMsg(422002, i18n.TKey(language, "app.common.noNEInfo")))
return return
} }

View File

@@ -48,7 +48,7 @@ func (s *WSController) WS(c *gin.Context) {
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }
@@ -92,7 +92,7 @@ func (s *WSController) Test(c *gin.Context) {
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }

View File

@@ -1,6 +1,8 @@
package controller package controller
import ( import (
"fmt"
"be.ems/src/framework/database/redis" "be.ems/src/framework/database/redis"
"be.ems/src/framework/i18n" "be.ems/src/framework/i18n"
"be.ems/src/framework/logger" "be.ems/src/framework/logger"
@@ -20,14 +22,15 @@ func (s *WSController) Redis(c *gin.Context) {
HostId int64 `form:"hostId" binding:"required"` // 连接主机ID HostId int64 `form:"hostId" binding:"required"` // 连接主机ID
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }

View File

@@ -26,7 +26,8 @@ func (s *WSController) SSH(c *gin.Context) {
Rows int `form:"rows"` // 终端显示行数 Rows int `form:"rows"` // 终端显示行数
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if query.Cols < 80 || query.Cols > 400 { if query.Cols < 80 || query.Cols > 400 {
@@ -39,7 +40,7 @@ func (s *WSController) SSH(c *gin.Context) {
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }

View File

@@ -26,7 +26,8 @@ func (s *WSController) Telnet(c *gin.Context) {
Rows int `form:"rows"` // 终端显示行数 Rows int `form:"rows"` // 终端显示行数
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if query.Cols < 120 || query.Cols > 400 { if query.Cols < 120 || query.Cols > 400 {
@@ -39,7 +40,7 @@ func (s *WSController) Telnet(c *gin.Context) {
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }

View File

@@ -39,7 +39,8 @@ func (s *WSController) ShellView(c *gin.Context) {
Rows int `form:"rows"` // 终端显示行数 Rows int `form:"rows"` // 终端显示行数
} }
if err := c.ShouldBindQuery(&query); err != nil { if err := c.ShouldBindQuery(&query); err != nil {
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400"))) errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
c.JSON(422, resp.CodeMsg(422001, errMsgs))
return return
} }
if query.Cols < 120 || query.Cols > 400 { if query.Cols < 120 || query.Cols > 400 {
@@ -52,7 +53,7 @@ func (s *WSController) ShellView(c *gin.Context) {
// 登录用户信息 // 登录用户信息
loginUser, err := reqctx.LoginUser(c) loginUser, err := reqctx.LoginUser(c)
if err != nil { if err != nil {
c.JSON(401, resp.CodeMsg(401, i18n.TKey(language, err.Error()))) c.JSON(401, resp.CodeMsg(401002, i18n.TKey(language, err.Error())))
return return
} }