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

import com.kt.event.content.biz.domain.Job;
import com.kt.event.content.biz.dto.ContentCommand;
import com.kt.event.content.biz.dto.JobInfo;
import com.kt.event.content.biz.usecase.in.RegenerateImageUseCase;
import com.kt.event.content.biz.usecase.out.JobWriter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * Mock 이미지 재생성 서비스 (테스트용)
 * 실제 구현 전까지 사용
 */
@Slf4j
@Service
@Profile({"local", "test"})
@RequiredArgsConstructor
public class MockRegenerateImageService implements RegenerateImageUseCase {

    private final JobWriter jobWriter;

    @Override
    public JobInfo execute(ContentCommand.RegenerateImage command) {
        log.info("[MOCK] 이미지 재생성 요청: imageId={}", command.getImageId());

        // Mock Job 생성
        String jobId = "job-regen-" + UUID.randomUUID().toString().substring(0, 8);

        Job job = Job.builder()
                .id(jobId)
                .eventDraftId(999L)  // Mock event ID
                .jobType("image-regeneration")
                .status(Job.Status.PENDING)
                .progress(0)
                .createdAt(java.time.LocalDateTime.now())
                .updatedAt(java.time.LocalDateTime.now())
                .build();

        // Job 저장
        Job savedJob = jobWriter.save(job);

        log.info("[MOCK] 재생성 Job 생성 완료: jobId={}", jobId);

        return JobInfo.from(savedJob);
    }
}
