Skip to content
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

[Refactor] TalkRoom 조회 Query 리펙토링 #63

Merged
merged 3 commits into from
Apr 7, 2024

Conversation

AHNYUNKI
Copy link
Member

@AHNYUNKI AHNYUNKI commented Apr 5, 2024

💡 연관된 이슈

close #61

📝 작업 내용

*. TalkRoom 조회 API Comment 조회 API 변경

  • 조회 메서드 분리
  • TalkRoom 서비스 메서드 분리
  • Service - Repository 계층 분리

💬 리뷰 요구 사항

리뷰 요구 사항은 없습니다.

@AHNYUNKI AHNYUNKI added the 🔨 Refactor 코드 리팩토링 label Apr 5, 2024
@AHNYUNKI AHNYUNKI requested review from pdohyung and jwooo April 5, 2024 09:21
@AHNYUNKI AHNYUNKI self-assigned this Apr 5, 2024
@AHNYUNKI AHNYUNKI linked an issue Apr 5, 2024 that may be closed by this pull request
3 tasks
Copy link
Member

@pdohyung pdohyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다 !
질문 남겼으니 답변 부탁드립니다. 😊

Comment on lines +298 to +308
List<Comment> comments = IntStream.range(1, 6)
.mapToObj(i -> Comment.builder()
.talkRoom(talkRoom)
.user(user)
.content("의견 " + i)
.build())
.collect(Collectors.toList());

for (int i = 0; i < 5; i++) {
commentRepository.save(comments.get(i));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commentRepository.saveAll(comments) 이렇게 한 번에 저장하는 것도 좋아보입니다 !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음 저도 처음에 saveAll를 했으나 간혈적으로 저장순서가 바뀌는 문제로 테스트가 실패해서 그냥 포문으로 저장 시켰습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 알기로 saveAll은 리스트의 순서대로 저장합니다 !
테스트의 다른 부분에서 문제가 발생했던 건 아닐까요 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 그런걸로 알고있는데 repository 테스트에서 자꾸 테스트 실패가 떴습니다 ㅠㅠ

Comment on lines +124 to +132
if (request.getNewImage() != null && !request.getNewImage().isEmpty()) {
request.getNewImage().stream().map(url -> TalkRoomImage.createImages(talkRoom, url))
.forEach(talkRoomImageRepository::save);
}

if (request.getRemoveImage() != null && !request.getRemoveImage().isEmpty()) {
request.getRemoveImage().stream().map(s -> talkRoomImageRepository.findByTalkRoomAndImageUrl(talkRoom, s))
.forEach(talkRoomImageRepository::deleteAll);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 if문이 어떤 동작을 하는지 간단하게 설명 부탁드립니다 !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

유저가 토론방을 수정할 때, 새로운 이미지를 추가하고 기존에 있던 이미지를 삭제 할때 if문으로 새로운 이미지 혹은 삭제된 이미지 url이 있는지 체크를 하고 있다면 로직을 수행하도록 했습니다!

Copy link
Collaborator

@jwooo jwooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!! 리뷰 남겼으니 확인 부탁드립니다!

}

public SearchServiceRequest toService() {
return SearchServiceRequest.builder()
.page(page)
.size(size)
.search(search)
.orderType(OrderType.convertToOrderType(order))
.order(order != null ? order : "re")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 정렬 기준에서 "re"를 사용하시는 지 궁금해서 리뷰 남깁니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정렬 값이 null이 들어올 시 seach.getOrder() 로 가져오게 되면 예외가 발생하기 때문에 null이면 기본으로 최신순으로 정렬하게 하기 위해 짧게 "re" 값으로 넘겨줬습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"re" 값이 불명확한거 같아서 디폴드 값이 무조건 최신순이라면 default나 recent로 값을 넘겨주어도 되지 않을까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 수정하도록 하겠습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 알겠습니다!

Copy link
Member

@pdohyung pdohyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다 ~ 👍

Copy link
Collaborator

@jwooo jwooo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다 👊

@AHNYUNKI AHNYUNKI merged commit 5966a4d into develop Apr 7, 2024
1 check passed
@AHNYUNKI AHNYUNKI deleted the refactor/61-talkroom-find-query branch April 7, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 Refactor 코드 리팩토링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactor] TalkRoom 조회 Query 리펙토링
3 participants