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

import com.its.api.its.model.dto.vms.TbVmsFormPrrtDto;
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 FORM 우선순위 Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("VMS FORM 우선순위")
@Entity
@Table(name = "TB_VMS_FORM_PRRT")
public class TbVmsFormPrrt implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VMS FORM 우선순위 코드")  // N VARCHAR(3)
    @Id
    @Column(name = "VMS_FORM_PRRT_CD", nullable = false, length = 3)
    private String vmsFormPrrtCd;

    @ApiModelProperty("VMS FORM 우선순위")  // Y NUMBER(2)
    @Column(name = "VMS_FORM_PRRT", columnDefinition = "NUMBER", length = 2)
    private Integer vmsFormPrrt;

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

    @ApiModelProperty("VMS 용도 유형 코드")  // Y VARCHAR(7)
    @Column(name = "VMS_USAG_TYPE_CD", length = 7)
    private String vmsUsagTypeCd;

    public TbVmsFormPrrtDto toDto() {
        return TbVmsFormPrrtDto.builder()
                .vmsFormPrrtCd(this.vmsFormPrrtCd)
                .vmsFormPrrt(this.vmsFormPrrt)
                .vmsFormTypeCd(this.vmsFormTypeCd)
                .vmsUsagTypeCd(this.vmsUsagTypeCd)
                .build();
    }

    public TbVmsFormPrrt(String vmsFormPrrtCd) {
        this.vmsFormPrrtCd = vmsFormPrrtCd;
    }

    public void updateInfo(TbVmsFormPrrtDto.TbVmsFormPrrtUpdReq req) {
        this.vmsFormPrrt = req.getVmsFormPrrt();
        this.vmsFormTypeCd = req.getVmsFormTypeCd();
        this.vmsUsagTypeCd = req.getVmsUsagTypeCd();
    }

}
