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

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

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

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

    @ApiModelProperty("VMS 유형 코드")  // N VARCHAR(5)
    @Id
    @Column(name = "VMS_TYPE_CD", nullable = false, length = 5)
    private String vmsTypeCd;

    @ApiModelProperty("VMS 유형 명")  // Y VARCHAR(40)
    @Column(name = "VMS_TYPE_NM", length = 40)
    private String vmsTypeNm;

    @ApiModelProperty("VMS 너비")  // Y NUMBER(4)
    @Column(name = "VMS_WDTH", columnDefinition = "NUMBER", length = 4)
    private Integer vmsWdth;

    @ApiModelProperty("VMS 높이")  // Y NUMBER(4)
    @Column(name = "VMS_HGHT", columnDefinition = "NUMBER", length = 4)
    private Integer vmsHght;

    @ApiModelProperty("행 개수")  // Y NUMBER(3)
    @Column(name = "ROW_NUM", columnDefinition = "NUMBER", length = 3)
    private Integer rowNum;

    @ApiModelProperty("열 개수")  // Y NUMBER(3)
    @Column(name = "COL_NUM", columnDefinition = "NUMBER", length = 3)
    private Integer colNum;

    @ApiModelProperty("모듈 행 개수")  // Y NUMBER(3)
    @Column(name = "MODL_ROW_NUM", columnDefinition = "NUMBER", length = 3)
    private Integer modlRowNum;

    @ApiModelProperty("모듈 열 개수")  // Y NUMBER(3)
    @Column(name = "MODL_COL_NUM", columnDefinition = "NUMBER", length = 3)
    private Integer modlColNum;

    @ApiModelProperty("전원모듈 행 개수")  // Y NUMBER(3)
    @Column(name = "POWR_ROW_NUM", columnDefinition = "NUMBER", length = 3)
    private Integer powrRowNum;

    @ApiModelProperty("전원모듈 열 개수")  // Y NUMBER(3)
    @Column(name = "POWR_COL_NUM", columnDefinition = "NUMBER", length = 3)
    private Integer powrColNum;

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

    public TbVmsTypeDto toDto() {
        TbVmsTypeDto dto = TbVmsTypeDto.builder()
                .vmsTypeCd(this.vmsTypeCd)
                .vmsTypeNm(this.vmsTypeNm)
                .vmsWdth(this.vmsWdth)
                .vmsHght(this.vmsHght)
                .rowNum(this.rowNum)
                .colNum(this.colNum)
                .modlRowNum(this.modlRowNum)
                .modlColNum(this.modlColNum)
                .powrRowNum(this.powrRowNum)
                .powrColNum(this.powrColNum)
                .useYn(this.useYn)
                .build();

        dto.setVmsTypeDesc("[" + dto.getVmsTypeCd() + "] " + dto.getVmsTypeNm());

        return dto;
    }

    public TbVmsType(String vmsTypeCd) {
        this.vmsTypeCd = vmsTypeCd;
    }

    public void updateInfo(TbVmsTypeDto.TbVmsTypeUpdReq req) {
        this.vmsTypeNm = req.getVmsTypeNm();
        this.vmsWdth = req.getVmsWdth();
        this.vmsHght = req.getVmsHght();
        this.rowNum = req.getRowNum();
        this.colNum = req.getColNum();
        this.modlRowNum = req.getModlRowNum();
        this.modlColNum = req.getModlColNum();
        this.powrRowNum = req.getPowrRowNum();
        this.powrColNum = req.getPowrColNum();
        this.useYn = req.getUseYn();
    }

}
