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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.facility.TbFcltSttsAlrmStup;
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("TbFcltSttsAlrmStupDto(시설물 상태 알람 설정)")
public class TbFcltSttsAlrmStupDto implements Serializable {
    private static final long serialVersionUID = 1L;

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

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

    @ApiModelProperty("시설물 명")  // N VARCHAR2(30)
    @JsonProperty("fclt_nm")
    private String fcltNm;

    @ApiModelProperty("등록일시")  // N VARCHAR2(14)
    @JsonProperty("reg_dt")
    private String regDt;

    @ApiModelProperty("통신 상태 ")  // Y CHAR(1)
    @JsonProperty("cmnc_stts")
    private String cmncStts;

    @ApiModelProperty("전원 상태")  // Y CHAR(1)
    @JsonProperty("pwer_stts")
    private String pwerStts;

    @ApiModelProperty("모듈 상태")  // Y CHAR(1)
    @JsonProperty("modl_stts")
    private String modlStts;

    @ApiModelProperty("도어 상태")  // Y CHAR(1)
    @JsonProperty("door_stts")
    private String doorStts;

    @ApiModelProperty("앞문 상태")  // Y CHAR(1)
    @JsonProperty("front_door_stts")
    private String frontDoorStts;

    @ApiModelProperty("뒷문 상태")  // Y CHAR(1)
    @JsonProperty("back_door_stts")
    private String backDoorStts;

    @ApiModelProperty("비디오 입력")  // Y CHAR(1)
    @JsonProperty("video_input")
    private String videoInput;

    @ApiModelProperty("제어기 장치 상태")  // Y CHAR(1)
    @JsonProperty("cntl_devc_stts")
    private String cntlDevcStts;

    @ApiModelProperty("안테나 상태")  // Y CHAR(1)
    @JsonProperty("atn_stts")
    private String atnStts;

    @ApiModelProperty("안테나 동작")  // Y CHAR(1)
    @JsonProperty("atn_mtns")
    private String atnMtns;

    @ApiModelProperty("제어기 통신 상태")  // Y CHAR(1)
    @JsonProperty("comm_stts")
    private String commStts;

    @ApiModelProperty("사용자ID(사원번호)")  // Y VARCHAR2(20)
    @JsonProperty("user_id")
    private String userId;

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

    public static TbFcltSttsAlrmStupDto build(String fcltType, String fcltId, String fcltNm) {
        return TbFcltSttsAlrmStupDto.builder()
                .fcltType(fcltType)
                .fcltId(fcltId)
                .fcltNm(fcltNm)
                .regDt("19700101000000")
                .cmncStts("Y")
                .pwerStts("Y")
                .modlStts("Y")
                .doorStts("Y")
                .frontDoorStts("Y")
                .backDoorStts("Y")
                .videoInput("Y")
                .cntlDevcStts("Y")
                .atnStts("Y")
                .atnMtns("Y")
                .commStts("Y")
                .userId("")
                .useYn("N")
                .build();
    }

    public void setInfo(TbFcltSttsAlrmStup entity) {
        this.regDt = entity.getRegDt();
        this.cmncStts = entity.getCmncStts();
        this.pwerStts = entity.getPwerStts();
        this.modlStts = entity.getModlStts();
        this.doorStts = entity.getDoorStts();
        this.frontDoorStts = entity.getFrontDoorStts();
        this.backDoorStts = entity.getBackDoorStts();
        this.videoInput = entity.getVideoInput();
        this.cntlDevcStts = entity.getCntlDevcStts();
        this.atnStts = entity.getAtnStts();
        this.atnMtns = entity.getAtnMtns();
        this.commStts = entity.getCommStts();
        this.userId = entity.getUserId();
        this.useYn = entity.getUseYn();

    }
    @ApiModel("TbFcltSttsAlrmStupUpdReq(시설물 상태 알람 설정 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbFcltSttsAlrmStupUpdReq {

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

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

        @ApiModelProperty("등록일시, Nullable = N, VARCHAR2(14)")  // N VARCHAR2(14)
        @JsonProperty("reg_dt")
        @Size(min=1, max=14)
        private String regDt;

        @ApiModelProperty("통신 상태 , Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("cmnc_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String cmncStts;

        @ApiModelProperty("전원 상태, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("pwer_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String pwerStts;

        @ApiModelProperty("모듈 상태, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("modl_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String modlStts;

        @ApiModelProperty("도어 상태, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("door_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String doorStts;

        @ApiModelProperty("앞문 상태, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("front_door_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String frontDoorStts;

        @ApiModelProperty("뒷문 상태, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("back_door_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String backDoorStts;

        @ApiModelProperty("비디오 입력, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("video_input")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String videoInput;

        @ApiModelProperty("제어기 장치 상태, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("cntl_devc_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String cntlDevcStts;

        @ApiModelProperty("안테나 상태, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("atn_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String atnStts;

        @ApiModelProperty("안테나 동작, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("atn_mtns")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String atnMtns;

        @ApiModelProperty("제어기 통신 상태, Nullable = Y, CHAR(1)")  // Y CHAR(1)
        @JsonProperty("comm_stts")
        @Size(min=1, max=1)
        @Pattern(regexp = "[YN]")
        private String commStts;

        @ApiModelProperty("사용자ID(사원번호), Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("user_id")
        @Size(min=1, max=20)
        private String userId;

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

//        @Builder
//        public TbFcltSttsAlrmStupUpdReq(String fclt_type, String fclt_id, String reg_dt, String cmnc_stts, String pwer_stts, String modl_stts, String door_stts, String front_door_stts, String back_door_stts, String video_input, String cntl_devc_stts, String atn_stts, String atn_mtns, String comm_stts, String user_id, String use_yn) {
//            this.fcltType = fclt_type;
//            this.fcltId = fclt_id;
//            this.regDt = reg_dt;
//            this.cmncStts = cmnc_stts;
//            this.pwerStts = pwer_stts;
//            this.modlStts = modl_stts;
//            this.doorStts = door_stts;
//            this.frontDoorStts = front_door_stts;
//            this.backDoorStts = back_door_stts;
//            this.videoInput = video_input;
//            this.cntlDevcStts = cntl_devc_stts;
//            this.atnStts = atn_stts;
//            this.atnMtns = atn_mtns;
//            this.commStts = comm_stts;
//            this.userId = user_id;
//            this.useYn = use_yn;
//        }

        public TbFcltSttsAlrmStup toEntity() {
            return TbFcltSttsAlrmStup.builder()
                    .fcltType(this.fcltType)
                    .fcltId(this.fcltId)
                    .regDt(this.regDt)
                    .cmncStts(this.cmncStts)
                    .pwerStts(this.pwerStts)
                    .modlStts(this.modlStts)
                    .doorStts(this.doorStts)
                    .frontDoorStts(this.frontDoorStts)
                    .backDoorStts(this.backDoorStts)
                    .videoInput(this.videoInput)
                    .cntlDevcStts(this.cntlDevcStts)
                    .atnStts(this.atnStts)
                    .atnMtns(this.atnMtns)
                    .commStts(this.commStts)
                    .userId(this.userId)
                    .useYn(this.useYn)
                    .build();
        }

    }

}
