From 257b6e4e373eea32487f6de2bb43734722ec9437 Mon Sep 17 00:00:00 2001 From: kdkdhoho Date: Wed, 7 Feb 2024 17:58:52 +0900 Subject: [PATCH] =?UTF-8?q?=20hotfix:=20=EB=8C=93=EA=B8=80=EC=9D=B4=20?= =?UTF-8?q?=EC=97=86=EC=9D=84=20=EB=95=8C=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C?= =?UTF-8?q?=20=EC=97=90=EB=9F=AC=20=EB=B0=9C=EC=83=9D=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/response/CommentFindResponse.java | 11 +++++++++++ .../list/application/service/CommentService.java | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/com/listywave/list/application/dto/response/CommentFindResponse.java b/src/main/java/com/listywave/list/application/dto/response/CommentFindResponse.java index 2598a05d..2c3c6a17 100644 --- a/src/main/java/com/listywave/list/application/dto/response/CommentFindResponse.java +++ b/src/main/java/com/listywave/list/application/dto/response/CommentFindResponse.java @@ -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; @@ -15,6 +17,15 @@ public record CommentFindResponse( List 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, diff --git a/src/main/java/com/listywave/list/application/service/CommentService.java b/src/main/java/com/listywave/list/application/service/CommentService.java index eaaaea39..cf022182 100644 --- a/src/main/java/com/listywave/list/application/service/CommentService.java +++ b/src/main/java/com/listywave/list/application/service/CommentService.java @@ -49,6 +49,10 @@ public CommentFindResponse getComments(Long listId, int size, Long cursorId) { List comments = commentRepository.getComments(listId, size, cursorId); + if (comments.isEmpty()) { + return CommentFindResponse.emptyResponse(); + } + boolean hasNext = false; if (comments.size() > size) { hasNext = true;