From 66ef65e4d50cf8afab5263c6f3f5e767dcaef62e Mon Sep 17 00:00:00 2001 From: kgc91747 Date: Tue, 13 Aug 2024 12:25:45 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20user=20=ED=9A=8C=EC=9B=90=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EB=A7=8C=20=EB=B3=80=EA=B2=BD=20=EA=B8=B0=EB=8A=A5=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edufocus/user/model/service/UserServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java index 310a2e6..516fc16 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/model/service/UserServiceImpl.java @@ -13,6 +13,7 @@ import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.NoSuchElementException; import java.util.Optional; @Service @@ -72,10 +73,10 @@ public class UserServiceImpl implements UserService { @Override 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("이미 사용 중인 이메일입니다."); }