Skip to content

Commit

Permalink
Refact/#178 pagination refact (#180)
Browse files Browse the repository at this point in the history
* [REFACT] Pagination 정렬 누락 수정 및 최신순 정렬

* [REFACT] 사용자의 프로젝트 매칭 요청 리스트 조회에서 Pagination 정렬 누락 수정 및 최신순 정렬
  • Loading branch information
JIN-076 committed Feb 28, 2024
1 parent 75cb83a commit 5f1605a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public CursorPaginationResult<UserProfileLikeInfoAPIRes> getLikeInfoBySender(
cursorIdCondition(pageable.getCursorId()),
senderIdEq(senderId)
)
// 최근순
.orderBy(profileCardLike.id.desc())
.limit(pageable.getPageSize() + 1)
.fetch();

Expand All @@ -83,6 +85,6 @@ private BooleanExpression receiveridEq(Long receiverId) {
}

private BooleanExpression cursorIdCondition(Long cursorId) {
return cursorId != null ? profileCardLike.id.gt(cursorId) : null;
return cursorId != null ? profileCardLike.id.lt(cursorId) : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public CursorPaginationResult<UserPublicApiResponse> findByConditionWithPaginati
regionEq(region),
deletedProfileCardEq()
)
// 최근순
.orderBy(profileCard.id.desc())
.limit(pageable.getPageSize() + 1)
.fetch();

Expand Down Expand Up @@ -69,7 +71,7 @@ private BooleanExpression userIdEq(Long userId) {
}

private BooleanExpression cursorIdCondition(Long cursorId) {
return cursorId != null ? profileCard.id.gt(cursorId) : null;
return cursorId != null ? profileCard.id.lt(cursorId) : null;
}

private BooleanExpression deletedProfileCardEq() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public CursorPaginationResult<ProjectDetailAPIRes> findByConditionWithPagination
projectStatusEq(projectStatus),
createdAtEq(today)
)
// 최근순
.orderBy(project.id.desc())
.limit(pageable.getPageSize() + 1)
.fetch();

Expand Down Expand Up @@ -90,7 +92,7 @@ public List<Region> getDensityRankProjectsByRegion(int limit) {
}

private BooleanExpression cursorIdCondition(Long cursorId) {
return cursorId != null ? project.id.gt(cursorId) : null;
return cursorId != null ? project.id.lt(cursorId) : null;
}

private BooleanExpression userIdEq(Long userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ public CursorPaginationResult<ProjectJoinRequestDetailAPIRes> getBySenderIdWithP
) {
List<ProjectJoinRequest> entities = jpaQueryFactory.selectFrom(projectJoinRequest)
.where(
cursorIdCondition(pageable.getCursorId()),
cursorIdConditionForDesc(pageable.getCursorId()),
senderIdEq(senderId),
projectIdEq(projectId),
requestStatusEq(requestStatus)
)
// 최근순
.orderBy(projectJoinRequest.id.desc())
.limit(pageable.getPageSize() + 1)
.fetch();

Expand Down Expand Up @@ -125,4 +127,8 @@ private BooleanExpression cursorIdCondition(Long cursorId) {
return cursorId != null ? projectJoinRequest.id.gt(cursorId) : null;
}

private BooleanExpression cursorIdConditionForDesc(Long cursorId) {
return cursorId != null ? projectJoinRequest.id.lt(cursorId) : null;
}

}

0 comments on commit 5f1605a

Please sign in to comment.