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:
@@ -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"
|
||||
)
|
||||
@@ -20,14 +20,14 @@ func ErrorCatch() gin.HandlerFunc {
|
||||
|
||||
// 返回错误响应给客户端
|
||||
if config.Env() == "prod" {
|
||||
c.JSON(500, resp.CodeMsg(500, "Internal Server Errors"))
|
||||
c.JSON(500, resp.CodeMsg(500001, "Internal Server Errors"))
|
||||
} else {
|
||||
// 通过实现 error 接口的 Error() 方法自定义错误类型进行捕获
|
||||
switch v := err.(type) {
|
||||
case error:
|
||||
c.JSON(500, resp.CodeMsg(500, v.Error()))
|
||||
c.JSON(500, resp.CodeMsg(500001, v.Error()))
|
||||
default:
|
||||
c.JSON(500, resp.CodeMsg(500, fmt.Sprint(err)))
|
||||
c.JSON(500, resp.CodeMsg(500001, fmt.Sprint(err)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ func OperateLog(options Options) gin.HandlerFunc {
|
||||
// 获取登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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() // 停止执行后续的处理函数
|
||||
return
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func CryptoApi(requestDecrypt, responseEncrypt bool) gin.HandlerFunc {
|
||||
|
||||
// 是否存在data字段数据
|
||||
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() // 停止执行后续的处理函数
|
||||
return
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func CryptoApi(requestDecrypt, responseEncrypt bool) gin.HandlerFunc {
|
||||
dataBodyStr, err := crypto.AESDecryptBase64(contentDe, apiKey)
|
||||
if err != nil {
|
||||
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() // 停止执行后续的处理函数
|
||||
return
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func OperateLog(options Options) gin.HandlerFunc {
|
||||
// 获取登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
if err != nil {
|
||||
c.JSON(401, resp.CodeMsg(401, "无效身份授权"))
|
||||
c.JSON(401, resp.CodeMsg(401002, "invalid login user information"))
|
||||
c.Abort() // 停止执行后续的处理函数
|
||||
return
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func RateLimit(option LimitOption) gin.HandlerFunc {
|
||||
if option.Type == LIMIT_USER {
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
if err != nil {
|
||||
c.JSON(401, resp.CodeMsg(40003, err.Error()))
|
||||
c.JSON(401, resp.CodeMsg(401002, "invalid login user information"))
|
||||
c.Abort() // 停止执行后续的处理函数
|
||||
return
|
||||
}
|
||||
@@ -80,13 +80,13 @@ func RateLimit(option LimitOption) gin.HandlerFunc {
|
||||
// 在Redis查询并记录请求次数
|
||||
rateCount, err := redis.RateLimit("", limitKey, option.Time, option.Count)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.CodeMsg(4013, "访问过于频繁,请稍候再试"))
|
||||
c.JSON(200, resp.ErrMsg("access too often, please try again later"))
|
||||
c.Abort() // 停止执行后续的处理函数
|
||||
return
|
||||
}
|
||||
rateTime, err := redis.GetExpire("", limitKey)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.CodeMsg(4013, "访问过于频繁,请稍候再试"))
|
||||
c.JSON(200, resp.ErrMsg("access too often, please try again later"))
|
||||
c.Abort() // 停止执行后续的处理函数
|
||||
return
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func RateLimit(option LimitOption) gin.HandlerFunc {
|
||||
c.Header("X-RateLimit-Reset", fmt.Sprintf("%d", time.Now().Unix()+rateTime)) // 重置时间戳
|
||||
|
||||
if rateCount >= option.Count {
|
||||
c.JSON(200, resp.CodeMsg(4013, "访问过于频繁,请稍候再试"))
|
||||
c.JSON(200, resp.ErrMsg("access too often, please try again later"))
|
||||
c.Abort() // 停止执行后续的处理函数
|
||||
return
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func RepeatSubmit(interval int64) gin.HandlerFunc {
|
||||
|
||||
// 小于间隔时间且参数内容一致
|
||||
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()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"be.ems/src/framework/constants"
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/reqctx"
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/framework/token"
|
||||
@@ -140,7 +141,8 @@ func (s *BootloaderController) Account(c *gin.Context) {
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mojocn/base64Captcha"
|
||||
|
||||
"be.ems/src/framework/config"
|
||||
"be.ems/src/framework/constants"
|
||||
"be.ems/src/framework/database/redis"
|
||||
@@ -10,42 +14,30 @@ import (
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/framework/utils/parse"
|
||||
systemService "be.ems/src/modules/system/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/mojocn/base64Captcha"
|
||||
)
|
||||
|
||||
// 实例化控制层 CaptchaController 结构体
|
||||
// NewCaptcha 实例化控制层
|
||||
var NewCaptcha = &CaptchaController{
|
||||
sysConfigService: systemService.NewSysConfig,
|
||||
}
|
||||
|
||||
// 验证码操作处理
|
||||
// CaptchaController 验证码操作 控制层处理
|
||||
//
|
||||
// PATH /
|
||||
type CaptchaController struct {
|
||||
sysConfigService *systemService.SysConfig // 参数配置服务
|
||||
}
|
||||
|
||||
// 获取验证码
|
||||
// Image 获取验证码-图片
|
||||
//
|
||||
// GET /captchaImage
|
||||
//
|
||||
// @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) {
|
||||
// GET /captcha-image
|
||||
func (s CaptchaController) Image(c *gin.Context) {
|
||||
// 从数据库配置获取验证码开关 true开启,false关闭
|
||||
captchaEnabledStr := s.sysConfigService.FindValueByKey("sys.account.captchaEnabled")
|
||||
captchaEnabled := parse.Boolean(captchaEnabledStr)
|
||||
if !captchaEnabled {
|
||||
c.JSON(200, resp.Ok(map[string]any{
|
||||
"captchaEnabled": captchaEnabled,
|
||||
c.JSON(200, resp.OkData(map[string]any{
|
||||
"enabled": captchaEnabled,
|
||||
}))
|
||||
return
|
||||
}
|
||||
@@ -53,14 +45,16 @@ func (s *CaptchaController) Image(c *gin.Context) {
|
||||
// 生成唯一标识
|
||||
verifyKey := ""
|
||||
data := map[string]any{
|
||||
"captchaEnabled": captchaEnabled,
|
||||
"uuid": "",
|
||||
"img": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
||||
"enabled": captchaEnabled,
|
||||
"uuid": "",
|
||||
"img": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
|
||||
}
|
||||
|
||||
// 验证码有效期,单位秒
|
||||
captchaExpiration := 2 * 60 * time.Second
|
||||
// 从数据库配置获取验证码类型 math 数值计算 char 字符验证
|
||||
captchaType := s.sysConfigService.FindValueByKey("sys.account.captchaType")
|
||||
if captchaType == constants.CAPTCHA_TYPE_MATH {
|
||||
if captchaType == "math" {
|
||||
math := config.Get("mathCaptcha").(map[string]any)
|
||||
driverCaptcha := &base64Captcha.DriverMath{
|
||||
//Height png height in pixel.
|
||||
@@ -81,16 +75,15 @@ func (s *CaptchaController) Image(c *gin.Context) {
|
||||
// 验证码表达式解析输出
|
||||
item, err := driverCaptcha.DrawCaptcha(question)
|
||||
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 {
|
||||
data["uuid"] = id
|
||||
data["img"] = item.EncodeB64string()
|
||||
expiration := constants.CAPTCHA_EXPIRATION * time.Second
|
||||
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)
|
||||
driverCaptcha := &base64Captcha.DriverString{
|
||||
//Height png height in pixel.
|
||||
@@ -115,13 +108,12 @@ func (s *CaptchaController) Image(c *gin.Context) {
|
||||
// 验证码表达式解析输出
|
||||
item, err := driverCaptcha.DrawCaptcha(question)
|
||||
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 {
|
||||
data["uuid"] = id
|
||||
data["img"] = item.EncodeB64string()
|
||||
expiration := constants.CAPTCHA_EXPIRATION * time.Second
|
||||
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" {
|
||||
text, _ := redis.Get("", verifyKey)
|
||||
data["text"] = text
|
||||
c.JSON(200, resp.Ok(data))
|
||||
c.JSON(200, resp.OkData(data))
|
||||
return
|
||||
}
|
||||
c.JSON(200, resp.Ok(data))
|
||||
c.JSON(200, resp.OkData(data))
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ package controller
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/reqctx"
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/modules/chart/service"
|
||||
|
||||
@@ -62,7 +60,7 @@ func (s *ChartGraphController) Load(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,7 +92,7 @@ func (s *ChartGraphController) Save(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -125,10 +123,9 @@ func (s *ChartGraphController) Save(c *gin.Context) {
|
||||
// @Description Deleting Relationship Diagram Data
|
||||
// @Router /chart/graph/{group} [delete]
|
||||
func (s *ChartGraphController) Delete(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
group := c.Param("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
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/reqctx"
|
||||
"be.ems/src/framework/resp"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -31,10 +32,8 @@ func (s CommonController) Hash(c *gin.Context) {
|
||||
Str string `json:"str" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&body); err != nil {
|
||||
c.JSON(200, gin.H{
|
||||
"code": 400,
|
||||
"msg": "参数错误",
|
||||
})
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,13 @@ func (s *FileController) Download(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
filePath := c.Param("filePath")
|
||||
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
|
||||
}
|
||||
// base64解析出地址
|
||||
decodedBytes, err := base64.StdEncoding.DecodeString(filePath)
|
||||
if err != nil {
|
||||
c.JSON(400, resp.CodeMsg(400, err.Error()))
|
||||
c.JSON(422, resp.CodeMsg(422002, err.Error()))
|
||||
return
|
||||
}
|
||||
routerPath := string(decodedBytes)
|
||||
@@ -87,14 +87,14 @@ func (s *FileController) Upload(c *gin.Context) {
|
||||
// 上传的文件
|
||||
formFile, err := c.FormFile("file")
|
||||
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
|
||||
}
|
||||
// 子路径需要在指定范围内
|
||||
subPath := c.PostForm("subPath")
|
||||
_, ok := constants.UPLOAD_SUB_PATH[subPath]
|
||||
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
|
||||
}
|
||||
if subPath == "" {
|
||||
@@ -136,7 +136,7 @@ func (s *FileController) ChunkCheck(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -170,12 +170,12 @@ func (s *FileController) ChunkMerge(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 子路径需要在指定范围内
|
||||
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
|
||||
}
|
||||
if body.SubPath == "" {
|
||||
@@ -218,13 +218,13 @@ func (s *FileController) ChunkUpload(c *gin.Context) {
|
||||
// 切片唯一标识
|
||||
identifier := c.PostForm("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
|
||||
}
|
||||
// 上传的文件
|
||||
formFile, err := c.FormFile("file")
|
||||
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
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ func (s *FileController) List(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ func (s *FileController) File(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ func (s *FileController) Remove(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ func (s *FileController) TransferStaticFile(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ func (s *FileController) TransferStaticFile(c *gin.Context) {
|
||||
static := config.Get("staticFile.default").(map[string]any)
|
||||
dir, err := filepath.Abs(static["dir"].(string))
|
||||
if err != nil {
|
||||
c.JSON(400, resp.CodeMsg(400, err.Error()))
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ func (s *FileController) TransferStaticFile(c *gin.Context) {
|
||||
|
||||
err = file.CopyUploadFile(body.UploadPath, newFile)
|
||||
if err != nil {
|
||||
c.JSON(400, resp.CodeMsg(400, err.Error()))
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ func (s *MonitorController) Load(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ func (s SysCacheController) Keys(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ func (s SysCacheController) Value(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func (s SysCacheController) CleanKeys(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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 {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ func (s *SysJobController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
jobId := parse.Number(c.Param("jobId"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -87,11 +87,11 @@ func (s *SysJobController) Add(c *gin.Context) {
|
||||
var body model.SysJob
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -143,11 +143,11 @@ func (s *SysJobController) Edit(c *gin.Context) {
|
||||
var body model.SysJob
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ func (s *SysJobController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
jobId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ func (s *SysJobController) Status(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ func (s *SysJobController) Run(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
jobId := parse.Number(c.Param("jobId"))
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ func (s *SysJobLogController) List(c *gin.Context) {
|
||||
func (s *SysJobLogController) Info(c *gin.Context) {
|
||||
logId := parse.Number(c.Param("logId"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (s *SysJobLogController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
logId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -143,13 +143,6 @@ func (s *SysJobLogController) Export(c *gin.Context) {
|
||||
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) {
|
||||
for i := range *arr {
|
||||
|
||||
@@ -57,7 +57,7 @@ func (s AlarmController) List(c *gin.Context) {
|
||||
var query model.AlarmQuery
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 查询数据
|
||||
@@ -72,7 +72,7 @@ func (s AlarmController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func (s AlarmController) Clear(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (s AlarmController) Ack(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ func (s AlarmController) Export(c *gin.Context) {
|
||||
var query model.AlarmQuery
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
|
||||
@@ -43,7 +43,7 @@ func (s AlarmForwardController) List(c *gin.Context) {
|
||||
var query model.AlarmForwardLogQuery
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 查询数据
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s AlarmLogController) List(c *gin.Context) {
|
||||
var query model.AlarmLogQuery
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 查询数据
|
||||
@@ -82,7 +82,7 @@ func (s AlarmLogController) Event(c *gin.Context) {
|
||||
var query model.AlarmEventQuery
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 查询数据
|
||||
|
||||
@@ -35,7 +35,7 @@ func (s BackupController) FTPUpdate(c *gin.Context) {
|
||||
var body model.BackupDataFTP
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (s BackupController) FTPPush(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 判断路径是否合法
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s KPIController) KPIData(c *gin.Context) {
|
||||
var querys model.KPIQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func (s KPIController) KPIData(c *gin.Context) {
|
||||
func (s KPIController) KPITitle(c *gin.Context) {
|
||||
neType := c.Query("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
|
||||
}
|
||||
kpiTitles := s.kpiReportService.FindTitle(neType)
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s NBStateController) List(c *gin.Context) {
|
||||
var query model.NBStateQuery
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (s NBStateController) Export(c *gin.Context) {
|
||||
var querys model.NBStateQuery
|
||||
if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s *AMFController) UEList(c *gin.Context) {
|
||||
var querys model.UEEventAMFQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (s *AMFController) UERemove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func (s *AMFController) UEExport(c *gin.Context) {
|
||||
var querys model.UEEventAMFQuery
|
||||
if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
@@ -181,7 +181,7 @@ func (s *AMFController) NbInfoList(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func (s *AMFController) NbStateList(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Query("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
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s *IMSController) CDRList(c *gin.Context) {
|
||||
var querys model.CDREventIMSQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ func (s *IMSController) CDRRemove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func (s *IMSController) CDRExport(c *gin.Context) {
|
||||
var querys model.CDREventIMSQuery
|
||||
if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
@@ -177,7 +177,7 @@ func (s *IMSController) UeSessionNum(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Query("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
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ func (s *IMSController) UeSessionList(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s *MMEController) UEList(c *gin.Context) {
|
||||
var querys model.UEEventMMEQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (s *MMEController) UERemove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func (s *MMEController) UEExport(c *gin.Context) {
|
||||
var querys model.UEEventMMEQuery
|
||||
if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
@@ -181,7 +181,7 @@ func (s *MMEController) NbInfoList(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func (s *MMEController) NbStateList(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Query("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
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ func (s *SGWCController) CDRList(c *gin.Context) {
|
||||
var querys model.CDREventSGWCQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ func (s *SGWCController) CDRRemove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func (s *SGWCController) CDRExport(c *gin.Context) {
|
||||
var querys model.CDREventSGWCQuery
|
||||
if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
|
||||
@@ -55,7 +55,7 @@ func (s *SMFController) CDRList(c *gin.Context) {
|
||||
var querys model.CDREventSMFQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (s *SMFController) CDRRemove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ func (s *SMFController) CDRExport(c *gin.Context) {
|
||||
var querys model.CDREventSMFQuery
|
||||
if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
@@ -181,7 +181,8 @@ func (s *SMFController) SubUserNum(c *gin.Context) {
|
||||
NeId string `form:"neId" binding:"required"`
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -229,7 +230,8 @@ func (s *SMFController) SubUserList(c *gin.Context) {
|
||||
PageNum string `form:"pageNum"`
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s *SMSCController) CDRList(c *gin.Context) {
|
||||
var querys model.CDREventSMSCQuery
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (s *SMSCController) CDRRemove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func (s *SMSCController) CDRExport(c *gin.Context) {
|
||||
var querys model.CDREventSMSCQuery
|
||||
if err := c.ShouldBindBodyWithJSON(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 限制导出数据集
|
||||
|
||||
@@ -49,10 +49,9 @@ type UDMAuthController struct {
|
||||
// @Description UDM Authenticated User Data List Refresh Synchronization Latest
|
||||
// @Router /neData/udm/auth/resetData/{neId} [put]
|
||||
func (s *UDMAuthController) ResetData(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@ func (s *UDMAuthController) Info(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
imsi := c.Param("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
|
||||
}
|
||||
|
||||
@@ -156,14 +155,18 @@ func (s *UDMAuthController) Add(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMAuthUser
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil || body.IMSI == "" {
|
||||
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.IMSI == "" {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -217,14 +220,18 @@ func (s *UDMAuthController) Adds(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
num := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMAuthUser
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil || body.IMSI == "" {
|
||||
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.IMSI == "" {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -276,14 +283,18 @@ func (s *UDMAuthController) Edit(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMAuthUser
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil || body.IMSI == "" {
|
||||
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.IMSI == "" {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -336,7 +347,7 @@ func (s *UDMAuthController) Remove(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
imsi := c.Param("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
|
||||
}
|
||||
|
||||
@@ -402,7 +413,7 @@ func (s *UDMAuthController) Removes(c *gin.Context) {
|
||||
imsi := c.Param("imsi")
|
||||
num := c.Param("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
|
||||
}
|
||||
|
||||
@@ -458,7 +469,7 @@ func (s *UDMAuthController) Export(c *gin.Context) {
|
||||
neId := c.Query("neId")
|
||||
fileType := c.Query("type")
|
||||
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
|
||||
}
|
||||
if !(fileType == "csv" || fileType == "txt") {
|
||||
@@ -546,7 +557,7 @@ func (s *UDMAuthController) Import(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,9 @@ type UDMSubController struct {
|
||||
// @Description UDM Subscriber User Reload Data
|
||||
// @Router /neData/udm/sub/resetData/{neId} [put]
|
||||
func (s *UDMSubController) ResetData(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@ func (s *UDMSubController) Info(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
imsi := c.Param("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
|
||||
}
|
||||
|
||||
@@ -156,18 +155,18 @@ func (s *UDMSubController) Add(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMSubUser
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -222,18 +221,18 @@ func (s *UDMSubController) Adds(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
num := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMSubUser
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -288,18 +287,18 @@ func (s *UDMSubController) Edit(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMSubUser
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -353,7 +352,7 @@ func (s *UDMSubController) Remove(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
imsi := c.Param("imsi")
|
||||
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
|
||||
}
|
||||
|
||||
@@ -419,7 +418,7 @@ func (s *UDMSubController) Removes(c *gin.Context) {
|
||||
imsi := c.Param("imsi")
|
||||
num := c.Param("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
|
||||
}
|
||||
|
||||
@@ -476,7 +475,7 @@ func (s *UDMSubController) Export(c *gin.Context) {
|
||||
neId := c.Query("neId")
|
||||
fileType := c.Query("type")
|
||||
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
|
||||
}
|
||||
if !(fileType == "csv" || fileType == "txt") {
|
||||
@@ -556,7 +555,7 @@ func (s *UDMSubController) Import(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,9 @@ type UDMVOIPController struct {
|
||||
// @Description UDM VOIP User Data List Refresh Synchronization Latest
|
||||
// @Router /neData/udm/voip/resetData/{neId} [put]
|
||||
func (s *UDMVOIPController) ResetData(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -100,7 +99,7 @@ func (s *UDMVOIPController) Info(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
username := c.Param("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
|
||||
}
|
||||
|
||||
@@ -159,14 +158,18 @@ func (s *UDMVOIPController) Add(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMVOIPUser
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil || body.UserName == "" {
|
||||
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.UserName == "" {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: username is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -219,14 +222,18 @@ func (s *UDMVOIPController) Adds(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
num := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMVOIPUser
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil || body.UserName == "" {
|
||||
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.UserName == "" {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: username is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -278,7 +285,7 @@ func (s *UDMVOIPController) Remove(c *gin.Context) {
|
||||
neId := c.Param("neId")
|
||||
username := c.Param("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
|
||||
}
|
||||
|
||||
@@ -344,7 +351,7 @@ func (s *UDMVOIPController) Removes(c *gin.Context) {
|
||||
username := c.Param("username")
|
||||
num := c.Param("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
|
||||
}
|
||||
|
||||
@@ -400,11 +407,11 @@ func (s *UDMVOIPController) Export(c *gin.Context) {
|
||||
neId := c.Query("neId")
|
||||
fileType := c.Query("type")
|
||||
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
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -478,7 +485,7 @@ func (s *UDMVOIPController) Import(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,9 @@ type UDMVolteIMSController struct {
|
||||
// @Description UDM Authenticated User Data List Refresh Synchronization Latest
|
||||
// @Router /neData/udm/volte-ims/resetData/{neId} [put]
|
||||
func (s *UDMVolteIMSController) ResetData(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -102,11 +101,11 @@ func (s *UDMVolteIMSController) Info(c *gin.Context) {
|
||||
imsi := c.Param("imsi")
|
||||
msisdn := c.Query("msisdn")
|
||||
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
|
||||
}
|
||||
if msisdn == "" {
|
||||
c.JSON(400, resp.CodeMsg(400, "msisdn is required"))
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: msisdn is required"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -165,14 +164,18 @@ func (s *UDMVolteIMSController) Add(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neId := c.Param("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
|
||||
}
|
||||
|
||||
var body model.UDMVolteIMSUser
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil || body.IMSI == "" {
|
||||
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.IMSI == "" {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -237,9 +240,13 @@ func (s *UDMVolteIMSController) Adds(c *gin.Context) {
|
||||
}
|
||||
|
||||
var body model.UDMVolteIMSUser
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil || body.IMSI == "" {
|
||||
c.JSON(400, resp.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.IMSI == "" {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -375,7 +382,7 @@ func (s *UDMVolteIMSController) Removes(c *gin.Context) {
|
||||
imsi := c.Param("imsi")
|
||||
num := c.Param("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
|
||||
}
|
||||
|
||||
@@ -431,7 +438,7 @@ func (s *UDMVolteIMSController) Export(c *gin.Context) {
|
||||
neId := c.Query("neId")
|
||||
fileType := c.Query("type")
|
||||
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
|
||||
}
|
||||
if !(fileType == "csv" || fileType == "txt") {
|
||||
@@ -507,7 +514,7 @@ func (s *UDMVolteIMSController) Import(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/reqctx"
|
||||
"be.ems/src/framework/resp"
|
||||
@@ -46,7 +48,8 @@ func (s UPFController) FlowTotal(c *gin.Context) {
|
||||
Day int `form:"day"`
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ func (s *NeActionController) PushFile(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func (s *NeActionController) PullFile(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ func (s *NeActionController) PullDirZip(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ func (s *NeActionController) ViewFile(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ func (s *NeActionController) Files(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ func (s *NeActionController) Service(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ func (s NeConfigController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := parse.Number(c.Query("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -72,14 +72,14 @@ func (s NeConfigController) Add(c *gin.Context) {
|
||||
var body model.NeConfig
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
// 将json数据转字符串存储
|
||||
paramDataByte, err := json.Marshal(body.ParamData)
|
||||
if err != nil {
|
||||
c.JSON(400, resp.CodeMsg(400, err.Error()))
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
body.ParamJson = string(paramDataByte)
|
||||
@@ -100,7 +100,7 @@ func (s NeConfigController) Edit(c *gin.Context) {
|
||||
var body model.NeConfig
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ func (s NeConfigController) Edit(c *gin.Context) {
|
||||
// 将json数据转字符串存储
|
||||
paramDataByte, err := json.Marshal(body.ParamData)
|
||||
if err != nil {
|
||||
c.JSON(400, resp.CodeMsg(400, err.Error()))
|
||||
c.JSON(200, resp.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
body.ParamJson = string(paramDataByte)
|
||||
@@ -135,7 +135,7 @@ func (s NeConfigController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Query("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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
// @Router /ne/config/list/{neType} [get]
|
||||
func (s NeConfigController) ListByNeType(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
neType := c.Param("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
|
||||
}
|
||||
data := s.neConfigService.FindByNeType(neType)
|
||||
@@ -204,7 +203,7 @@ func (s NeConfigController) DataInfo(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -259,7 +258,7 @@ func (s NeConfigController) DataEdit(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -312,20 +311,20 @@ func (s NeConfigController) DataAdd(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否array
|
||||
info := s.neConfigService.FindByNeTypeAndParamName(body.NeType, body.ParamName)
|
||||
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
|
||||
}
|
||||
// 必须含有index
|
||||
_, idxOk := body.ParamData["index"]
|
||||
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
|
||||
}
|
||||
|
||||
@@ -369,14 +368,15 @@ func (s NeConfigController) DataRemove(c *gin.Context) {
|
||||
Loc string `form:"loc" binding:"required"` // 与数据对象内index一致,有多层时划分嵌套层(index/subParamName/index)
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
// 检查是否array
|
||||
info := s.neConfigService.FindByNeTypeAndParamName(query.NeType, query.ParamName)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ func (s NeConfigBackupController) Download(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := parse.Number(c.Query("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (s NeConfigBackupController) Edit(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func (s NeConfigBackupController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Query("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
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ func (s NeConfigBackupController) Import(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
if !strings.HasSuffix(body.Path, ".zip") {
|
||||
@@ -181,7 +181,7 @@ func (s NeConfigBackupController) Export(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
// 查网元
|
||||
|
||||
@@ -75,11 +75,11 @@ func (s NeHostController) Add(c *gin.Context) {
|
||||
var body model.NeHost
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -116,11 +116,11 @@ func (s NeHostController) Edit(c *gin.Context) {
|
||||
var body model.NeHost
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ func (s NeHostController) Test(c *gin.Context) {
|
||||
var body model.NeHost
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ func (s NeHostController) Cmd(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ func (s NeHostController) CheckBySSH(c *gin.Context) {
|
||||
var body model.NeHost
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -460,11 +460,11 @@ func (s NeHostController) AuthorizedBySSH(c *gin.Context) {
|
||||
var body model.NeHost
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func (s NeHostCmdController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := parse.Number(c.Param("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func (s NeHostCmdController) Add(c *gin.Context) {
|
||||
var body model.NeHostCmd
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func (s NeHostCmdController) Edit(c *gin.Context) {
|
||||
var body model.NeHostCmd
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ func (s NeHostCmdController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ func (s NeInfoController) State(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func (s NeInfoController) NeTypeAndID(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ func (s NeInfoController) ListAll(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ func (s NeInfoController) Para5GFileWrite(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ func (s NeInfoController) OAMFileRead(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ func (s NeInfoController) OAMFileWrite(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ func (s NeInfoController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := parse.Number(c.Param("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -345,11 +345,11 @@ func (s NeInfoController) Add(c *gin.Context) {
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -438,11 +438,11 @@ func (s NeInfoController) Edit(c *gin.Context) {
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ func (s NeInfoController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s *NeLicenseController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := parse.Number(c.Param("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func (s *NeLicenseController) NeTypeAndID(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -137,7 +137,8 @@ func (s *NeLicenseController) Code(c *gin.Context) {
|
||||
NeId string `form:"neId" binding:"required"`
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -183,7 +184,8 @@ func (s *NeLicenseController) Change(c *gin.Context) {
|
||||
var body model.NeLicense
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ func (s NeSoftwareController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := parse.Number(c.Param("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -86,11 +86,11 @@ func (s NeSoftwareController) Add(c *gin.Context) {
|
||||
var body model.NeSoftware
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
// 找到已存在的删除后重新添加
|
||||
@@ -130,11 +130,11 @@ func (s NeSoftwareController) Edit(c *gin.Context) {
|
||||
var body model.NeSoftware
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ func (s NeSoftwareController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ func (s NeSoftwareController) NewNeVersion(c *gin.Context) {
|
||||
var body model.NeSoftware
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func (s *NeVersionController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := parse.Number(c.Param("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func (s *NeVersionController) Operate(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ func (s Oauth2Controller) Authorize(c *gin.Context) {
|
||||
// 是否存在clientId
|
||||
info := s.oauth2ClientService.FindByClientId(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
|
||||
}
|
||||
|
||||
// 判断IP白名单
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ func (s *SysConfigController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
configId := parse.Number(c.Param("configId"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ func (s *SysConfigController) Add(c *gin.Context) {
|
||||
var body model.SysConfig
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -132,11 +132,11 @@ func (s *SysConfigController) Edit(c *gin.Context) {
|
||||
var body model.SysConfig
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ func (s SysConfigController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
configId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ func (s SysConfigController) Refresh(c *gin.Context) {
|
||||
func (s SysConfigController) ConfigKey(c *gin.Context) {
|
||||
configKey := c.Param("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
|
||||
}
|
||||
key := s.sysConfigService.FindValueByKey(configKey)
|
||||
@@ -255,7 +255,7 @@ func (s SysConfigController) Export(c *gin.Context) {
|
||||
rows, total := s.sysConfigService.FindByPage(query)
|
||||
if total == 0 {
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ func (s *SysConfigController) ConfigValue(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ func (s *SysDeptController) List(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func (s SysDeptController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
deptId := parse.Number(c.Param("deptId"))
|
||||
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
|
||||
}
|
||||
data := s.sysDeptService.FindById(deptId)
|
||||
@@ -111,11 +111,11 @@ func (s SysDeptController) Add(c *gin.Context) {
|
||||
var body model.SysDept
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -169,11 +169,11 @@ func (s SysDeptController) Edit(c *gin.Context) {
|
||||
var body model.SysDept
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ func (s SysDeptController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
deptId := parse.Number(c.Param("deptId"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ func (s SysDeptController) Remove(c *gin.Context) {
|
||||
func (s *SysDeptController) ExcludeChild(c *gin.Context) {
|
||||
deptIdStr := c.Param("deptId")
|
||||
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
|
||||
}
|
||||
deptId := parse.Number(deptIdStr)
|
||||
@@ -333,7 +333,7 @@ func (s *SysDeptController) Tree(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
sysDept := model.SysDept{
|
||||
@@ -367,7 +367,7 @@ func (s *SysDeptController) TreeRole(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
roleId := parse.Number(c.Param("roleId"))
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ func (s SysDictDataController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
dataId := parse.Number(c.Param("dataId"))
|
||||
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
|
||||
}
|
||||
data := s.sysDictDataService.FindById(dataId)
|
||||
@@ -102,11 +102,11 @@ func (s SysDictDataController) Add(c *gin.Context) {
|
||||
var body model.SysDictData
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -153,11 +153,11 @@ func (s SysDictDataController) Edit(c *gin.Context) {
|
||||
var body model.SysDictData
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ func (s SysDictDataController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
dataId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ func (s SysDictDataController) DictType(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
dictType := c.Param("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
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ func (s SysDictDataController) Export(c *gin.Context) {
|
||||
rows, total := s.sysDictDataService.FindByPage(query)
|
||||
if total == 0 {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ func (s *SysDictTypeController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
dictId := parse.Number(c.Param("dictId"))
|
||||
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
|
||||
}
|
||||
data := s.sysDictTypeService.FindById(dictId)
|
||||
@@ -95,11 +95,11 @@ func (s *SysDictTypeController) Add(c *gin.Context) {
|
||||
var body model.SysDictType
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -138,11 +138,11 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
|
||||
var body model.SysDictType
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ func (s SysDictTypeController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
dictId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ func (s SysDictTypeController) Export(c *gin.Context) {
|
||||
rows, total := s.sysDictTypeService.FindByPage(query)
|
||||
if total == 0 {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ func (s SysLogLoginController) Unlock(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
userName := c.Param("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
|
||||
}
|
||||
ok := s.accountService.CleanLoginRecordCache(userName)
|
||||
@@ -103,7 +103,7 @@ func (s SysLogLoginController) Export(c *gin.Context) {
|
||||
rows, total := s.sysLogLoginService.FindByPage(query, dataScopeSQL)
|
||||
if total == 0 {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ func (s SysLogOperateController) Export(c *gin.Context) {
|
||||
rows, total := s.sysLogOperateService.FindByPage(query, dataScopeSQL)
|
||||
if total == 0 {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ func (s *SysMenuController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
menuId := parse.Number(c.Param("menuId"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -105,11 +105,11 @@ func (s *SysMenuController) Add(c *gin.Context) {
|
||||
var body model.SysMenu
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -158,11 +158,11 @@ func (s *SysMenuController) Edit(c *gin.Context) {
|
||||
var body model.SysMenu
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ func (s SysMenuController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
menuId := parse.Number(c.Param("menuId"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ func (s *SysMenuController) TreeRole(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
roleId := parse.Number(c.Param("roleId"))
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -95,11 +95,11 @@ func (s *SysPostController) Add(c *gin.Context) {
|
||||
var body model.SysPost
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -138,11 +138,11 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
||||
var body model.SysPost
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ func (s SysPostController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
postId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ func (s *SysPostController) Export(c *gin.Context) {
|
||||
rows, total := s.sysPostService.FindByPage(query)
|
||||
if total == 0 {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s *SysProfileController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ func (s *SysProfileController) PasswordForce(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ func (s *SysProfileController) PasswordForce(c *gin.Context) {
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ func (s *SysRoleController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
roleId := parse.Number(c.Param("roleId"))
|
||||
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
|
||||
}
|
||||
data := s.sysRoleService.FindById(roleId)
|
||||
@@ -96,11 +96,11 @@ func (s *SysRoleController) Add(c *gin.Context) {
|
||||
var body model.SysRole
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -139,11 +139,11 @@ func (s *SysRoleController) Edit(c *gin.Context) {
|
||||
var body model.SysRole
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ func (s *SysRoleController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
roleId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ func (s SysRoleController) Status(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ func (s *SysRoleController) DataScope(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ func (s SysRoleController) UserAuthList(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
roleId := parse.Number(c.Query("roleId"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -380,11 +380,11 @@ func (s SysRoleController) UserAuthChecked(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ func (s *SysRoleController) Export(c *gin.Context) {
|
||||
rows, total := s.sysRoleService.FindByPage(query)
|
||||
if total == 0 {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ func (s *SysUserController) Info(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
userId := parse.Number(c.Param("userId"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -164,7 +164,8 @@ func (s *SysUserController) Add(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body model.SysUser
|
||||
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
|
||||
}
|
||||
|
||||
@@ -174,13 +175,13 @@ func (s *SysUserController) Add(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&bodyPassword); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
body.Password = bodyPassword.Password
|
||||
|
||||
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
|
||||
}
|
||||
if !regular.ValidUsername(body.UserName) {
|
||||
@@ -278,11 +279,11 @@ func (s *SysUserController) Edit(c *gin.Context) {
|
||||
var body model.SysUser
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -378,7 +379,7 @@ func (s *SysUserController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
userId := c.Param("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
|
||||
}
|
||||
|
||||
@@ -426,7 +427,7 @@ func (s *SysUserController) Password(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -477,7 +478,7 @@ func (s *SysUserController) Status(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -525,7 +526,7 @@ func (s *SysUserController) Export(c *gin.Context) {
|
||||
rows, total := s.sysUserService.FindByPage(queryMap, dataScopeSQL)
|
||||
if total == 0 {
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -647,7 +648,7 @@ func (s *SysUserController) Import(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,8 @@ func (s *IPerfController) Version(c *gin.Context) {
|
||||
Version string `form:"version" binding:"required,oneof=V2 V3"` // 版本
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -88,7 +89,8 @@ func (s *IPerfController) Install(c *gin.Context) {
|
||||
Version string `form:"version" binding:"required,oneof=V2 V3"` // 版本
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -125,14 +127,15 @@ func (s *IPerfController) Run(c *gin.Context) {
|
||||
Rows int `form:"rows"` // 终端显示行数
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ func (s *PingController) Statistics(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body model.Ping
|
||||
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
|
||||
}
|
||||
|
||||
@@ -78,7 +79,7 @@ func (s *PingController) StatisticsOn(c *gin.Context) {
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -122,7 +123,8 @@ func (s *PingController) Version(c *gin.Context) {
|
||||
NeID string `form:"neId" binding:"required"` // 网元ID
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -160,14 +162,15 @@ func (s *PingController) Run(c *gin.Context) {
|
||||
Rows int `form:"rows"` // 终端显示行数
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ func (s *PacketController) Start(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (s *PacketController) Stop(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func (s *PacketController) Filter(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ func (s *PacketController) KeepAlive(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func (s *PacketController) FilePull(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
fileName := fmt.Sprintf("%s.pcap", querys.TaskNo)
|
||||
|
||||
@@ -43,10 +43,9 @@ func (s *TCPdumpController) DumpStart(c *gin.Context) {
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
Cmd string `json:"cmd" binding:"required"` // 命令 "-n -s 0 -v"
|
||||
}
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil {
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -78,10 +77,9 @@ func (s *TCPdumpController) DumpStop(c *gin.Context) {
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
TaskCode string `json:"taskCode" binding:"required"` // 任务码,停止任务并查看日志信息
|
||||
}
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil {
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -113,10 +111,9 @@ func (s *TCPdumpController) UPFTrace(c *gin.Context) {
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
Cmd string `json:"cmd" binding:"required"` // 命令
|
||||
}
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil {
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ func (s *TraceDataController) List(c *gin.Context) {
|
||||
func (s *TraceDataController) Info(c *gin.Context) {
|
||||
id := parse.Number(c.Param("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s *TraceDataController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ func (s *TraceTaskController) List(c *gin.Context) {
|
||||
func (s *TraceTaskController) Info(c *gin.Context) {
|
||||
id := parse.Number(c.Param("id"))
|
||||
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
|
||||
}
|
||||
|
||||
@@ -61,19 +61,18 @@ func (s *TraceTaskController) Info(c *gin.Context) {
|
||||
func (s *TraceTaskController) Add(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body model.TraceTask
|
||||
err := c.ShouldBindBodyWithJSON(&body)
|
||||
if err != nil {
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
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())))
|
||||
return
|
||||
}
|
||||
@@ -87,7 +86,7 @@ func (s *TraceTaskController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -112,12 +111,12 @@ func (s *TraceTaskController) Remove(c *gin.Context) {
|
||||
//
|
||||
// GET /filePull
|
||||
func (s *TraceTaskController) FilePull(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var querys struct {
|
||||
TraceId string `form:"traceId" binding:"required"`
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,10 @@ type TraceTaskHlrController struct {
|
||||
//
|
||||
// GET /list
|
||||
func (s *TraceTaskHlrController) List(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query model.TraceTaskHlrQuery
|
||||
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
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (s *TraceTaskHlrController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
id := c.Param("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
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ func (s *TraceTaskHlrController) Remove(c *gin.Context) {
|
||||
//
|
||||
// POST /start
|
||||
func (s *TraceTaskHlrController) Start(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
IMSI string `json:"imsi"` // IMSI
|
||||
MSISDN string `json:"msisdn"` // MSISDN
|
||||
@@ -88,12 +87,13 @@ func (s *TraceTaskHlrController) Start(c *gin.Context) {
|
||||
Remark string `json:"remark"` // 备注说明
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ func (s *TraceTaskHlrController) Start(c *gin.Context) {
|
||||
//
|
||||
// POST /stop
|
||||
func (s *TraceTaskHlrController) Stop(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
ID string `json:"id" binding:"required"` // 任务ID
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
@@ -162,13 +162,13 @@ func (s *TraceTaskHlrController) File(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
task := s.traceTaskHlrService.FindById(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
|
||||
}
|
||||
|
||||
@@ -194,14 +194,14 @@ func (s *TraceTaskHlrController) FilePull(c *gin.Context) {
|
||||
}
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
c.JSON(422, resp.CodeMsg(40422, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(422001, errMsgs))
|
||||
return
|
||||
}
|
||||
|
||||
// 查询网元获取IP
|
||||
neInfo := s.neInfoService.FindByNeTypeAndNeID(querys.NeType, querys.NeID)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s *WSController) WS(c *gin.Context) {
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (s *WSController) Test(c *gin.Context) {
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"be.ems/src/framework/database/redis"
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/logger"
|
||||
@@ -20,14 +22,15 @@ func (s *WSController) Redis(c *gin.Context) {
|
||||
HostId int64 `form:"hostId" binding:"required"` // 连接主机ID
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ func (s *WSController) SSH(c *gin.Context) {
|
||||
Rows int `form:"rows"` // 终端显示行数
|
||||
}
|
||||
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
|
||||
}
|
||||
if query.Cols < 80 || query.Cols > 400 {
|
||||
@@ -39,7 +40,7 @@ func (s *WSController) SSH(c *gin.Context) {
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ func (s *WSController) Telnet(c *gin.Context) {
|
||||
Rows int `form:"rows"` // 终端显示行数
|
||||
}
|
||||
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
|
||||
}
|
||||
if query.Cols < 120 || query.Cols > 400 {
|
||||
@@ -39,7 +40,7 @@ func (s *WSController) Telnet(c *gin.Context) {
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ func (s *WSController) ShellView(c *gin.Context) {
|
||||
Rows int `form:"rows"` // 终端显示行数
|
||||
}
|
||||
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
|
||||
}
|
||||
if query.Cols < 120 || query.Cols > 400 {
|
||||
@@ -52,7 +53,7 @@ func (s *WSController) ShellView(c *gin.Context) {
|
||||
// 登录用户信息
|
||||
loginUser, err := reqctx.LoginUser(c)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user