From 41fbe2d5a0475924ee6af09cd78fc4715ca8f007 Mon Sep 17 00:00:00 2001 From: coPpark Date: Thu, 8 Feb 2024 18:19:33 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=B5=9C=EC=8B=A0=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=2010=EA=B0=9C=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20(#82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 최신 리스트 10개 조회 API 구현 (#73) * refactor: 코드 컨벤션 및 리펙토링 적용 (#73) --- .../dto/response/ListRecentResponse.java | 101 ++++++++++++++++++ .../list/application/service/ListService.java | 27 +++++ .../controller/ListController.java | 9 ++ .../list/custom/CustomListRepository.java | 5 + .../custom/impl/CustomListRepositoryImpl.java | 43 ++++++-- 5 files changed, 177 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/listywave/list/application/dto/response/ListRecentResponse.java diff --git a/src/main/java/com/listywave/list/application/dto/response/ListRecentResponse.java b/src/main/java/com/listywave/list/application/dto/response/ListRecentResponse.java new file mode 100644 index 00000000..a412dafd --- /dev/null +++ b/src/main/java/com/listywave/list/application/dto/response/ListRecentResponse.java @@ -0,0 +1,101 @@ +package com.listywave.list.application.dto.response; + +import com.listywave.list.application.domain.Item; +import com.listywave.list.application.domain.Label; +import com.listywave.list.application.domain.Lists; +import java.util.Comparator; +import java.util.List; +import lombok.Builder; + +@Builder +public record ListRecentResponse( + List lists +) { + public static ListRecentResponse of(List lists) { + return ListRecentResponse.builder() + .lists(ListResponse.toList(lists)) + .build(); + } +} + +@Builder +record ListResponse( + Long id, + String category, + String backgroundColor, + Long ownerId, + String ownerNickname, + String ownerProfileImage, + List labels, + String title, + String description, + List items +) { + + public static List toList(List lists) { + return lists.stream() + .map(ListResponse::of) + .toList(); + } + + public static ListResponse of(Lists lists) { + return ListResponse.builder() + .id(lists.getId()) + .category(lists.getCategory().getKorNameValue()) + .backgroundColor(lists.getBackgroundColor()) + .ownerId(lists.getUser().getId()) + .ownerNickname(lists.getUser().getNickname()) + .ownerProfileImage(lists.getUser().getProfileImageUrl()) + .labels(LabelsResponse.toList(lists.getLabels())) + .title(lists.getTitle()) + .description(lists.getDescription()) + .items(ItemsResponse.toList(lists.getItems())) + .build(); + } +} + +@Builder +record LabelsResponse( + Long id, + String name +) { + + public static List toList(List