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

import com.kt.event.content.biz.domain.GeneratedImage;
import com.kt.event.content.biz.dto.ImageInfo;
import com.kt.event.content.biz.usecase.in.GetImageListUseCase;
import com.kt.event.content.biz.usecase.out.ContentReader;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

/**
 * 이미지 목록 조회 서비스
 */
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class GetImageListService implements GetImageListUseCase {

    private final ContentReader contentReader;

    @Override
    public List<ImageInfo> execute(Long eventDraftId) {
        List<GeneratedImage> images = contentReader.findImagesByEventDraftId(eventDraftId);
        return images.stream()
                .map(ImageInfo::from)
                .collect(Collectors.toList());
    }
}
