|
@@ -1,8 +1,5 @@
|
|
-package org.dromara.common.security.handler;
|
|
|
|
|
|
+package org.dromara.common.web.handler;
|
|
|
|
|
|
-import cn.dev33.satoken.exception.NotLoginException;
|
|
|
|
-import cn.dev33.satoken.exception.NotPermissionException;
|
|
|
|
-import cn.dev33.satoken.exception.NotRoleException;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.http.HttpStatus;
|
|
import cn.hutool.http.HttpStatus;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
@@ -32,36 +29,6 @@ import org.springframework.web.servlet.NoHandlerFoundException;
|
|
@RestControllerAdvice
|
|
@RestControllerAdvice
|
|
public class GlobalExceptionHandler {
|
|
public class GlobalExceptionHandler {
|
|
|
|
|
|
- /**
|
|
|
|
- * 权限码异常
|
|
|
|
- */
|
|
|
|
- @ExceptionHandler(NotPermissionException.class)
|
|
|
|
- public R<Void> handleNotPermissionException(NotPermissionException e, HttpServletRequest request) {
|
|
|
|
- String requestURI = request.getRequestURI();
|
|
|
|
- log.error("请求地址'{}',权限码校验失败'{}'", requestURI, e.getMessage());
|
|
|
|
- return R.fail(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 角色权限异常
|
|
|
|
- */
|
|
|
|
- @ExceptionHandler(NotRoleException.class)
|
|
|
|
- public R<Void> handleNotRoleException(NotRoleException e, HttpServletRequest request) {
|
|
|
|
- String requestURI = request.getRequestURI();
|
|
|
|
- log.error("请求地址'{}',角色权限校验失败'{}'", requestURI, e.getMessage());
|
|
|
|
- return R.fail(HttpStatus.HTTP_FORBIDDEN, "没有访问权限,请联系管理员授权");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 认证失败
|
|
|
|
- */
|
|
|
|
- @ExceptionHandler(NotLoginException.class)
|
|
|
|
- public R<Void> handleNotLoginException(NotLoginException e, HttpServletRequest request) {
|
|
|
|
- String requestURI = request.getRequestURI();
|
|
|
|
- log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
|
|
|
- return R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 请求方式不支持
|
|
* 请求方式不支持
|
|
*/
|
|
*/
|