From 96e3949700d2c63d99aa7493ac7e04beaf92b151 Mon Sep 17 00:00:00 2001 From: yulmam <70622601+yulmam@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:48:35 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EC=B2=B4=ED=81=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edufocus/edufocus/user/controller/UserController.java | 3 +++ .../edufocus/user/model/repository/UserRepository.java | 1 + .../edufocus/edufocus/user/model/service/UserService.java | 2 ++ .../edufocus/user/model/service/UserServiceImpl.java | 5 +++++ 4 files changed, 11 insertions(+) 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 c077839..fec5f10 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'};