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

[Feature] TalkRoom 좋아요, 검색 쿼리 기능 구현 #44

Merged
merged 6 commits into from
Mar 27, 2024

Conversation

AHNYUNKI
Copy link
Member

💡 연관된 이슈

close #40

📝 작업 내용

  • TalkRoom 좋아요 구현
  • TalkRoom 좋아요 테스트 작성
  • TalkRoom 검색 쿼리 구현
  • TalkRoom 검색 쿼리 테스트 코드 작성

💬 리뷰 요구 사항

최신순, 좋아요 정렬 기능 추가 및 where절 검색 조건 기능 구현 했습니다.

그리고 RepositoryImpl에 각 메서드 기능별 설명 주석으로 달아놨습니다!

    private List<TalkRoomFindAllResponse> findTalkRoomBySearch(TalkRoomSearchServiceRequest search) {
        return queryFactory.select(new QTalkRoomFindAllResponse(
                        talkRoom.id.as("talkRoomId"),
                        user.name.as("userName"),
                        talkRoom.title,
                        talkRoom.content,
                        book.title,
                        book.imageUrl.as("bookImage"),
                        talkRoomLike.count().as("likeCount")
                ))
                .from(talkRoom)
                .join(talkRoom.user, user)
                .join(talkRoom.book, book)
                .leftJoin(talkRoomLike).on(talkRoom.eq(talkRoomLike.talkRoom))
                .groupBy(talkRoom.id)
                .where(searchQuery(search.getSearch()))
                .offset(search.getOffset())
                .limit(search.getSize())
                .orderBy(condition(search.getOrderType()))
                .fetch();
    }
    private OrderSpecifier<?> condition(OrderType orderType) {
        if (RECENT.equals(orderType)) {
            return talkRoom.id.desc();
        } else if (RECOMMEND.equals(orderType)) {
            return talkRoomLike.count().desc();
        }
        return OrderByNull.DEFAULT;
    }
    private BooleanExpression searchQuery(String search) {
        return search != null ? talkRoom.title.contains(search) : null;
    }

@AHNYUNKI AHNYUNKI added the ✨ Feature 기능 개발 label Mar 27, 2024
@AHNYUNKI AHNYUNKI requested review from pdohyung and jwooo March 27, 2024 11:39
@AHNYUNKI AHNYUNKI self-assigned this Mar 27, 2024
@AHNYUNKI AHNYUNKI linked an issue Mar 27, 2024 that may be closed by this pull request
4 tasks
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.

고생하셨습니다. 필드가 하나 누락 된 것 같아 리뷰 남겼습니다. 확인 부탁드립니다!

Comment on lines 31 to 37
public TalkRoomSearchServiceRequest toService() {
return TalkRoomSearchServiceRequest.builder()
.page(page)
.size(size)
.order(order)
.orderType(OrderType.conversionOrderType(order))
.build();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

search를 넘기시는 것을 깜빡 하신 것 같아요!

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

@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.

넵 확인했습니다.

고생하셨습니다 👍

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 13 to 19
public static OrderType conversionOrderType(String order) {
return switch (order) {
case "recent" -> RECENT;
case "recommend" -> RECOMMEND;
default -> RECENT;
};
}
Copy link
Member

Choose a reason for hiding this comment

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

변환 메서드명 convertToOrderType은 어떠신가요 ?

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
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.

수고하셨습니다. 👍

@AHNYUNKI AHNYUNKI merged commit d428c29 into develop Mar 27, 2024
1 check passed
@AHNYUNKI AHNYUNKI deleted the feature/40-talkroom-like-and-searh-api branch March 27, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature 기능 개발
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] TalkRoom 좋아요, 검색 쿼리 기능 구현
3 participants