Skip to content

Commit 36d901f

Browse files
committed
reafactor(community): 코드 리뷰 사항 반영
- 삭제 메서드 추출
1 parent 7893c03 commit 36d901f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.somemore.community.repository.board;
22

33
import com.querydsl.core.types.Projections;
4+
import com.querydsl.core.types.dsl.BooleanExpression;
5+
import com.querydsl.core.types.dsl.BooleanExpression;
46
import com.querydsl.jpa.impl.JPAQuery;
57
import com.querydsl.jpa.impl.JPAQueryFactory;
68
import com.somemore.community.domain.CommunityBoard;
@@ -37,7 +39,7 @@ public Optional<CommunityBoard> findById(Long id) {
3739
return Optional.ofNullable(queryFactory
3840
.selectFrom(communityBoard)
3941
.where(communityBoard.id.eq(id)
40-
.and(communityBoard.deleted.eq(false)))
42+
.and(isNotDeleted()))
4143
.fetchOne());
4244
}
4345

@@ -49,7 +51,8 @@ public Page<CommunityBoardView> findCommunityBoards(Pageable pageable) {
4951

5052
JPAQuery<Long> countQuery = queryFactory
5153
.select(communityBoard.count())
52-
.from(communityBoard);
54+
.from(communityBoard)
55+
.where(isNotDeleted());
5356

5457
return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchOne);
5558
}
@@ -63,7 +66,8 @@ public Page<CommunityBoardView> findByWriterId(UUID writerId, Pageable pageable)
6366

6467
JPAQuery<Long> countQuery = queryFactory
6568
.select(communityBoard.count())
66-
.from(communityBoard);
69+
.from(communityBoard)
70+
.where(isNotDeleted());
6771

6872
return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchOne);
6973
}
@@ -88,4 +92,8 @@ private JPAQuery<CommunityBoardView> getCommunityBoardsQuery() {
8892
public void deleteAllInBatch() {
8993
communityBoardJpaRepository.deleteAllInBatch();
9094
}
95+
96+
private BooleanExpression isNotDeleted() {
97+
return communityBoard.deleted.eq(false);
98+
}
9199
}

0 commit comments

Comments
 (0)