package com.kt.event.content.biz.dto;

import com.kt.event.content.biz.domain.Content;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 콘텐츠 정보 DTO
 */
@Getter
@Builder
@AllArgsConstructor
public class ContentInfo {

    private Long id;
    private String eventId;
    private String eventTitle;
    private String eventDescription;
    private List<ImageInfo> images;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;

    /**
     * 도메인 모델로부터 생성
     *
     * @param content 콘텐츠 도메인 모델
     * @return ContentInfo
     */
    public static ContentInfo from(Content content) {
        return ContentInfo.builder()
                .id(content.getId())
                .eventId(content.getEventId())
                .eventTitle(content.getEventTitle())
                .eventDescription(content.getEventDescription())
                .images(content.getImages().stream()
                        .map(ImageInfo::from)
                        .collect(Collectors.toList()))
                .createdAt(content.getCreatedAt())
                .updatedAt(content.getUpdatedAt())
                .build();
    }
}
