diff --git a/Api/src/main/java/tify/server/api/question/service/RetrieveIsAnsweredUseCase.java b/Api/src/main/java/tify/server/api/question/service/RetrieveIsAnsweredUseCase.java index 2bb73e06..582797bc 100644 --- a/Api/src/main/java/tify/server/api/question/service/RetrieveIsAnsweredUseCase.java +++ b/Api/src/main/java/tify/server/api/question/service/RetrieveIsAnsweredUseCase.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.transaction.annotation.Transactional; import tify.server.api.config.security.SecurityUtils; import tify.server.api.question.model.response.RetrieveCategoryIsAnsweredDTO; @@ -16,6 +17,7 @@ import tify.server.domain.domains.user.domain.DetailCategory; import tify.server.domain.domains.user.domain.SmallCategory; +@Slf4j @UseCase @RequiredArgsConstructor @Transactional(readOnly = true) @@ -47,6 +49,7 @@ public List retrieveIsAnsweredBySmallCategory() { .filter(category -> category.getSmallCategory().equals(smallCategory)) .toList() .size(); // smallCategory와 같은 smallCategory를 가지는 detailCategory의 개수 + categoryIsAnsweredDTOS.add( RetrieveCategoryIsAnsweredDTO.of( smallCategory, userAnswerCategorySize == size)); diff --git a/Api/src/main/java/tify/server/api/user/controller/UserController.java b/Api/src/main/java/tify/server/api/user/controller/UserController.java index 6761892e..3045e019 100644 --- a/Api/src/main/java/tify/server/api/user/controller/UserController.java +++ b/Api/src/main/java/tify/server/api/user/controller/UserController.java @@ -52,7 +52,6 @@ public class UserController { private final RetrieveUserListUseCase retrieveUserListUseCase; private final RetrieveMutualFriendsUseCase retrieveMutualFriendsUseCase; - // userId를 pathvariable로 받아서 그 해당 유저의 profile 정보를 리턴하기. @Operation(summary = "유저 정보 조회") @GetMapping("/{userId}") public UserProfileVo getUserProfileInfo(@PathVariable Long userId) { diff --git a/Api/src/main/java/tify/server/api/user/service/UserInfoUseCase.java b/Api/src/main/java/tify/server/api/user/service/UserInfoUseCase.java index 9c1d4226..558ff90d 100644 --- a/Api/src/main/java/tify/server/api/user/service/UserInfoUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/UserInfoUseCase.java @@ -8,7 +8,6 @@ import tify.server.domain.common.vo.UserInfoVo; import tify.server.domain.common.vo.UserProfileVo; import tify.server.domain.domains.user.adaptor.UserAdaptor; -import tify.server.domain.domains.user.domain.User; @UseCase @RequiredArgsConstructor @@ -18,8 +17,7 @@ public class UserInfoUseCase { private final UserAdaptor userAdaptor; public UserProfileVo execute(Long userId) { - User user = userAdaptor.query(userId); - return user.toUserProfileVo(); + return userAdaptor.query(userId).toUserProfileVo(); } public UserInfoVo executeByToken() { diff --git a/Domain/src/main/java/tify/server/domain/common/vo/UserInfoVo.java b/Domain/src/main/java/tify/server/domain/common/vo/UserInfoVo.java index 96f9e895..8683946c 100644 --- a/Domain/src/main/java/tify/server/domain/common/vo/UserInfoVo.java +++ b/Domain/src/main/java/tify/server/domain/common/vo/UserInfoVo.java @@ -2,10 +2,13 @@ import java.time.LocalDateTime; +import java.util.Optional; import lombok.Builder; import lombok.Getter; import tify.server.domain.domains.user.domain.Gender; +import tify.server.domain.domains.user.domain.Profile; import tify.server.domain.domains.user.domain.User; +import tify.server.domain.domains.user.domain.UserOnBoardingStatus; @Getter @Builder @@ -33,14 +36,27 @@ public class UserInfoVo { public static UserInfoVo from(User user) { return UserInfoVo.builder() .id(user.getId()) - .userName(user.getProfile().getUserName()) + .userName( + Optional.ofNullable(user.getProfile()) + .map(Profile::getUserName) + .orElse(null)) .userId(user.getUserId()) - .imageUrl(user.getProfile().getThumbNail()) - .birth(user.getProfile().getBirth()) - .job(user.getProfile().getJob()) + .imageUrl( + Optional.ofNullable(user.getProfile()) + .map(Profile::getThumbNail) + .orElse(null)) + .birth(Optional.ofNullable(user.getProfile()).map(Profile::getBirth).orElse(null)) + .job(Optional.ofNullable(user.getProfile()).map(Profile::getJob).orElse(null)) .createdAt(user.getCreatedAt().toLocalDateTime()) - .gender(Gender.toValue(user.getProfile().getGender())) - .onBoardingStatus(user.getOnBoardingStatus().getName()) + .gender( + Gender.toValue( + Optional.ofNullable(user.getProfile()) + .map(Profile::getGender) + .orElse(null))) + .onBoardingStatus( + Optional.ofNullable(user.getOnBoardingStatus()) + .map(UserOnBoardingStatus::getName) + .orElse(null)) .build(); } } diff --git a/Domain/src/main/java/tify/server/domain/common/vo/UserProfileVo.java b/Domain/src/main/java/tify/server/domain/common/vo/UserProfileVo.java index dc9e986d..63e89144 100644 --- a/Domain/src/main/java/tify/server/domain/common/vo/UserProfileVo.java +++ b/Domain/src/main/java/tify/server/domain/common/vo/UserProfileVo.java @@ -1,10 +1,13 @@ package tify.server.domain.common.vo; +import java.util.Optional; import lombok.Builder; import lombok.Getter; import tify.server.domain.domains.user.domain.Gender; +import tify.server.domain.domains.user.domain.Profile; import tify.server.domain.domains.user.domain.User; +import tify.server.domain.domains.user.domain.UserOnBoardingStatus; @Getter @Builder @@ -28,14 +31,27 @@ public class UserProfileVo { public static UserProfileVo from(User user) { return UserProfileVo.builder() - .userName(user.getProfile().getUserName()) + .userName( + Optional.ofNullable(user.getProfile()) + .map(Profile::getUserName) + .orElse(null)) .userId(user.getUserId()) - .email(user.getProfile().getEmail()) - .thumbnail(user.getProfile().getThumbNail()) - .birth(user.getProfile().getBirth()) - .job(user.getProfile().getJob()) - .gender(Gender.toValue(user.getProfile().getGender())) - .onBoardingStatus(user.getOnBoardingStatus().getName()) + .email(Optional.ofNullable(user.getProfile()).map(Profile::getEmail).orElse(null)) + .thumbnail( + Optional.ofNullable(user.getProfile()) + .map(Profile::getThumbNail) + .orElse(null)) + .birth(Optional.ofNullable(user.getProfile()).map(Profile::getBirth).orElse(null)) + .job(Optional.ofNullable(user.getProfile()).map(Profile::getJob).orElse(null)) + .gender( + Gender.toValue( + Optional.ofNullable(user.getProfile()) + .map(Profile::getGender) + .orElse(null))) + .onBoardingStatus( + Optional.ofNullable(user.getOnBoardingStatus()) + .map(UserOnBoardingStatus::getName) + .orElse(null)) .build(); } }