diff --git a/internal/pkg/response/response.go b/internal/pkg/response/response.go index 7be7275..1514fc3 100644 --- a/internal/pkg/response/response.go +++ b/internal/pkg/response/response.go @@ -155,8 +155,10 @@ func statusCodeFromAppErrorCode(code string) int { case "NOT_FOUND", "USER_NOT_FOUND", "POST_NOT_FOUND", "GROUP_NOT_FOUND", "GROUP_REQUEST_NOT_FOUND", "SCHEDULE_COURSE_NOT_FOUND": return http.StatusNotFound - case "UNAUTHORIZED", "INVALID_CREDENTIALS": + case "UNAUTHORIZED": return http.StatusUnauthorized + case "INVALID_CREDENTIALS": + return http.StatusBadRequest case "FORBIDDEN", "NOT_GROUP_MEMBER", "NOT_GROUP_ADMIN", "NOT_GROUP_OWNER", "USER_BANNED", "USER_BLOCKED", "MUTED", "MUTE_ALL_ENABLED", "SCHEDULE_FORBIDDEN", "UNAUTHORIZED_NOTIFICATION": @@ -183,8 +185,8 @@ func statusCodeFromAppErrorCode(code string) int { // ErrorWithStringCode 带字符串错误码的错误响应 func ErrorWithStringCode(c *gin.Context, statusCode int, code string, message string) { c.JSON(statusCode, ResponseSnakeCase{ - Code: 0, // 为了兼容,这里设为0,实际错误码在message中体现 + Code: statusCode, Message: message, - Data: code, + Data: nil, }) }