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() + "";