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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.facility.TbFcltFailTypeAct;
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("TbFcltFailTypeActDto(시설물 장애 유형별 조치)")
public class TbFcltFailTypeActDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("장애조치유형")  // N VARCHAR2(7)
    @JsonProperty("fail_act_cd")
    private String failActCd;

    @ApiModelProperty("장애조치 명")  // Y VARCHAR2(30)
    @JsonProperty("fail_act_cd_nm")
    private String failActCdNm;

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

    // Code Description Field
    @ApiModelProperty("장애조치유형 설명")
    @JsonProperty("fail_act_desc")    // FAIL_ACT_CD
    private String failActDesc;

    @ApiModelProperty("장애조치 명 설명")
    @JsonProperty("fail_act_desc_nm")    // FAIL_ACT_CD_NM
    private String failActDescNm;

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

    @ApiModel("TbFcltFailTypeActUpdReq(시설물 장애 유형별 조치 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbFcltFailTypeActUpdReq {

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

        @ApiModelProperty("장애조치 명, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("fail_act_cd_nm")
        @Size(min=1, max=30)
        private String failActCdNm;

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

        @Builder
        public TbFcltFailTypeActUpdReq(String fail_act_cd, String fail_act_cd_nm, String use_yn) {
            this.failActCd = fail_act_cd;
            this.failActCdNm = fail_act_cd_nm;
            this.useYn = use_yn;
        }

        public TbFcltFailTypeAct toEntity() {
            return TbFcltFailTypeAct.builder()
                    .failActCd(this.failActCd)
                    .failActCdNm(this.failActCdNm)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
