From 1410d16bb5b289e751e4501f67f06de1173bbd3a Mon Sep 17 00:00:00 2001 From: Ziin Date: Fri, 20 Jun 2025 20:15:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=A3=80=E6=9F=A5=E8=B4=A6=E5=8F=B7=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=9A=84ErrorCode=E6=9E=9A=E4=B8=BE=E5=80=BC=202.=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8B=A6=E6=88=AA=E5=99=A8=E9=80=9A=E9=85=8D=E7=AC=A6?= =?UTF-8?q?=203.=E4=BF=AE=E6=94=B9=20sql=20=E6=97=A5=E5=BF=97=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootinit/config/SaTokenConfigure.java | 5 ++++- .../controller/UserController.java | 5 ++--- src/main/resources/application.yml | 16 +--------------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/yupi/springbootinit/config/SaTokenConfigure.java b/src/main/java/com/yupi/springbootinit/config/SaTokenConfigure.java index 07edf5b..9869280 100644 --- a/src/main/java/com/yupi/springbootinit/config/SaTokenConfigure.java +++ b/src/main/java/com/yupi/springbootinit/config/SaTokenConfigure.java @@ -10,11 +10,14 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class SaTokenConfigure implements WebMvcConfigurer { + + + @Override public void addInterceptors(InterceptorRegistry registry) { // 注册Sa-Token的拦截器 registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin())) - .addPathPatterns("/**") + .addPathPatterns("/api/**") .excludePathPatterns(getExcludePaths()); } diff --git a/src/main/java/com/yupi/springbootinit/controller/UserController.java b/src/main/java/com/yupi/springbootinit/controller/UserController.java index 5b4b29d..402d705 100644 --- a/src/main/java/com/yupi/springbootinit/controller/UserController.java +++ b/src/main/java/com/yupi/springbootinit/controller/UserController.java @@ -38,7 +38,6 @@ public class UserController { if (user == null) { throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR); } - if (!usersService.isPasswordMatch(usersDTO.getPassword(), user.getPassword())) { throw new BusinessException(ErrorCode.USERNAME_OR_PASSWORD_ERROR); } @@ -49,8 +48,8 @@ public class UserController { if (usersService.isExpired(usersDTO.getTenantId())){ throw new BusinessException(ErrorCode.PACKAGE_EXPIRED); } - if (usersService.checkCrawlRole(user.getId())){ - throw new BusinessException(ErrorCode.NOT_FOUND_ERROR); + if (!usersService.checkCrawlRole(user.getId())){ + throw new BusinessException(ErrorCode.LOGIN_NOW_ALLOWED); } Long second = usersService.getTenantExpiredTime(usersDTO.getTenantId()); SystemUsersVO systemUsersVO = new SystemUsersVO(); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 3111455..ffbb4ce 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -42,7 +42,7 @@ server: mybatis-plus: configuration: map-underscore-to-camel-case: false - log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl + log-impl: org.apache.ibatis.logging.log4j2.Log4j2Impl log-sql: default-executor-type: batch global-config: @@ -108,19 +108,5 @@ sa-token: # 是否输出操作日志 is-log: true - -# security配置,如果使用了Spring security或者satoken需要添加排除路径 - security: - # 排除路径 - excludes: - - /*.html - - /**/*.html - - /**/*.css - - /**/*.js - - /favicon.ico - - /error/** - #swagger文档和knife4j的路径 - - /v3/api-docs/** - - /doc.html/** md5: salt: (-FhqvXO,wMz \ No newline at end of file