fix:: 请求响应码用常量

This commit is contained in:
TsMask
2025-06-07 16:32:04 +08:00
parent c67fbb7998
commit 33b95a6e30
73 changed files with 441 additions and 375 deletions

View File

@@ -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(422, resp.CodeMsg(422002, "bind err: configId is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "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(422001, errMsgs))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
return
}
if body.ConfigId > 0 {
c.JSON(422, resp.CodeMsg(422002, "bind err: configId not is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "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(422001, errMsgs))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
return
}
if body.ConfigId <= 0 {
c.JSON(422, resp.CodeMsg(422002, "bind err: configId is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "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(422, resp.CodeMsg(422002, "bind err: configId is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "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(422, resp.CodeMsg(422002, "bind err: configKey is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: configKey is empty"))
return
}
key := s.sysConfigService.FindValueByKey(configKey)
@@ -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(422001, errMsgs))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
return
}