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