11package com .somemore .community .repository .board ;
22
33import com .querydsl .core .types .Projections ;
4+ import com .querydsl .core .types .dsl .BooleanExpression ;
5+ import com .querydsl .core .types .dsl .BooleanExpression ;
46import com .querydsl .jpa .impl .JPAQuery ;
57import com .querydsl .jpa .impl .JPAQueryFactory ;
68import 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