Skip to content

Commit

Permalink
hotfix: 댓글이 없을 때 조회 시 에러 발생 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
kdkdhoho committed Feb 7, 2024
1 parent 98a4861 commit 257b6e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.listywave.list.application.dto.response;

import static java.util.Collections.emptyList;

import com.listywave.list.application.domain.Comment;
import com.listywave.list.application.domain.Reply;
import java.time.LocalDateTime;
Expand All @@ -15,6 +17,15 @@ public record CommentFindResponse(
List<CommentResponse> comments
) {

public static CommentFindResponse emptyResponse() {
return CommentFindResponse.builder()
.totalCount(0L)
.cursorId(0L)
.hasNext(false)
.comments(emptyList())
.build();
}

public static CommentFindResponse from(
Long totalCount,
Long cursorId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public CommentFindResponse getComments(Long listId, int size, Long cursorId) {

List<Comment> comments = commentRepository.getComments(listId, size, cursorId);

if (comments.isEmpty()) {
return CommentFindResponse.emptyResponse();
}

boolean hasNext = false;
if (comments.size() > size) {
hasNext = true;
Expand Down

0 comments on commit 257b6e4

Please sign in to comment.