-
Notifications
You must be signed in to change notification settings - Fork 2
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
[BE] feat: 내가 받은 리뷰 목록에 페이지네이션 적용 #683
Changes from 1 commit
b85e6d2
b8b3666
8c238a2
2b3bb9a
34077d6
79b4bda
5c30f34
787e707
fc28d73
f0fa9c6
8443181
ecb444b
d2064d4
34702c7
a530a67
1ac7f16
88eea36
1dceecb
b865dce
89cdb58
b825f1b
2b6f268
622ea23
840f337
c793331
d40ded6
9364818
ea61130
cb1c797
d4d546c
3dcaeaf
1548304
5076911
b83f55f
708afd2
8bc24d2
cb64bb0
7588097
e86f4df
fc5f345
7954cc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import reviewme.review.repository.ReviewRepository; | ||
import reviewme.review.service.dto.response.list.ReceivedReviewsResponse; | ||
import reviewme.review.service.dto.response.list.ReceivedReviewsResponseWithPagination; | ||
import reviewme.review.service.dto.response.list.ReviewListElementResponse; | ||
|
@@ -19,6 +20,7 @@ public class ReviewListLookupService { | |
|
||
private final ReviewGroupRepository reviewGroupRepository; | ||
private final ReviewListMapper reviewListMapper; | ||
private final ReviewRepository reviewRepository; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사용하지 않는 것 같슴다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영했습니다🫡 |
||
|
||
@Transactional(readOnly = true) | ||
public ReceivedReviewsResponse getReceivedReviews(String reviewRequestCode, String groupAccessCode) { | ||
|
@@ -53,11 +55,24 @@ public ReceivedReviewsResponse getReceivedReviews2(String reviewRequestCode) { | |
} | ||
|
||
@Transactional(readOnly = true) | ||
public ReceivedReviewsResponseWithPagination getReceivedReviewsWithPagination(String reviewRequestCode) { | ||
public ReceivedReviewsResponseWithPagination getReceivedReviewsWithPagination(String reviewRequestCode, | ||
long lastReviewId, int limit) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 질문) 페이지의 게시물 수를 나타내는 인자를 컨트롤러에서는 size로 서비스부터는 limit로 표현하고 있는데 용어를 다르게 한 이유가 있을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋은 부분 잘 짚어주셨네요🙇🏻♀️ 쿼리 파라미터에서는 페이징의 개념과 잘어울리는 size 라는 이름을 사용했고, 일단 제 의도는 이러한데, 커비처럼 헷갈릴 수 있으니 아래처럼 바꿔볼게요!
|
||
ReviewGroup reviewGroup = reviewGroupRepository.findByReviewRequestCode(reviewRequestCode) | ||
.orElseThrow(() -> new ReviewGroupNotFoundByReviewRequestCodeException(reviewRequestCode)); | ||
|
||
List<ReviewListElementResponse> reviewGroupResponse = reviewListMapper.mapToReviewList(reviewGroup); | ||
return null; | ||
List<ReviewListElementResponse> elements | ||
= reviewListMapper.mapToReviewListWithPagination(reviewGroup, lastReviewId, limit); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. elements보다 더 의미가 담긴 변수명은 어떨까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영했습니다~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 깜짝 제안 : |
||
int totalSize = reviewRepository.countByReviewGroupId(reviewGroup.getId()); | ||
long newLastReviewId = calculateLastReviewId(elements); | ||
return new ReceivedReviewsResponseWithPagination( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이것도 반영했습니다! |
||
reviewGroup.getReviewee(), reviewGroup.getProjectName(), totalSize, newLastReviewId, elements | ||
); | ||
} | ||
|
||
private long calculateLastReviewId(List<ReviewListElementResponse> elements) { | ||
if(elements.isEmpty()) { | ||
return 0; | ||
} | ||
return elements.get(elements.size() - 1).reviewId(); | ||
} | ||
} |
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.
사용하지 않습니다!
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.
삭제했습니다!