From e2de22bdce173a951083a81d0065c69d8e5e9832 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期二, 28 九月 2021 18:26:08 +0800
Subject: [PATCH] update 优化 代码生成常量 关于 BO VO 注释
---
ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 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 9cf69ff..a96450c 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
@@ -1,5 +1,8 @@
package com.ruoyi.framework.web.exception;
+import cn.dev33.satoken.exception.NotLoginException;
+import cn.dev33.satoken.exception.NotPermissionException;
+import cn.dev33.satoken.exception.NotRoleException;
import cn.hutool.http.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.DemoModeException;
@@ -7,7 +10,6 @@
import com.ruoyi.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.security.access.AccessDeniedException;
import org.springframework.validation.BindException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
@@ -30,8 +32,8 @@
/**
* 鏉冮檺鏍¢獙寮傚父
*/
- @ExceptionHandler(AccessDeniedException.class)
- public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request)
+ @ExceptionHandler(NotPermissionException.class)
+ public AjaxResult handleAccessDeniedException(NotPermissionException e, HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("璇锋眰鍦板潃'{}',鏉冮檺鏍¢獙澶辫触'{}'", requestURI, e.getMessage());
@@ -39,6 +41,28 @@
}
/**
+ * 瑙掕壊鏍¢獙寮傚父
+ */
+ @ExceptionHandler(NotRoleException.class)
+ public AjaxResult handleAccessDeniedException(NotRoleException e, HttpServletRequest request)
+ {
+ String requestURI = request.getRequestURI();
+ log.error("璇锋眰鍦板潃'{}',瑙掕壊鏍¢獙澶辫触'{}'", requestURI, e.getMessage());
+ return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "娌℃湁瑙掕壊锛岃鑱旂郴绠$悊鍛樻巿鏉�");
+ }
+
+ /**
+ * 璁よ瘉澶辫触
+ */
+ @ExceptionHandler(NotLoginException.class)
+ public AjaxResult handleAccessDeniedException(NotLoginException e, HttpServletRequest request)
+ {
+ String requestURI = request.getRequestURI();
+ log.error("璇锋眰璁块棶锛歿}锛岃璇佸け璐ワ紝鏃犳硶璁块棶绯荤粺璧勬簮", requestURI, e.getMessage());
+ return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, StringUtils.format("璇锋眰璁块棶锛歿}锛岃璇佸け璐ワ紝鏃犳硶璁块棶绯荤粺璧勬簮", requestURI));
+ }
+
+ /**
* 璇锋眰鏂瑰紡涓嶆敮鎸�
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
--
Gitblit v1.9.3