Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public Page<CommunityBoardView> findCommunityBoards(Pageable pageable) {
JPAQuery<Long> countQuery = queryFactory
.select(communityBoard.count())
.from(communityBoard)
.join(volunteer).on(communityBoard.writerId.eq(volunteer.id))
.where(isNotDeleted());

return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchOne);
Expand All @@ -70,6 +71,7 @@ public Page<CommunityBoardView> findByWriterId(UUID writerId, Pageable pageable)
JPAQuery<Long> countQuery = queryFactory
.select(communityBoard.count())
.from(communityBoard)
.join(volunteer).on(communityBoard.writerId.eq(volunteer.id))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted false 조건도 달아주면 좋을것 같아요!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

밑에 있었군요 죄송합니다!

.where(isWriter(writerId)
.and(isNotDeleted()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public Page<CommunityCommentView> findCommentsByBoardId(Long boardId, Pageable p
JPAQuery<Long> countQuery = queryFactory
.select(communityComment.count())
.from(communityComment)
.join(volunteer).on(communityComment.writerId.eq(volunteer.id))
.where(communityComment.communityBoardId.eq(boardId));

return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchOne);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ void getAllCommunityBoards() {

//given
//when
Page<CommunityBoardResponseDto> dtos = communityBoardQueryService.getCommunityBoards(0);
Page<CommunityBoardResponseDto> dtos = communityBoardQueryService.getCommunityBoards(2);

//then
assertThat(dtos).isNotNull();
assertThat(dtos.getContent()).isNotNull();
assertThat(dtos.getTotalElements()).isEqualTo(33);
assertThat(dtos.getSize()).isEqualTo(10);
assertThat(dtos.getTotalPages()).isEqualTo(4);
assertThat(dtos.getNumber()).isZero();
}

@DisplayName("저장된 커뮤니티 게시글 리스트를 작성자자별로 페이지 조회한다.")
Expand All @@ -106,14 +106,13 @@ void getCommunityBoardsByWriter() {

//given
//when
Page<CommunityBoardResponseDto> dtos = communityBoardQueryService.getCommunityBoardsByWriterId(writerId1, 0);
Page<CommunityBoardResponseDto> dtos = communityBoardQueryService.getCommunityBoardsByWriterId(writerId1, 1);

//then
assertThat(dtos).isNotNull();
assertThat(dtos.getTotalElements()).isEqualTo(12);
assertThat(dtos.getSize()).isEqualTo(10);
assertThat(dtos.getTotalPages()).isEqualTo(2);
assertThat(dtos.getNumber()).isZero();
}

@DisplayName("커뮤니티 게시글의 상세 정보를 조회한다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void getCommentsByCommunityBoardId() {

//given
//when
Page<CommunityCommentResponseDto> comments = communityCommentQueryService.getCommunityCommentsByBoardId(boardId, 0);
Page<CommunityCommentResponseDto> comments = communityCommentQueryService.getCommunityCommentsByBoardId(boardId, 1);

//then
assertThat(comments).isNotNull();
Expand Down
Loading