diff --git a/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java b/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java index 2efa0e7..4ef793c 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java @@ -37,6 +37,9 @@ public class UserController { if (userService.isUserIdExist(requestJoinDto.getUserId())) return new ResponseEntity<>("아이디가 중복 됐습니다.", HttpStatus.CONFLICT); + if(userService.isEmailExist(requestJoinDto.getEmail())) + return new ResponseEntity<>("이메일이 중복 됐습니다.", HttpStatus.CONFLICT); + userService.join(requestJoinDto); return ResponseEntity.ok("User registered successfully"); diff --git a/backend/src/main/java/com/edufocus/edufocus/user/model/repository/UserRepository.java b/backend/src/main/java/com/edufocus/edufocus/user/model/repository/UserRepository.java index 10e9f87..cd8e74c 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/model/repository/UserRepository.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/model/repository/UserRepository.java @@ -31,4 +31,5 @@ public interface UserRepository extends JpaRepository { Optional findByUserId(String userId); + Optional findByEmail(String email); } diff --git a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserService.java b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserService.java index 7b2d101..29578c0 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserService.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserService.java @@ -25,4 +25,6 @@ public interface UserService { void changePassword(PasswordDto passwordDto,Long id); boolean isUserIdExist(String userId); + + boolean isEmailExist(String email); } diff --git a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java index 77fd4ca..547b37f 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java @@ -113,6 +113,11 @@ public class UserServiceImpl implements UserService { return userRepository.findByUserId(userId).isPresent(); } + @Override + public boolean isEmailExist(String email) { + return userRepository.findByEmail(email).isPresent(); + } + public String getTempPassword() { char[] charSet = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};