Skip to content

Commit

Permalink
Merge pull request #44 from potenday-project/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
oU-Ua authored Dec 16, 2023
2 parents 58152d1 + 0125113 commit 78fb860
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,8 +41,8 @@ public class UserController {
}

@PostMapping("/users/check")
public ResponseEntity<Long>check(@RequestBody String email){
return ResponseEntity.ok(userService.check(email));
public ResponseEntity<Long>check(@RequestBody Map<String, String> requestBody){
return ResponseEntity.ok(userService.check(requestBody.get("email")));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import org.springframework.data.jpa.repository.JpaRepository;

public interface UserRepository extends JpaRepository<Users, Long> {
Users findByEmail(String email);
Users findByEmailIgnoreCase(String email);
Users findUsersByUserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand All @@ -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);

Expand All @@ -47,7 +47,8 @@ public String logout(String token) {

@Override
public Long check(String email) {
Users checkUser = userRepository.findByEmail(email);
System.out.println("email : " + email);
Users checkUser = userRepository.findByEmailIgnoreCase(email);
if(checkUser == null)
throw new UserException(ErrorCode.INVALID_User_Login);

Expand Down
10 changes: 10 additions & 0 deletions src/test/java/mvc/promiseme/project/projectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,6 +27,8 @@ public class projectTest {
private ProjectService projectService;
@Autowired
private RecommendService recommendService;
@Autowired
private UserService userService;

@Test
public void testGetDday() {
Expand Down Expand Up @@ -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("[email protected]");
System.out.println("id" +id);
}

}

0 comments on commit 78fb860

Please sign in to comment.