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] 사용자 별점 조회 API 구현 #54

Merged
merged 5 commits into from
Mar 31, 2024

Conversation

pdohyung
Copy link
Member

💡 연관된 이슈

close #43

📝 작업 내용

  • 사용자 별점 조회 API 추가
    • 페이징 구현
    • 정렬 기준 (등록시간, 별점 오름차/내림차, 평균 별점 오름차/내림차)
    • 별점 선택 (etc 2.0, 3.5, 5.0)

💬 리뷰 요구 사항

    @Override
    public PageResponse<RatingFindAllResponse> findAllRatingOrderBy(
            Long userId, RatingOrderType ratingSortType, Double rating, int size, int offset) {
        log.info("--------------start--------------");
        // 리뷰 조회, 쿼리 1회
        List<RatingFindAllResponse> ratings = getRatings(userId, ratingSortType, rating, size, offset);

        return PageResponse.<RatingFindAllResponse>builder()
                .queryResponse(ratings)
                .totalCount(getTotalCount(userId, rating)) // 해당 유저의 리뷰 총 개수, 쿼리 1회
                .size(size)
                .build();
    }

    // ... 중간 생략 ...

    private OrderSpecifier createSpecifier(RatingOrderType ratingSortType) {
        if (ratingSortType.equals(RATING_ASC)) {
            return review.rating.asc();
        }
        if (ratingSortType.equals(RATING_DESC)) {
            return review.rating.desc();
        }
        if (ratingSortType.equals(RATING_AVG_ASC)) {
            return review.rating.avg().asc();
        }
        if (ratingSortType.equals(RATING_AVG_DESC)) {
            return review.rating.avg().desc();
        }

        return review.createDateTime.desc();
    }

쉬운 쿼리는 아니기 때문에 쿼리 위주로 봐주시면 감사하겠습니다 !
코드에 보완이 필요하다면 편하게 말씀해주세요. 😊

또한 아래 OrderSpecifier 메서드는 정렬 기준을 동적 쿼리로 구현하려고 추가했습니다.
해당 분기문이 최선이라고 생각했는데 의견 있으시면 남겨주세요 ! 😃

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

@AHNYUNKI AHNYUNKI left a comment

Choose a reason for hiding this comment

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

확인했습니다! 고생하셨어요!!

@pdohyung pdohyung force-pushed the feature/43-my-review-read-api branch from 564fc4e to 4b0c724 Compare March 31, 2024 09:31
@pdohyung pdohyung merged commit ca3b062 into develop Mar 31, 2024
1 check passed
@pdohyung pdohyung deleted the feature/43-my-review-read-api branch March 31, 2024 09:33
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] 사용자 별점 조회 API 구현
3 participants