package kr.xit.core.biz.batch.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import java.time.LocalDateTime;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

/**
 * <pre>
 * description :
 *
 * packageName : kr.xit.core.biz.batch.model
 * fileName    : BatchLockDTO
 * author      : limju
 * date        : 2023-05-16
 * ======================================================================
 * 변경일         변경자        변경 내용
 * ----------------------------------------------------------------------
 * 2023-05-16    limju       최초 생성
 * 2023-06-15    limju       배치로그 추가
 *
 * </pre>
 */
public class BatchCmmDTO {
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @SuperBuilder
    @EqualsAndHashCode(callSuper = false)
    public static class BatchCmmRequest extends CmmEnsRequestDTO {
        /**
         * 배치 인스턴스 ID
         */
        @Schema(requiredMode = RequiredMode.AUTO, title = "배치인스턴스ID", example = "EnsCctvAcceptJob")
        private String instanceId;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class BatchLock {
        /**
         * 배치 로그 ID
         */
        private String batchLogId;
        /**
         * 배치 인스턴스 ID
         */
        private String instanceId;
        /**
         * 배치 인스턴스 name
         */
        private String instanceName;
        /**
         * 배치 인스턴스 call url
         */
        private String instanceUrl;
        /**
         * 배치 인스턴스 parameter
         */
        private String instanceParam;
        /**
         * 배치 API trace ID
         */
        private String traceId;
        /**
         * 실행 결과
         */
        private String result;
        /**
         * 에러메세지
         */
        private String message;
        /**
         * 배치 실행중 여부
         */
        private String useYn;

        //@Convert(converter = Jsr310.LocalDateTimeConverter.class)
        @JsonDeserialize(using = LocalDateDeserializer.class)
        @JsonFormat(pattern = "yyyy-MM-dd kk:mm:ss.SSS")
        private LocalDateTime registDt;

        @JsonDeserialize(using = LocalDateDeserializer.class)
        @JsonFormat(pattern = "yyyy-MM-dd kk:mm:ss.SSS")
        private LocalDateTime updateDt;
    }
}
