feat: user 회원정보 수정 시 이름만 변경 기능 수정

This commit is contained in:
kgc91747 2024-08-13 12:25:45 +09:00
parent 1d307c006d
commit 66ef65e4d5

View File

@ -13,6 +13,7 @@ import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.NoSuchElementException;
import java.util.Optional; import java.util.Optional;
@Service @Service
@ -72,10 +73,10 @@ public class UserServiceImpl implements UserService {
@Override @Override
public void changeUserInfo(InfoDto infoDto, Long id) { public void changeUserInfo(InfoDto infoDto, Long id) {
User user = userRepository.findById(id).orElse(null); User user = userRepository.findById(id).orElseThrow(NoSuchElementException::new);
if (isEmailExist(infoDto.getEmail())) { if (isEmailExist(infoDto.getEmail()) && !infoDto.getEmail().equals(user.getEmail())) {
throw new RuntimeException("이미 사용 중인 이메일입니다."); throw new RuntimeException("이미 사용 중인 이메일입니다.");
} }