package com.its.api.its.model.dto.facility;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.facility.TbFcltFailRparHs;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 시설물 장애 조치 내역 DTO Class
 */
@Data
@Builder
@ApiModel("TbFcltFailRparHsDto(시설물 장애 조치 내역)")
public class TbFcltFailRparHsDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("생성 일시")  // N VARCHAR(14)
    @JsonProperty("crtn_dt")
    private String crtnDt;

    @ApiModelProperty("장애 이력 일련번호")  // N VARCHAR(10)
    @JsonProperty("fail_hs_seq")
    private String failHsSeq;

    @ApiModelProperty("작업자 명")  // Y VARCHAR(30)
    @JsonProperty("wrkr_nm")
    private String wrkrNm;

    @ApiModelProperty("작업 내용")  // Y VARCHAR(600)
    @JsonProperty("work_cont")
    private String workCont;

    @ApiModelProperty("작업 시작 일시")  // Y VARCHAR(14)
    @JsonProperty("work_strt_dt")
    private String workStrtDt;

    @ApiModelProperty("작업 종료 일시")  // Y VARCHAR(14)
    @JsonProperty("work_end_dt")
    private String workEndDt;

    @ApiModelProperty("작업 완료 여부")  // Y CHAR(1)
    @JsonProperty("work_fins_yn")
    private String workFinsYn;

    @ApiModelProperty("추가자 명")  // Y VARCHAR(30)
    @JsonProperty("adtn_nm")
    private String adtnNm;

    @ApiModelProperty("변경자 명")  // Y VARCHAR(30)
    @JsonProperty("chng_nm")
    private String chngNm;

    @ApiModelProperty("변경 일시")  // Y VARCHAR(14)
    @JsonProperty("chng_dt")
    private String chngDt;

    // Code Description Field
    @ApiModelProperty("작업 완료 여부 설명")
    @JsonProperty("work_fins_desc")    // WORK_FINS_YN
    private String workFinsDesc;

    @ApiModel("TbFcltFailRparHsUpdReq(시설물 장애 조치 내역 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbFcltFailRparHsUpdReq {

        @ApiModelProperty("생성 일시, Nullable = N, VARCHAR(14)")  // N VARCHAR(14)
        @JsonProperty("crtn_dt")
        @Size(min=1, max=14)
        private String crtnDt;

        @ApiModelProperty("장애 이력 일련번호, Nullable = N, VARCHAR(10)")  // N VARCHAR(10)
        @JsonProperty("fail_hs_seq")
        @Size(min=1, max=10)
        private String failHsSeq;

        @ApiModelProperty("작업자 명, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("wrkr_nm")
        @Size(min=1, max=30)
        private String wrkrNm;

        @ApiModelProperty("작업 내용, Nullable = Y, VARCHAR(600)")  // Y VARCHAR(600)
        @JsonProperty("work_cont")
        @Size(min=1, max=600)
        private String workCont;

        @ApiModelProperty("작업 시작 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("work_strt_dt")
        @Size(min=1, max=14)
        private String workStrtDt;

        @ApiModelProperty("작업 종료 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("work_end_dt")
        @Size(min=1, max=14)
        private String workEndDt;

        @ApiModelProperty("작업 완료 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("work_fins_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String workFinsYn;

        @ApiModelProperty("추가자 명, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("adtn_nm")
        @Size(min=1, max=30)
        private String adtnNm;

        @ApiModelProperty("변경자 명, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("chng_nm")
        @Size(min=1, max=30)
        private String chngNm;

        @ApiModelProperty("변경 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("chng_dt")
        @Size(min=1, max=14)
        private String chngDt;

        @Builder
        public TbFcltFailRparHsUpdReq(String crtn_dt, String fail_hs_seq, String wrkr_nm, String work_cont, String work_strt_dt, String work_end_dt, String work_fins_yn, String adtn_nm, String chng_nm, String chng_dt) {
            this.crtnDt = crtn_dt;
            this.failHsSeq = fail_hs_seq;
            this.wrkrNm = wrkr_nm;
            this.workCont = work_cont;
            this.workStrtDt = work_strt_dt;
            this.workEndDt = work_end_dt;
            this.workFinsYn = work_fins_yn;
            this.adtnNm = adtn_nm;
            this.chngNm = chng_nm;
            this.chngDt = chng_dt;
        }

        public TbFcltFailRparHs toEntity() {
            return TbFcltFailRparHs.builder()
                    .crtnDt(this.crtnDt)
                    .failHsSeq(this.failHsSeq)
                    .wrkrNm(this.wrkrNm)
                    .workCont(this.workCont)
                    .workStrtDt(this.workStrtDt)
                    .workEndDt(this.workEndDt)
                    .workFinsYn(this.workFinsYn)
                    .adtnNm(this.adtnNm)
                    .chngNm(this.chngNm)
                    .chngDt(this.chngDt)
                    .build();
        }

    }

}
