Skip to content

Commit

Permalink
refactor(Comment): 댓글 조회시 Parent가 Null인 것만을 조회하지 않도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
SongJaeHoonn committed Jul 22, 2024
1 parent 683cf42 commit 884dc12
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public Page<Comment> findAllByIsDeletedTrueAndBoardId(Long boardId, Pageable pag
}

@Override
public Page<Comment> findAllByBoardIdAndParentIsNull(Long boardId, Pageable pageable) {
return commentRepository.findAllByBoardIdAndParentIsNull(boardId, pageable)
public Page<Comment> findAllByBoardId(Long boardId, Pageable pageable) {
return commentRepository.findAllByBoardId(boardId, pageable)
.map(commentMapper::toDomain);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
@Repository
public interface CommentRepository extends JpaRepository<CommentJpaEntity, Long> {

@Query("SELECT c FROM CommentJpaEntity c WHERE c.boardId = ?1 AND c.parent.id IS NULL")
Page<CommentJpaEntity> findAllByBoardIdAndParentIsNull(Long boardId, Pageable pageable);
@Query("SELECT c FROM CommentJpaEntity c WHERE c.boardId = ?1")
Page<CommentJpaEntity> findAllByBoardId(Long boardId, Pageable pageable);

@Query("SELECT c FROM CommentJpaEntity c WHERE c.writerId = ?1 AND c.isDeleted = false")
Page<CommentJpaEntity> findAllByWriterId(String memberId, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface RetrieveCommentPort {

Page<Comment> findAllByIsDeletedTrueAndBoardId(Long boardId, Pageable pageable);

Page<Comment> findAllByBoardIdAndParentIsNull(Long boardId, Pageable pageable);
Page<Comment> findAllByBoardId(Long boardId, Pageable pageable);

Page<Comment> findAllByWriterId(String memberId, Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Comment findByIdOrThrow(Long commentId) {
@Transactional(readOnly = true)
public PagedResponseDto<CommentResponseDto> getAllComments(Long boardId, Pageable pageable) {
String currentMemberId = externalRetrieveMemberUseCase.getCurrentMemberId();
Page<Comment> comments = retrieveCommentPort.findAllByBoardIdAndParentIsNull(boardId, pageable);
Page<Comment> comments = retrieveCommentPort.findAllByBoardId(boardId, pageable);
List<CommentResponseDto> commentDtos = comments.stream()
.map(comment -> toCommentResponseDtoWithMemberInfo(comment, currentMemberId))
.toList();
Expand Down

0 comments on commit 884dc12

Please sign in to comment.