优化页面、修复BUG
This commit is contained in:
@@ -31,14 +31,9 @@ func SuccessWithMsg(c *gin.Context, msg string, result interface{}) {
|
||||
})
|
||||
}
|
||||
|
||||
// Error 错误响应 (默认 Code 400)
|
||||
// Error 错误响应,HTTP 状态恒为 200,通过 code 区分业务状态
|
||||
func Error(c *gin.Context, code int, msg string) {
|
||||
httpStatus := http.StatusBadRequest
|
||||
if code == 500 {
|
||||
httpStatus = http.StatusInternalServerError
|
||||
}
|
||||
|
||||
c.JSON(httpStatus, Response{
|
||||
c.JSON(http.StatusOK, Response{
|
||||
Code: code,
|
||||
Message: msg,
|
||||
Result: nil,
|
||||
@@ -47,7 +42,7 @@ func Error(c *gin.Context, code int, msg string) {
|
||||
|
||||
// ServerError 服务器错误 (Code 500)
|
||||
func ServerError(c *gin.Context, err error) {
|
||||
c.JSON(http.StatusInternalServerError, Response{
|
||||
c.JSON(http.StatusOK, Response{
|
||||
Code: 500,
|
||||
Message: err.Error(),
|
||||
Result: nil,
|
||||
|
||||
Reference in New Issue
Block a user