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

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.facility.TbFcltInfr;
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("TbFcltInfrDto(시설물 정보)")
public class TbFcltInfrDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("시설물 ID")  // N VARCHAR(50)
    @JsonProperty("fclt_id")
    private String fcltId;

    @ApiModelProperty("시설물 유형")  // Y VARCHAR(7)
    @JsonProperty("fclt_type")
    private String fcltType;

    @ApiModelProperty("시설물 위치")  // Y VARCHAR(100)
    @JsonProperty("fclt_lctn")
    private String fcltLctn;

    @ApiModelProperty("설치 위치 주소")  // Y VARCHAR(200)
    @JsonProperty("istl_lctn_addr")
    private String istlLctnAddr;

    @ApiModelProperty("자산 유무")  // Y CHAR(1)
    @JsonProperty("rsce_yn")
    private String rsceYn;

    @ApiModelProperty("모델 명")  // Y VARCHAR(30)
    @JsonProperty("mdl_nm")
    private String mdlNm;

    @ApiModelProperty("사용 년수")  // Y NUMBER(3)
    @JsonProperty("use_year")
    private Integer useYear;

    @ApiModelProperty("입고 일시")  // Y VARCHAR(14)
    @JsonProperty("inwr_dt")
    private String inwrDt;

    @ApiModelProperty("출고 일시")  // Y VARCHAR(14)
    @JsonProperty("otwr_dt")
    private String otwrDt;

    @ApiModelProperty("설치 일시")  // Y VARCHAR(14)
    @JsonProperty("istl_dt")
    private String istlDt;

    @ApiModelProperty("반출 일시")  // Y VARCHAR(14)
    @JsonProperty("takt_dt")
    private String taktDt;

    @ApiModelProperty("반출 사유")  // Y VARCHAR(100)
    @JsonProperty("takt_resn")
    private String taktResn;

    @ApiModelProperty("반입 일시")  // Y VARCHAR(14)
    @JsonProperty("takn_dt")
    private String taknDt;

    @ApiModelProperty("폐기 일시")  // Y VARCHAR(14)
    @JsonProperty("abdn_dt")
    private String abdnDt;

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

    //@ApiModelProperty("추가 일시")  // Y VARCHAR(14)
    //@JsonProperty("adtn_dt")
    @JsonIgnore
    private String adtnDt;

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

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

    @ApiModelProperty("금액")  // Y NUMBER(15)
    @JsonProperty("amt")
    private Long amt;

    @ApiModelProperty("삭제 여부")  // Y CHAR(1)
    @JsonProperty("del_yn")
    private String delYn;

    @ApiModelProperty("설치 업체 ID")  // Y VARCHAR(30)
    @JsonProperty("istl_cmpy_id")
    private String istlCmpyId;

    @ApiModelProperty("제조 업체 ID")  // Y VARCHAR(30)
    @JsonProperty("mnfc_cmpy_id")
    private String mnfcCmpyId;

    @ApiModelProperty("RFID ID")  // Y VARCHAR(30)
    @JsonProperty("rfid_id")
    private String rfidId;

    // Code Description Field
    @ApiModelProperty("자산 유무 설명")
    @JsonProperty("rsce_desc")    // RSCE_YN
    private String rsceDesc;

    @ApiModelProperty("삭제 여부 설명")
    @JsonProperty("del_desc")    // DEL_YN
    private String delDesc;

    @ApiModel("TbFcltInfrUpdReq(시설물 정보 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbFcltInfrUpdReq {

        @ApiModelProperty("시설물 ID, Nullable = N, VARCHAR(50)")  // N VARCHAR(50)
        @JsonProperty("fclt_id")
        @Size(min=1, max=50)
        private String fcltId;

        @ApiModelProperty("시설물 유형, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("fclt_type")
        @Size(min=1, max=7)
        private String fcltType;

        @ApiModelProperty("시설물 위치, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("fclt_lctn")
        @Size(min=1, max=100)
        private String fcltLctn;

        @ApiModelProperty("설치 위치 주소, Nullable = Y, VARCHAR(200)")  // Y VARCHAR(200)
        @JsonProperty("istl_lctn_addr")
        @Size(min=0, max=200)
        private String istlLctnAddr;

        @ApiModelProperty("자산 유무, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("rsce_yn")
        @Size(min=0, max=1)
        @Pattern(regexp = "[YN]")
        private String rsceYn;

        @ApiModelProperty("모델 명, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("mdl_nm")
        @Size(min=0, max=30)
        private String mdlNm;

        @ApiModelProperty("사용 년수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("use_year")
        //@PositiveOrZero
        private Integer useYear;

        @ApiModelProperty("입고 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("inwr_dt")
        @Size(min=0, max=14)
        private String inwrDt;

        @ApiModelProperty("출고 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("otwr_dt")
        @Size(min=0, max=14)
        private String otwrDt;

        @ApiModelProperty("설치 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("istl_dt")
        @Size(min=0, max=14)
        private String istlDt;

        @ApiModelProperty("반출 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("takt_dt")
        @Size(min=0, max=14)
        private String taktDt;

        @ApiModelProperty("반출 사유, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("takt_resn")
        @Size(min=0, max=100)
        private String taktResn;

        @ApiModelProperty("반입 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("takn_dt")
        @Size(min=0, max=14)
        private String taknDt;

        @ApiModelProperty("폐기 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("abdn_dt")
        @Size(min=0, max=14)
        private String abdnDt;

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

        @ApiModelProperty("추가 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("adtn_dt")
        @Size(min=0, max=14)
        private String adtnDt;

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

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

        @ApiModelProperty("금액, Nullable = Y, NUMBER(15)")  // Y NUMBER(15)
        @JsonProperty("amt")
        //@PositiveOrZero
        private Long amt;

        @ApiModelProperty("삭제 여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("del_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String delYn;

        @ApiModelProperty("설치 업체 ID, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("istl_cmpy_id")
        @Size(min=0, max=30)
        private String istlCmpyId;

        @ApiModelProperty("제조 업체 ID, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("mnfc_cmpy_id")
        @Size(min=0, max=30)
        private String mnfcCmpyId;

        @ApiModelProperty("RFID ID, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("rfid_id")
        @Size(min=0, max=30)
        private String rfidId;

        @Builder
        public TbFcltInfrUpdReq(String fclt_id, String fclt_type, String fclt_lctn, String istl_lctn_addr, String rsce_yn, String mdl_nm, Integer use_year, String inwr_dt, String otwr_dt, String istl_dt, String takt_dt, String takt_resn, String takn_dt, String abdn_dt, String adtn_nm, String adtn_dt, String chng_nm, String chng_dt, Long amt, String del_yn, String istl_cmpy_id, String mnfc_cmpy_id, String rfid_id) {
            this.fcltId = fclt_id;
            this.fcltType = fclt_type;
            this.fcltLctn = fclt_lctn;
            this.istlLctnAddr = istl_lctn_addr;
            this.rsceYn = rsce_yn;
            this.mdlNm = mdl_nm;
            this.useYear = use_year;
            this.inwrDt = inwr_dt;
            this.otwrDt = otwr_dt;
            this.istlDt = istl_dt;
            this.taktDt = takt_dt;
            this.taktResn = takt_resn;
            this.taknDt = takn_dt;
            this.abdnDt = abdn_dt;
            this.adtnNm = adtn_nm;
            this.adtnDt = adtn_dt;
            this.chngNm = chng_nm;
            this.chngDt = chng_dt;
            this.amt = amt;
            this.delYn = del_yn;
            this.istlCmpyId = istl_cmpy_id;
            this.mnfcCmpyId = mnfc_cmpy_id;
            this.rfidId = rfid_id;
        }

        public TbFcltInfr toEntity() {
            return TbFcltInfr.builder()
                    .fcltId(this.fcltId)
                    .fcltType(this.fcltType)
                    .fcltLctn(this.fcltLctn)
                    .istlLctnAddr(this.istlLctnAddr)
                    .rsceYn(this.rsceYn)
                    .mdlNm(this.mdlNm)
                    .useYear(this.useYear)
                    .inwrDt(this.inwrDt)
                    .otwrDt(this.otwrDt)
                    .istlDt(this.istlDt)
                    .taktDt(this.taktDt)
                    .taktResn(this.taktResn)
                    .taknDt(this.taknDt)
                    .abdnDt(this.abdnDt)
                    .adtnNm(this.adtnNm)
                    .adtnDt(this.adtnDt)
                    .chngNm(this.chngNm)
                    .chngDt(this.chngDt)
                    .amt(this.amt)
                    .delYn(this.delYn)
                    .istlCmpyId(this.istlCmpyId)
                    .mnfcCmpyId(this.mnfcCmpyId)
                    .rfidId(this.rfidId)
                    .build();
        }

    }

}
