From e5b93b978e9cf6dcc5dc8468c0e44b60831ec473 Mon Sep 17 00:00:00 2001 From: qiushile Date: Fri, 12 Sep 2025 23:46:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 SseException替换为 NotLoginException,以正确处理未登录异常 - 更新异常处理方法,确保认证失败时返回正确的错误信息 --- .../dromara/common/web/handler/GlobalExceptionHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java index 28aacbcfb..4ed841dfe 100644 --- a/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java +++ b/ruoyi-common/ruoyi-common-web/src/main/java/org/dromara/common/web/handler/GlobalExceptionHandler.java @@ -1,5 +1,6 @@ package org.dromara.common.web.handler; +import cn.dev33.satoken.exception.NotLoginException; import cn.hutool.core.util.ObjectUtil; import cn.hutool.http.HttpStatus; import com.fasterxml.jackson.core.JsonParseException; @@ -10,7 +11,6 @@ import jakarta.validation.ConstraintViolationException; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.domain.R; import org.dromara.common.core.exception.ServiceException; -import org.dromara.common.core.exception.SseException; import org.dromara.common.core.exception.base.BaseException; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.json.utils.JsonUtils; @@ -62,8 +62,8 @@ public class GlobalExceptionHandler { * 认证失败 */ @ResponseStatus(org.springframework.http.HttpStatus.UNAUTHORIZED) - @ExceptionHandler(SseException.class) - public String handleNotLoginException(SseException e, HttpServletRequest request) { + @ExceptionHandler(NotLoginException.class) + public String handleNotLoginException(NotLoginException e, HttpServletRequest request) { String requestURI = request.getRequestURI(); log.debug("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage()); return JsonUtils.toJsonString(R.fail(HttpStatus.HTTP_UNAUTHORIZED, "认证失败,无法访问系统资源"));