feat: optimized api response code

This commit is contained in:
Marvin Zhang
2024-11-13 17:31:05 +08:00
parent 86669be84b
commit c6ca5cb2a9
3 changed files with 16 additions and 6 deletions

View File

@@ -175,7 +175,7 @@ func DeleteUserById(c *gin.Context) {
return
}
if user.RootAdmin {
HandleErrorBadRequest(c, errors.New("root admin cannot be deleted"))
HandleErrorForbidden(c, errors.New("root admin cannot be deleted"))
return
}
@@ -217,7 +217,7 @@ func DeleteUserList(c *gin.Context) {
"root_admin": true,
}, nil)
if err == nil {
HandleErrorBadRequest(c, errors.New("root admin cannot be deleted"))
HandleErrorForbidden(c, errors.New("root admin cannot be deleted"))
return
}
if !errors.Is(err, mongo2.ErrNoDocuments) {