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

import com.kt.event.common.exception.BusinessException;
import com.kt.event.common.exception.ErrorCode;
import com.kt.event.content.biz.domain.Job;
import com.kt.event.content.biz.dto.JobInfo;
import com.kt.event.content.biz.usecase.in.GetJobStatusUseCase;
import com.kt.event.content.biz.usecase.out.JobReader;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Job 관리 서비스
 * Job 상태 조회 기능 제공
 */
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class JobManagementService implements GetJobStatusUseCase {

    private final JobReader jobReader;

    @Override
    public JobInfo execute(String jobId) {
        Job job = jobReader.findById(jobId)
                .orElseThrow(() -> new BusinessException(ErrorCode.COMMON_001, "Job을 찾을 수 없습니다"));

        return JobInfo.from(job);
    }
}
