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

@@ -50,7 +50,7 @@ type UDMVolteIMSController struct {
func (s *UDMVolteIMSController) ResetData(c *gin.Context) {
neId := c.Param("neId")
if neId == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty"))
return
}
@@ -101,11 +101,11 @@ func (s *UDMVolteIMSController) Info(c *gin.Context) {
imsi := c.Param("imsi")
msisdn := c.Query("msisdn")
if neId == "" || imsi == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: neId or imsi is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId or imsi is empty"))
return
}
if msisdn == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: msisdn is required"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: msisdn is required"))
return
}
@@ -164,18 +164,18 @@ func (s *UDMVolteIMSController) Add(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
neId := c.Param("neId")
if neId == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty"))
return
}
var body model.UDMVolteIMSUser
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.IMSI == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: imsi is empty"))
return
}
@@ -242,11 +242,11 @@ func (s *UDMVolteIMSController) Adds(c *gin.Context) {
var body model.UDMVolteIMSUser
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.IMSI == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: imsi is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: imsi is empty"))
return
}
@@ -382,7 +382,7 @@ func (s *UDMVolteIMSController) Removes(c *gin.Context) {
imsi := c.Param("imsi")
num := c.Param("num")
if neId == "" || imsi == "" || num == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: neId/imsi/num is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId/imsi/num is empty"))
return
}
@@ -438,7 +438,7 @@ func (s *UDMVolteIMSController) Export(c *gin.Context) {
neId := c.Query("neId")
fileType := c.Query("type")
if neId == "" {
c.JSON(422, resp.CodeMsg(422002, "bind err: neId is empty"))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: neId is empty"))
return
}
if !(fileType == "csv" || fileType == "txt") {
@@ -514,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(422001, errMsgs))
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_PARSER, errMsgs))
return
}