package com.its.op.entity.its.vms;

import com.its.op.dto.its.vms.TbVmsFormObjectDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

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

/**
 * VMS FORM OBJECT Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("VMS FORM OBJECT")
@Entity
@Table(name = "TB_VMS_FORM_OBJECT")
@IdClass(TbVmsFormObjectKey.class)
public class TbVmsFormObject 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("FORM OBJECT ID")  // N NUMBER(5)
    @Id
    @Column(name = "VMS_FORM_OBJECT_ID", nullable = false, columnDefinition = "NUMBER", length = 5)
    private Integer vmsFormObjectId;

    @ApiModelProperty("VMS FORM 표출 행")  // Y NUMBER(2)
    @Column(name = "VMS_FORM_DSPL_ROW", columnDefinition = "NUMBER", length = 2)
    private Integer vmsFormDsplRow;

    @ApiModelProperty("VMS FORM 표출 칼럼")  // Y NUMBER(2)
    @Column(name = "VMS_FORM_DSPL_CLMN", columnDefinition = "NUMBER", length = 2)
    private Integer vmsFormDsplClmn;

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

    @ApiModelProperty("VMS 글꼴 명칭 코드")  // N NUMBER(3)
    @Column(name = "VMS_FONT_NAME_CD", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer vmsFontNameCd;

    @ApiModelProperty("VMS 글꼴 색상 코드")  // N NUMBER(3)
    @Column(name = "VMS_FONT_COLR_CD", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer vmsFontColrCd;

    @ApiModelProperty("VMS 글꼴 방식 코드(0:Normal,1:Bold)")  // Y NUMBER(1)
    @Column(name = "VMS_FONT_BOLD", columnDefinition = "NUMBER", length = 1)
    private Integer vmsFontBold;

    @ApiModelProperty("VMS 글꼴 크기")  // Y NUMBER(3)
    @Column(name = "VMS_FONT_SIZE", columnDefinition = "NUMBER", length = 3)
    private Integer vmsFontSize;

    @ApiModelProperty("VMS 표출 문자열정열방식(0:LEFT,1:RIGHT,2:CENTER)")  // Y NUMBER(1)
    @Column(name = "VMS_FONT_ALIGN", columnDefinition = "NUMBER", length = 1)
    private Integer vmsFontAlign;

    @ApiModelProperty("VMS 표출 텍스트")  // Y VARCHAR2(200)
    @Column(name = "VMS_DSPL_TXT", length = 200)
    private String vmsDsplTxt;

    @ApiModelProperty("VMS 표출 도형")  // Y BLOB
    @Lob
    @Column(name = "VMS_DSPL_FIGR")
    private byte[] vmsDsplFigr;

    @ApiModelProperty("VMS 표출 X좌표")  // Y NUMBER(5)
    @Column(name = "VMS_DSPL_XCRDN", columnDefinition = "NUMBER", length = 5)
    private Integer vmsDsplXcrdn;

    @ApiModelProperty("VMS 표출 Y좌표")  // Y NUMBER(5)
    @Column(name = "VMS_DSPL_YCRDN", columnDefinition = "NUMBER", length = 5)
    private Integer vmsDsplYcrdn;

    @ApiModelProperty("VMS 표출 넓이")  // Y NUMBER(5)
    @Column(name = "VMS_DSPL_WIDTH", columnDefinition = "NUMBER", length = 5)
    private Integer vmsDsplWidth;

    @ApiModelProperty("VMS 표출 높이")  // Y NUMBER(5)
    @Column(name = "VMS_DSPL_HEIGHT", columnDefinition = "NUMBER", length = 5)
    private Integer vmsDsplHeight;

    @ApiModelProperty("VMS 표출 점멸 여부(0:지속, 1:점멸)")  // Y NUMBER(1)
    @Column(name = "VMS_DSPL_BLINKING", columnDefinition = "NUMBER", length = 1)
    private Integer vmsDsplBlinking;

    @ApiModelProperty("VMS 표출 배경색상코드")  // Y NUMBER(1)
    @Column(name = "VMS_DSPL_BKCOLOR", columnDefinition = "NUMBER", length = 1)
    private Integer vmsDsplBkcolor;

    @ApiModelProperty("VMS 표출 크기(문자:문자길이,이미지:이미지전체크기)")  // Y NUMBER(7)
    @Column(name = "VMS_DSPL_SIZE", columnDefinition = "NUMBER", length = 7)
    private Integer vmsDsplSize;

    @ApiModelProperty("FILL-IN 메시지 여부")  // Y CHAR(1)
    @Column(name = "TRFC_FILL_CD", columnDefinition = "CHAR", length = 1)
    private String trfcFillCd;

    @ApiModelProperty("심벌라이브러리 번호(TB_VMS_SYMB_LIB)")  // N NUMBER(4)
    @Column(name = "SYMB_LIB_NMBR", nullable = false, columnDefinition = "NUMBER", length = 4)
    private Integer symbLibNmbr;

    @ApiModelProperty("VMS 정보제공구간 ID")  // Y NUMBER(10)
    @Column(name = "VMS_IFSC_ID", columnDefinition = "NUMBER", length = 10)
    private Long vmsIfscId;

    public TbVmsFormObjectDto toDto() {
        return TbVmsFormObjectDto.builder()
                .vmsFormId(this.vmsFormId)
                .vmsFormObjectId(this.vmsFormObjectId)
                .vmsFormDsplRow(this.vmsFormDsplRow)
                .vmsFormDsplClmn(this.vmsFormDsplClmn)
                .vmsFormObjectTypeCd(this.vmsFormObjectTypeCd)
                .vmsFontNameCd(this.vmsFontNameCd)
                .vmsFontColrCd(this.vmsFontColrCd)
                .vmsFontBold(this.vmsFontBold)
                .vmsFontSize(this.vmsFontSize)
                .vmsFontAlign(this.vmsFontAlign)
                .vmsDsplTxt(this.vmsDsplTxt)
                .vmsDsplFigr(this.vmsDsplFigr)
                .vmsDsplXcrdn(this.vmsDsplXcrdn)
                .vmsDsplYcrdn(this.vmsDsplYcrdn)
                .vmsDsplWidth(this.vmsDsplWidth)
                .vmsDsplHeight(this.vmsDsplHeight)
                .vmsDsplBlinking(this.vmsDsplBlinking)
                .vmsDsplBkcolor(this.vmsDsplBkcolor)
                .vmsDsplSize(this.vmsDsplSize)
                .trfcFillCd(this.trfcFillCd)
                .symbLibNmbr(this.symbLibNmbr)
                .vmsIfscId(this.vmsIfscId)
                .build();
    }

    public TbVmsFormObject(Integer vmsFormId, Integer vmsFormObjectId) {
        this.vmsFormId = vmsFormId;
        this.vmsFormObjectId = vmsFormObjectId;
    }

    public void updateInfo(TbVmsFormObjectDto.TbVmsFormObjectUpdReq req) {
        this.vmsFormDsplRow = req.getVmsFormDsplRow();
        this.vmsFormDsplClmn = req.getVmsFormDsplClmn();
        this.vmsFormObjectTypeCd = req.getVmsFormObjectTypeCd();
        this.vmsFontNameCd = req.getVmsFontNameCd();
        this.vmsFontColrCd = req.getVmsFontColrCd();
        this.vmsFontBold = req.getVmsFontBold();
        this.vmsFontSize = req.getVmsFontSize();
        this.vmsFontAlign = req.getVmsFontAlign();
        this.vmsDsplTxt = req.getVmsDsplTxt();
        this.vmsDsplFigr = req.getVmsDsplFigr();
        this.vmsDsplXcrdn = req.getVmsDsplXcrdn();
        this.vmsDsplYcrdn = req.getVmsDsplYcrdn();
        this.vmsDsplWidth = req.getVmsDsplWidth();
        this.vmsDsplHeight = req.getVmsDsplHeight();
        this.vmsDsplBlinking = req.getVmsDsplBlinking();
        this.vmsDsplBkcolor = req.getVmsDsplBkcolor();
        this.vmsDsplSize = req.getVmsDsplSize();
        this.trfcFillCd = req.getTrfcFillCd();
        this.symbLibNmbr = req.getSymbLibNmbr();
        this.vmsIfscId = req.getVmsIfscId();
    }

}
