refactor: findByEmail 중복코드 제거

This commit is contained in:
dongHyo
2022-06-18 22:29:00 +09:00
parent 9fa7446487
commit ffa6b3f623

View File

@@ -39,13 +39,7 @@ public class UserServiceImpl implements UserService {
@Override
@Transactional
public User delete(@Valid DeleteUserDTO deleteUserDto) {
User user = userRepository.findByEmail(deleteUserDto.getEmail())
.orElseThrow(() -> {
log.error("존재하지 않는 이메일 입니다. :: {}", deleteUserDto.getEmail());
throw new EmailNotFoundException();
}
);
User user = findByEmail(deleteUserDto.getEmail());
return user.delete(deleteUserDto);
}
@@ -59,7 +53,11 @@ public class UserServiceImpl implements UserService {
@Override
public User findByEmail(String email) {
return userRepository.findByEmail(email)
.orElseThrow(EmailNotFoundException::new);
.orElseThrow(() -> {
log.error("존재하지 않는 이메일 입니다. :: {}", email);
throw new EmailNotFoundException();
}
);
}
private User findNotDeletedUserByEmail(String email) {