Merge branch 'be/user' into 'backend'

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

See merge request s11-webmobile1-sub2/S11P12A701!183
This commit is contained in:
김기창 2024-08-13 12:27:25 +09:00
commit dee178a635

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("이미 사용 중인 이메일입니다.");
} }