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

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

import java.time.LocalDateTime;

/**
 * Job 정보 DTO
 */
@Getter
@Builder
@AllArgsConstructor
public class JobInfo {

    private String id;
    private String eventId;
    private String jobType;
    private Job.Status status;
    private int progress;
    private String resultMessage;
    private String errorMessage;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;

    /**
     * 도메인 모델로부터 생성
     *
     * @param job Job 도메인 모델
     * @return JobInfo
     */
    public static JobInfo from(Job job) {
        return JobInfo.builder()
                .id(job.getId())
                .eventId(job.getEventId())
                .jobType(job.getJobType())
                .status(job.getStatus())
                .progress(job.getProgress())
                .resultMessage(job.getResultMessage())
                .errorMessage(job.getErrorMessage())
                .createdAt(job.getCreatedAt())
                .updatedAt(job.getUpdatedAt())
                .build();
    }
}
