package com.its.api.its.model.entity.vms;

import com.its.api.its.model.dto.vms.TbVmsFormDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

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

/**
 * VMS FORM Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("VMS FORM")
@Entity
@Table(name = "TB_VMS_FORM")
public class TbVmsForm implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VMS FORM ID")  // N NUMBER(5)
    @Id
    @Column(name = "VMS_FORM_ID", nullable = false, columnDefinition = "NUMBER", length = 5)
    private Integer vmsFormId;

    @ApiModelProperty("VMS 유형 코드")  // Y VARCHAR(7)
    @Column(name = "VMS_TYPE_CD", length = 7)
    private String vmsTypeCd;

    @ApiModelProperty("VMS FORM 유형 코드")  // N NUMBER(3)
    @Column(name = "VMS_FORM_TYPE_CD", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer vmsFormTypeCd;

    @ApiModelProperty("VMS FORM 배경 색상 코드")  // N NUMBER(10)
    @Column(name = "VMS_FORM_BCKG_HUE_CD", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long vmsFormBckgHueCd;

    @ApiModelProperty("VMS FORM 명")  // Y VARCHAR(60)
    @Column(name = "VMS_FORM_NM", length = 60)
    private String vmsFormNm;

    @ApiModelProperty("VMS FORM 설명")  // Y VARCHAR(200)
    @Column(name = "VMS_FORM_EXPL", length = 200)
    private String vmsFormExpl;

    @ApiModelProperty("VMS 메시지 표출 방향 코드")  // Y NUMBER(3)
    @Column(name = "VMS_MSG_DSPL_DRCT_CD", columnDefinition = "NUMBER", length = 3)
    private Integer vmsMsgDsplDrctCd;

    @ApiModelProperty("심벌라이브러리 번호")  // Y NUMBER(4)
    @Column(name = "SYMBLIB_NMBR", columnDefinition = "NUMBER", length = 4)
    private Integer symbLibNmbr;

    @ApiModelProperty("VMS FORM 이미지")  // Y BLOB
    @Lob
    @Column(name = "VMS_FORM_IMAG")
    private byte[] vmsFormImag;

    @ApiModelProperty("VMS 메시지 표출 방법 코드")  // Y NUMBER(3)
    @Column(name = "VMS_MSG_DSPL_MTHD_CD", columnDefinition = "NUMBER", length = 3)
    private Integer vmsMsgDsplMthdCd;

    @ApiModelProperty("CCTV 관리 번호")  // Y NUMBER(10)
    @Column(name = "CCTV_MNGM_NMBR", columnDefinition = "NUMBER", length = 10)
    private Long cctvMngmNmbr;

    public TbVmsFormDto toDto() {
        return TbVmsFormDto.builder()
                .vmsFormId(this.vmsFormId)
                .vmsTypeCd(this.vmsTypeCd)
                .vmsFormTypeCd(this.vmsFormTypeCd)
                .vmsFormBckgHueCd(this.vmsFormBckgHueCd)
                .vmsFormNm(this.vmsFormNm)
                .vmsFormExpl(this.vmsFormExpl)
                .vmsMsgDsplDrctCd(this.vmsMsgDsplDrctCd)
                .symbLibNmbr(this.symbLibNmbr)
                .vmsFormImag(this.vmsFormImag)
                .vmsMsgDsplMthdCd(this.vmsMsgDsplMthdCd)
                .cctvMngmNmbr(this.cctvMngmNmbr)
                .build();
    }

    public TbVmsForm(Integer vmsFormId) {
        this.vmsFormId = vmsFormId;
    }

    public void updateInfo(TbVmsFormDto.TbVmsFormUpdReq req) {
        this.vmsTypeCd = req.getVmsTypeCd();
        this.vmsFormTypeCd = req.getVmsFormTypeCd();
        this.vmsFormBckgHueCd = req.getVmsFormBckgHueCd();
        this.vmsFormNm = req.getVmsFormNm();
        this.vmsFormExpl = req.getVmsFormExpl();
        this.vmsMsgDsplDrctCd = req.getVmsMsgDsplDrctCd();
        this.symbLibNmbr = req.getSymbLibNmbr();
        this.vmsFormImag = req.getVmsFormImag();
        this.vmsMsgDsplMthdCd = req.getVmsMsgDsplMthdCd();
        this.cctvMngmNmbr = req.getCctvMngmNmbr();
    }

}
