Skip to content

Commit 09dee08

Browse files
committed
refactor(community): isNotDeleted(), isWriter() 적용
1 parent f6d722d commit 09dee08

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public Optional<CommunityBoard> findById(Long id) {
4545
@Override
4646
public Page<CommunityBoardView> findCommunityBoards(Pageable pageable) {
4747
List<CommunityBoardView> content = getCommunityBoardsQuery()
48-
.where(QCommunityBoard.communityBoard.deleted.eq(false))
48+
.where(isNotDeleted())
4949
.offset(pageable.getOffset())
5050
.limit(pageable.getPageSize())
5151
.fetch();
@@ -61,16 +61,16 @@ public Page<CommunityBoardView> findCommunityBoards(Pageable pageable) {
6161
@Override
6262
public Page<CommunityBoardView> findByWriterId(UUID writerId, Pageable pageable) {
6363
List<CommunityBoardView> content = getCommunityBoardsQuery()
64-
.where(QCommunityBoard.communityBoard.writerId.eq(writerId)
65-
.and(QCommunityBoard.communityBoard.deleted.eq(false)))
64+
.where(isWriter(writerId)
65+
.and(isNotDeleted()))
6666
.offset(pageable.getOffset())
6767
.limit(pageable.getPageSize())
6868
.fetch();
6969

7070
JPAQuery<Long> countQuery = queryFactory
7171
.select(communityBoard.count())
7272
.from(communityBoard)
73-
.where(QCommunityBoard.communityBoard.writerId.eq(writerId)
73+
.where(isWriter(writerId)
7474
.and(isNotDeleted()));
7575

7676
return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchOne);
@@ -100,4 +100,6 @@ public void deleteAllInBatch() {
100100
private BooleanExpression isNotDeleted() {
101101
return communityBoard.deleted.eq(false);
102102
}
103+
104+
private BooleanExpression isWriter(UUID writerId) {return communityBoard.writerId.eq(writerId); }
103105
}

0 commit comments

Comments
 (0)