diff --git a/src/main/java/com/listywave/user/application/service/UserService.java b/src/main/java/com/listywave/user/application/service/UserService.java index ed5b214f..537b030a 100644 --- a/src/main/java/com/listywave/user/application/service/UserService.java +++ b/src/main/java/com/listywave/user/application/service/UserService.java @@ -1,9 +1,6 @@ package com.listywave.user.application.service; -import static com.listywave.common.exception.ErrorCode.NOT_FOUND; - import com.listywave.auth.application.domain.JwtManager; -import com.listywave.common.exception.CustomException; import com.listywave.common.util.UserUtil; import com.listywave.list.application.domain.CategoryType; import com.listywave.list.application.domain.Lists; @@ -16,7 +13,6 @@ import com.listywave.user.repository.follow.FollowRepository; import com.listywave.user.repository.user.UserRepository; import java.util.List; -import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -32,18 +28,17 @@ public class UserService { @Transactional(readOnly = true) public UserInfoResponse getUserInfo(Long userId, String accessToken) { - Optional found = userRepository.findById(userId); - User foundUser = found.orElseThrow(() -> new CustomException(NOT_FOUND)); + User user = userRepository.getById(userId); if (isSignedIn(accessToken)) { - return UserInfoResponse.of(foundUser, false, false); + return UserInfoResponse.of(user, false, false); } Long loginUserId = jwtManager.read(accessToken); - if (foundUser.isSame(loginUserId)) { - return UserInfoResponse.of(foundUser, false, true); + if (user.isSame(loginUserId)) { + return UserInfoResponse.of(user, false, true); } - return UserInfoResponse.of(foundUser, false, false); + return UserInfoResponse.of(user, false, false); } private boolean isSignedIn(String accessToken) {