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

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

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

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

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

    @ApiModelProperty("발생 일시")  // Y VARCHAR(14)
    @JsonProperty("ocrr_dt")
    private String ocrrDt;

    @ApiModelProperty("접수자 명")  // Y VARCHAR(30)
    @JsonProperty("rcpr_nm")
    private String rcprNm;

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

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

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

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

    @ApiModelProperty("장애 유형")  // Y VARCHAR(7)
    @JsonProperty("fail_type")
    private String failType;

    @ApiModelProperty("장애 내용")  // Y VARCHAR(600)
    @JsonProperty("fail_cont")
    private String failCont;

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

    // Code Description Field
    @ApiModel("TbFcltFailHsUpdReq(시설물 장애 내역 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbFcltFailHsUpdReq {

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

        @ApiModelProperty("발생 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("ocrr_dt")
        @Size(min=1, max=14)
        private String ocrrDt;

        @ApiModelProperty("접수자 명, Nullable = Y, VARCHAR(30)")  // Y VARCHAR(30)
        @JsonProperty("rcpr_nm")
        @Size(min=1, max=30)
        private String rcprNm;

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

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

        @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;

        @ApiModelProperty("장애 유형, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("fail_type")
        @Size(min=1, max=7)
        private String failType;

        @ApiModelProperty("장애 내용, Nullable = Y, VARCHAR(600)")  // Y VARCHAR(600)
        @JsonProperty("fail_cont")
        @Size(min=1, max=600)
        private String failCont;

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

        @Builder
        public TbFcltFailHsUpdReq(String fail_hs_seq, String ocrr_dt, String rcpr_nm, String adtn_nm, String adtn_dt, String chng_nm, String chng_dt, String fail_type, String fail_cont, String fclt_id) {
            this.failHsSeq = fail_hs_seq;
            this.ocrrDt = ocrr_dt;
            this.rcprNm = rcpr_nm;
            this.adtnNm = adtn_nm;
            this.adtnDt = adtn_dt;
            this.chngNm = chng_nm;
            this.chngDt = chng_dt;
            this.failType = fail_type;
            this.failCont = fail_cont;
            this.fcltId = fclt_id;
        }

        public TbFcltFailHs toEntity() {
            return TbFcltFailHs.builder()
                    .failHsSeq(this.failHsSeq)
                    .ocrrDt(this.ocrrDt)
                    .rcprNm(this.rcprNm)
                    .adtnNm(this.adtnNm)
                    .adtnDt(this.adtnDt)
                    .chngNm(this.chngNm)
                    .chngDt(this.chngDt)
                    .failType(this.failType)
                    .failCont(this.failCont)
                    .fcltId(this.fcltId)
                    .build();
        }

    }

}
