Skip to content

Commit f6d722d

Browse files
committed
refactor(community): QueryDSL 조회 수정
1 parent 7faad2e commit f6d722d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/com/somemore/community/repository/board/CommunityBoardRepositoryImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public Page<CommunityBoardView> findByWriterId(UUID writerId, Pageable pageable)
7070
JPAQuery<Long> countQuery = queryFactory
7171
.select(communityBoard.count())
7272
.from(communityBoard)
73-
.where(isNotDeleted());
73+
.where(QCommunityBoard.communityBoard.writerId.eq(writerId)
74+
.and(isNotDeleted()));
7475

7576
return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchOne);
7677
}

src/main/java/com/somemore/community/repository/comment/CommunityCommentRepositoryImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ public Page<CommunityCommentView> findCommentsByBoardId(Long boardId, Pageable p
4949
.join(volunteer).on(communityComment.writerId.eq(volunteer.id))
5050
.where(communityComment.communityBoardId.eq(boardId))
5151
.orderBy(communityComment.parentCommentId.asc().nullsFirst(), communityComment.createdAt.asc())
52-
.offset(pageable.getOffset())
53-
.limit(pageable.getPageSize())
5452
.fetch();
5553

5654
JPAQuery<Long> countQuery = queryFactory
5755
.select(communityComment.count())
58-
.from(communityComment);
56+
.from(communityComment)
57+
.where(communityComment.communityBoardId.eq(boardId));
5958

6059
return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchOne);
6160
}

0 commit comments

Comments
 (0)