package com.its.op.entity.its.facility;

import com.its.op.dto.its.facility.TbFcltSttsAlrmStupDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 시설물 상태 알람 설정 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("시설물 상태 알람 설정")
@Entity
@Table(name = "TB_FCLT_STTS_ALRM_STUP")
@IdClass(TbFcltSttsAlrmStupKey.class)
public class TbFcltSttsAlrmStup implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("시설물 유형")  // N VARCHAR2(7)
    @Id
    @Column(name = "FCLT_TYPE", nullable = false, length = 7)
    private String fcltType;

    @ApiModelProperty("시설물 ID")  // N VARCHAR2(30)
    @Id
    @Column(name = "FCLT_ID", nullable = false, length = 30)
    private String fcltId;

    @ApiModelProperty("등록일시")  // N VARCHAR2(14)
    @Column(name = "REG_DT", nullable = false, length = 14)
    private String regDt;

    @ApiModelProperty("통신 상태 ")  // Y CHAR(1)
    @Column(name = "CMNC_STTS", columnDefinition = "CHAR", length = 1)
    private String cmncStts;

    @ApiModelProperty("전원 상태")  // Y CHAR(1)
    @Column(name = "PWER_STTS", columnDefinition = "CHAR", length = 1)
    private String pwerStts;

    @ApiModelProperty("모듈 상태")  // Y CHAR(1)
    @Column(name = "MODL_STTS", columnDefinition = "CHAR", length = 1)
    private String modlStts;

    @ApiModelProperty("도어 상태")  // Y CHAR(1)
    @Column(name = "DOOR_STTS", columnDefinition = "CHAR", length = 1)
    private String doorStts;

    @ApiModelProperty("앞문 상태")  // Y CHAR(1)
    @Column(name = "FRONT_DOOR_STTS", columnDefinition = "CHAR", length = 1)
    private String frontDoorStts;

    @ApiModelProperty("뒷문 상태")  // Y CHAR(1)
    @Column(name = "BACK_DOOR_STTS", columnDefinition = "CHAR", length = 1)
    private String backDoorStts;

    @ApiModelProperty("비디오 입력")  // Y CHAR(1)
    @Column(name = "VIDEO_INPUT", columnDefinition = "CHAR", length = 1)
    private String videoInput;

    @ApiModelProperty("제어기 장치 상태")  // Y CHAR(1)
    @Column(name = "CNTL_DEVC_STTS", columnDefinition = "CHAR", length = 1)
    private String cntlDevcStts;

    @ApiModelProperty("안테나 상태")  // Y CHAR(1)
    @Column(name = "ATN_STTS", columnDefinition = "CHAR", length = 1)
    private String atnStts;

    @ApiModelProperty("안테나 동작")  // Y CHAR(1)
    @Column(name = "ATN_MTNS", columnDefinition = "CHAR", length = 1)
    private String atnMtns;

    @ApiModelProperty("제어기 통신 상태")  // Y CHAR(1)
    @Column(name = "COMM_STTS", columnDefinition = "CHAR", length = 1)
    private String commStts;

    @ApiModelProperty("사용자ID(사원번호)")  // Y VARCHAR2(20)
    @Column(name = "USER_ID", length = 20)
    private String userId;

    @ApiModelProperty("사용 여부")  // Y CHAR(1)
    @Column(name = "USE_YN", columnDefinition = "CHAR", length = 1)
    private String useYn;

    public TbFcltSttsAlrmStupDto toDto() {
        return TbFcltSttsAlrmStupDto.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();
    }

    public TbFcltSttsAlrmStup(String fcltType, String fcltId) {
        this.fcltType = fcltType;
        this.fcltId = fcltId;
    }

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

}
