From 7426084a2be10c241e2098a7f8ea9b51f12eb83f Mon Sep 17 00:00:00 2001 From: kdkdhoho Date: Sun, 4 Feb 2024 14:34:15 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Collectors.toMap=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=20=EC=8B=9C=20=EC=88=9C=EC=84=9C=20=EB=B3=B4=EC=9E=A5=EC=9D=84?= =?UTF-8?q?=20=EC=9C=84=ED=95=9C=20LinkedHashMap=20=EC=A0=81=EC=9A=A9=20(#?= =?UTF-8?q?43)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listywave/list/application/service/CommentService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 856382bf..e436508a 100644 --- a/src/main/java/com/listywave/list/application/service/CommentService.java +++ b/src/main/java/com/listywave/list/application/service/CommentService.java @@ -15,6 +15,7 @@ import com.listywave.user.application.domain.User; import com.listywave.user.repository.UserRepository; import jakarta.transaction.Transactional; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; @@ -50,9 +51,11 @@ public CommentFindResponse getComments(Long listId, int size, Long cursorId) { Map> result = comments.stream() .collect(toMap( identity(), - replyRepository::getAllByComment + replyRepository::getAllByComment, + (exists, newValue) -> exists, + LinkedHashMap::new )); - + Long cursorIdOfResult = comments.get(comments.size() - 1).getId(); boolean hasNext = comments.size() >= size;