From ecf561d0155c75e4c6591feac4731c161da8a951 Mon Sep 17 00:00:00 2001 From: walker Date: Mon, 5 Jun 2023 13:19:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/ResponseExceptionHandler.java | 2 +- .../configuration/SpringSecurityConfiguration.java | 10 ---------- .../club/joylink/xiannccda/service/UserService.java | 5 +++++ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/club/joylink/xiannccda/configuration/ResponseExceptionHandler.java b/src/main/java/club/joylink/xiannccda/configuration/ResponseExceptionHandler.java index f447336..bf1d130 100644 --- a/src/main/java/club/joylink/xiannccda/configuration/ResponseExceptionHandler.java +++ b/src/main/java/club/joylink/xiannccda/configuration/ResponseExceptionHandler.java @@ -26,7 +26,7 @@ public class ResponseExceptionHandler { @ExceptionHandler(Exception.class) public ProblemDetail UncaughtExceptionHandler(Exception e) { ProblemDetail problemDetail = ProblemDetail.forStatus(HttpStatus.INTERNAL_SERVER_ERROR); - problemDetail.setTitle("未处理异常"); + problemDetail.setTitle("未知错误"); problemDetail.setDetail(e.getMessage()); return problemDetail; } diff --git a/src/main/java/club/joylink/xiannccda/configuration/SpringSecurityConfiguration.java b/src/main/java/club/joylink/xiannccda/configuration/SpringSecurityConfiguration.java index 53da929..decd903 100644 --- a/src/main/java/club/joylink/xiannccda/configuration/SpringSecurityConfiguration.java +++ b/src/main/java/club/joylink/xiannccda/configuration/SpringSecurityConfiguration.java @@ -105,16 +105,6 @@ public class SpringSecurityConfiguration { return jwtAuthenticationConverter; } - /** - * Spring Security用户username/password认证使用的password编码器 - * - * @return - */ - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(13); - } - /** * JWT解码器 * diff --git a/src/main/java/club/joylink/xiannccda/service/UserService.java b/src/main/java/club/joylink/xiannccda/service/UserService.java index 88c996b..56edc2c 100644 --- a/src/main/java/club/joylink/xiannccda/service/UserService.java +++ b/src/main/java/club/joylink/xiannccda/service/UserService.java @@ -26,6 +26,11 @@ public class UserService { } public String register(User user) { + BusinessExceptionAssertEnum.UNIQUE_FIELD_REPEAT.assertTrue( + this.userRepository.count( + Wrappers.lambdaQuery().eq(User::getMobile, user.getMobile())) <= 0, + "手机号已经被注册" + ); user.setRegisterTime(LocalDateTime.now()); this.userRepository.save(user); return user.getId() + "";