Skip to content

Commit

Permalink
refactor(CommentRetrievalService): 자식 댓글이 부모 댓글에 중복되는 부분 필터링, PagedRe…
Browse files Browse the repository at this point in the history
…sponseDto 생성 방식 변경
  • Loading branch information
SongJaeHoonn committed Jul 23, 2024
1 parent 884dc12 commit b71fd23
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ public PagedResponseDto<CommentResponseDto> getAllComments(Long boardId, Pageabl
String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId();
Page<Comment> comments = retrieveCommentPort.findAllByBoardId(boardId, pageable);
List<CommentResponseDto> commentDtos = comments.stream()
.filter(comment -> comment.getParent() == null)
.map(comment -> toCommentResponseDtoWithMemberInfo(comment, currentMemberId))
.toList();
return new PagedResponseDto<>(new PageImpl<>(commentDtos, pageable, comments.getTotalElements()));
return new PagedResponseDto<>(commentDtos, pageable, comments.getTotalElements(), comments.getNumberOfElements());
}

private CommentResponseDto toCommentResponseDtoWithMemberInfo(Comment comment, String currentMemberId) {
Expand Down

0 comments on commit b71fd23

Please sign in to comment.