package com.its.op.dto.its.facility;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.facility.TbFcltFailStup;
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("TbFcltFailStupDto(시설물 장애 처리 설정)")
public class TbFcltFailStupDto implements Serializable {
    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("장애 발생 구분코드")  // N VARCHAR2(7)
    @JsonProperty("fail_ocrr_cd")
    private String failOcrrCd;

    @ApiModelProperty("장애유형")  // N VARCHAR2(7)
    @JsonProperty("fail_cd")
    private String failCd;

    @ApiModelProperty("사용여부")  // Y CHAR(1)
    @JsonProperty("use_yn")
    private String useYn;

    // Code Description Field
    @ApiModelProperty("장애 발생 구분코드 설명")
    @JsonProperty("fail_ocrr_desc")    // FAIL_OCRR_CD
    private String failOcrrDesc;

    @ApiModelProperty("장애유형 설명")
    @JsonProperty("fail_desc")    // FAIL_CD
    private String failDesc;

    @ApiModelProperty("사용여부 설명")
    @JsonProperty("use_desc")    // USE_YN
    private String useDesc;

    @ApiModel("TbFcltFailStupUpdReq(시설물 장애 처리 설정 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbFcltFailStupUpdReq {

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

        @ApiModelProperty("장애 발생 구분코드, Nullable = N, VARCHAR2(7)")  // N VARCHAR2(7)
        @JsonProperty("fail_ocrr_cd")
        @Size(min=1, max=7)
        private String failOcrrCd;

        @ApiModelProperty("장애유형, Nullable = N, VARCHAR2(7)")  // N VARCHAR2(7)
        @JsonProperty("fail_cd")
        @Size(min=1, max=7)
        private String failCd;

        @ApiModelProperty("사용여부, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("use_yn")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String useYn;

        @Builder
        public TbFcltFailStupUpdReq(String fclt_type, String fail_ocrr_cd, String fail_cd, String use_yn) {
            this.fcltType = fclt_type;
            this.failOcrrCd = fail_ocrr_cd;
            this.failCd = fail_cd;
            this.useYn = use_yn;
        }

        public TbFcltFailStup toEntity() {
            return TbFcltFailStup.builder()
                    .fcltType(this.fcltType)
                    .failOcrrCd(this.failOcrrCd)
                    .failCd(this.failCd)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
