From c386ad36df91f5fc06b216ba67c10174fa3b6921 Mon Sep 17 00:00:00 2001 From: UU_jeong <80961726+oU-Ua@users.noreply.github.com> Date: Sun, 17 Dec 2023 00:28:04 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore=20:=20email=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EC=A0=95=EA=B7=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mvc/promiseme/users/repository/UserRepository.java | 2 +- .../mvc/promiseme/users/service/UserServiceImpl.java | 6 +++--- src/test/java/mvc/promiseme/project/projectTest.java | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/mvc/promiseme/users/repository/UserRepository.java b/src/main/java/mvc/promiseme/users/repository/UserRepository.java index 54a8861..59a4b60 100644 --- a/src/main/java/mvc/promiseme/users/repository/UserRepository.java +++ b/src/main/java/mvc/promiseme/users/repository/UserRepository.java @@ -4,6 +4,6 @@ import org.springframework.data.jpa.repository.JpaRepository; public interface UserRepository extends JpaRepository { - Users findByEmail(String email); + Users findByEmailIgnoreCase(String email); Users findUsersByUserId(Long userId); } diff --git a/src/main/java/mvc/promiseme/users/service/UserServiceImpl.java b/src/main/java/mvc/promiseme/users/service/UserServiceImpl.java index 97cab5d..02ef613 100644 --- a/src/main/java/mvc/promiseme/users/service/UserServiceImpl.java +++ b/src/main/java/mvc/promiseme/users/service/UserServiceImpl.java @@ -16,7 +16,7 @@ public class UserServiceImpl implements UserService{ private final UserRepository userRepository; @Override public String register(UserDTO userDTO) { - if(userRepository.findByEmail(userDTO.getEmail()) != null) { + if(userRepository.findByEmailIgnoreCase(userDTO.getEmail()) != null) { throw new UserException(ErrorCode.DUPLICATE_USER); } Users users = Users.builder(). @@ -30,7 +30,7 @@ public String register(UserDTO userDTO) { @Override public LoginResponseDTO login(LoginRequestDTO loginRequestDTO) { - Users loginUser = userRepository.findByEmail(loginRequestDTO.getEmail()); + Users loginUser = userRepository.findByEmailIgnoreCase(loginRequestDTO.getEmail()); if(loginUser == null) throw new UserException(ErrorCode.INVALID_User_Login); @@ -47,7 +47,7 @@ public String logout(String token) { @Override public Long check(String email) { - Users checkUser = userRepository.findByEmail(email); + Users checkUser = userRepository.findByEmailIgnoreCase(email); if(checkUser == null) throw new UserException(ErrorCode.INVALID_User_Login); diff --git a/src/test/java/mvc/promiseme/project/projectTest.java b/src/test/java/mvc/promiseme/project/projectTest.java index 20e46d9..3f9f23d 100644 --- a/src/test/java/mvc/promiseme/project/projectTest.java +++ b/src/test/java/mvc/promiseme/project/projectTest.java @@ -6,6 +6,7 @@ import mvc.promiseme.project.dto.RecommendScheduleRequestDTO; import mvc.promiseme.project.service.ProjectService; import mvc.promiseme.project.service.RecommendService; +import mvc.promiseme.users.service.UserService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; @@ -26,6 +27,8 @@ public class projectTest { private ProjectService projectService; @Autowired private RecommendService recommendService; + @Autowired + private UserService userService; @Test public void testGetDday() { @@ -73,4 +76,11 @@ public void testInsert(){ public void testRecommendSchedule(){ recommendService.recommendSchedule(new RecommendScheduleRequestDTO(8L,"웹개발","기획자,백엔드개발자,프론트개발자,디자이너",LocalDate.parse("2023-10-13"),LocalDate.parse("2023-12-14"))); } + + @Test + public void testCheckUSer(){ + Long id = userService.check("a@gmail.com"); + System.out.println(id); + } + } From 126fd779d32bae98b6a846de331548eea78de3b2 Mon Sep 17 00:00:00 2001 From: UU_jeong <80961726+oU-Ua@users.noreply.github.com> Date: Sun, 17 Dec 2023 00:51:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore=20:=20email=20check=20parameter=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/mvc/promiseme/users/controller/UserController.java | 6 ++++-- .../java/mvc/promiseme/users/service/UserServiceImpl.java | 1 + src/test/java/mvc/promiseme/project/projectTest.java | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/mvc/promiseme/users/controller/UserController.java b/src/main/java/mvc/promiseme/users/controller/UserController.java index 7c2cca3..c8a61a7 100644 --- a/src/main/java/mvc/promiseme/users/controller/UserController.java +++ b/src/main/java/mvc/promiseme/users/controller/UserController.java @@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Map; + @Slf4j @RestController @RequiredArgsConstructor @@ -39,8 +41,8 @@ public class UserController { } @PostMapping("/users/check") - public ResponseEntitycheck(@RequestBody String email){ - return ResponseEntity.ok(userService.check(email)); + public ResponseEntitycheck(@RequestBody Map requestBody){ + return ResponseEntity.ok(userService.check(requestBody.get("email"))); } diff --git a/src/main/java/mvc/promiseme/users/service/UserServiceImpl.java b/src/main/java/mvc/promiseme/users/service/UserServiceImpl.java index 02ef613..e5b7c0c 100644 --- a/src/main/java/mvc/promiseme/users/service/UserServiceImpl.java +++ b/src/main/java/mvc/promiseme/users/service/UserServiceImpl.java @@ -47,6 +47,7 @@ public String logout(String token) { @Override public Long check(String email) { + System.out.println("email : " + email); Users checkUser = userRepository.findByEmailIgnoreCase(email); if(checkUser == null) throw new UserException(ErrorCode.INVALID_User_Login); diff --git a/src/test/java/mvc/promiseme/project/projectTest.java b/src/test/java/mvc/promiseme/project/projectTest.java index 3f9f23d..84fe2fb 100644 --- a/src/test/java/mvc/promiseme/project/projectTest.java +++ b/src/test/java/mvc/promiseme/project/projectTest.java @@ -79,8 +79,8 @@ public void testRecommendSchedule(){ @Test public void testCheckUSer(){ - Long id = userService.check("a@gmail.com"); - System.out.println(id); + Long id = userService.check("bbb@gmail.com"); + System.out.println("id" +id); } }