-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 소분글 상세조회 로직 추가 및 개선 #61
Conversation
- 미사용 엔티티 삭제(소분글 참여자 리스트) - response에 유저 닉네임 추가 - 서비스 함수 개행절약
List<ItemImageUrlEntity> itemImageUrlEntity = itemImageUrlJpaRepository.findByPostEntity(postEntity); | ||
if (itemImageUrlEntity.isEmpty()) throw new BaseException(BaseResponseStatus.NO_EXIST_ITEM_IMAGE_URL_ENTITY); | ||
|
||
// outdto 필드들 구성 | ||
UserPostDataOutDto userPostDataOutDto = modelMapper.map(userPostEntity, UserPostDataOutDto.class); | ||
if (userJpaRepository.findByUserUuid(userPostDataOutDto.getWriterUuid()).isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이전번처럼 유저객체를 리턴하는 하나의 쿼리만 사용해서 이거로 uuid와 nickname을 동시에 처리하는 구조로 바꿨습니다
@@ -103,37 +105,30 @@ public GetPostOutDto getPost(GetPostInDto inDto) { | |||
// 연관 엔티티들 조회 | |||
UserPostEntity userPostEntity = userPostJpaRepository.findById(inDto.getUserPostId()) | |||
.orElseThrow(() -> new BaseException(BaseResponseStatus.NO_EXIST_USER_POST_ENTITY)); | |||
|
|||
List<ParticipatingUsersEntity> participatingUsersEntity = participatingUsersJpaRepository.findByUserPostEntity(userPostEntity); | |||
if (participatingUsersEntity.isEmpty()) throw new BaseException(BaseResponseStatus.NO_EXIST_PARTICIPATING_USERS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용하지 않은 엔티티라 삭제했습니다.
추가로 해당 코드에서 예외발생이 아니라 그냥 빈 리스트 리턴으로 했었어야 생각합니다.
왜냐면 [빈 리스트 리턴 == 유일한 참여자인 게시자가 탈퇴한 경우] 인 경우라 그냥 리턴이 맞는것 같았습니다.
그런데 이제보니 해당 엔티티가 서비스에서 사용되지 않아서 그냥 지웠습니다
// 소분글 작성자가 탈퇴유저라면 작성자 UUID null로 설정 | ||
Optional<UserEntity> postWriterEntity = userJpaRepository.findByUserUuid(userPostEntity.getWriterUuid()); | ||
if (postWriterEntity.isEmpty()) userPostDataOutDto = userPostDataOutDto.toBuilder().writerUuid(null).build(); | ||
|
||
// 리턴할 OutDto 매핑 | ||
return GetPostOutDto.builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인자 안에 변수대신 코드를 넣어 개행을 좀 줄여봤습니다
변경점 👍
#58