Skip to content

Commit

Permalink
feat: 받은 리뷰가 없을 때의 응답 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
nayonsoso committed Jul 25, 2024
1 parent a8f2528 commit 022910c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backend/src/main/java/reviewme/review/service/ReviewService.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ public ReviewDetailResponse findReview(long reviewId, long memberId) {

public ReceivedReviewsResponse findMyReceivedReview(long memberId, long lastReviewId, int size) {
PageRequest pageRequest = PageRequest.of(0, size);
Page<Review> reviews = reviewRepository.findAllByRevieweeBeforeLastViewedId(memberId, lastReviewId, pageRequest);
Page<Review> reviews = reviewRepository.findAllByRevieweeBeforeLastViewedId(memberId, lastReviewId,
pageRequest);
int totalSize = reviews.getContent().size();

if (totalSize == 0) {
return new ReceivedReviewsResponse(0, 0, List.of());
}

return new ReceivedReviewsResponse(
reviews.getContent().size(),
reviews.getContent().get(reviews.getContent().size() - 1).getId(),
reviews.getContent().get(totalSize - 1).getId(),
reviews.getContent().stream()
.map(review -> new ReceivedReviewResponse(
review.getId(),
Expand Down

0 comments on commit 022910c

Please sign in to comment.