fix:: 请求响应码用常量
This commit is contained in:
@@ -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(422001, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.PostId > 0 {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: postId not is empty"))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "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(422001, errMsgs))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
|
||||
return
|
||||
}
|
||||
if body.PostId <= 0 {
|
||||
c.JSON(422, resp.CodeMsg(422002, "bind err: postId is empty"))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "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(422, resp.CodeMsg(422002, "bind err: postId is empty"))
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: postId is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user