@@ -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