feat: 회원정보 변경시 이메일 중복 검사

This commit is contained in:
박정민 2024-08-09 14:19:10 +09:00
parent 12c34005cd
commit 423332bacb
3 changed files with 11 additions and 5 deletions

View File

@ -65,7 +65,7 @@ public class UserController {
userService.changePassword(passwordDto, userId);
return ResponseEntity.ok("Password changed successfully");
} catch (Exception e) {
return ResponseEntity.badRequest().body(e.getMessage());
return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body(e.getMessage());
}
}

View File

@ -74,6 +74,12 @@ public class UserServiceImpl implements UserService {
User user = userRepository.findById(id).orElseThrow(IllegalArgumentException::new);
if (isEmailExist(infoDto.getEmail())) {
throw new IllegalArgumentException("이미 사용 중인 이메일입니다.");
}
if (infoDto.getName() != null)
user.setName(infoDto.getName());