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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.facility.TbFcltFailOcrrType;
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("TbFcltFailOcrrTypeDto(시설물 장애 발생 구분)")
public class TbFcltFailOcrrTypeDto implements Serializable {
    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("장애 발생 구분코드명")  // Y VARCHAR2(30)
    @JsonProperty("fail_ocrr_cd_nm")
    private String failOcrrCdNm;

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

    @ApiModel("TbFcltFailOcrrTypeUpdReq(시설물 장애 발생 구분 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbFcltFailOcrrTypeUpdReq {

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

        @ApiModelProperty("장애 발생 구분코드명, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("fail_ocrr_cd_nm")
        @Size(min=1, max=30)
        private String failOcrrCdNm;

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

        @Builder
        public TbFcltFailOcrrTypeUpdReq(String fail_ocrr_cd, String fail_ocrr_cd_nm, String use_yn) {
            this.failOcrrCd = fail_ocrr_cd;
            this.failOcrrCdNm = fail_ocrr_cd_nm;
            this.useYn = use_yn;
        }

        public TbFcltFailOcrrType toEntity() {
            return TbFcltFailOcrrType.builder()
                    .failOcrrCd(this.failOcrrCd)
                    .failOcrrCdNm(this.failOcrrCdNm)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
