From eefe3a9c6eba2c979cb2fdd57e819364018e843a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Fri, 28 Jan 2022 19:56:30 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/exception/GlobalExceptionHandler.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java index bc58049db..19673c544 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java @@ -8,7 +8,6 @@ import cn.hutool.http.HttpStatus; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.exception.DemoModeException; import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.common.utils.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.validation.BindException; @@ -32,33 +31,33 @@ import java.util.stream.Collectors; public class GlobalExceptionHandler { /** - * 权限校验异常 + * 权限码异常 */ @ExceptionHandler(NotPermissionException.class) - public AjaxResult handleAccessDeniedException(NotPermissionException e, HttpServletRequest request) { + public AjaxResult handleNotPermissionException(NotPermissionException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); - log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage()); - return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有权限,请联系管理员授权"); + log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage()); + return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权"); } /** - * 角色校验异常 + * 角色权限异常 */ @ExceptionHandler(NotRoleException.class) - public AjaxResult handleAccessDeniedException(NotRoleException e, HttpServletRequest request) { + public AjaxResult handleNotRoleException(NotRoleException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); - log.error("请求地址'{}',角色校验失败'{}'", requestURI, e.getMessage()); - return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有角色,请联系管理员授权"); + log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage()); + return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权"); } /** * 认证失败 */ @ExceptionHandler(NotLoginException.class) - public AjaxResult handleAccessDeniedException(NotLoginException e, HttpServletRequest request) { + public AjaxResult handleNotLoginException(NotLoginException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage()); - return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, StringUtils.format("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI)); + return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源"); } /**