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

import com.its.op.dto.its.vms.TbVmsDsplPrrtDto;
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;

/**
 * VMS FORM 표출 우선순위 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("VMS FORM 표출 우선순위")
@Entity
@Table(name = "TB_VMS_DSPL_PRRT")
@IdClass(TbVmsDsplPrrtKey.class)
public class TbVmsDsplPrrt implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VMS 스케줄 유형(A:자동,F:고정,B:기본)")  // N VARCHAR2(5)
    @Id
    @Column(name = "VMS_SCH_TYPE", nullable = false, length = 5)
    private String vmsSchType;

    @ApiModelProperty("VMS 폼 스케쥴 유형(0:교통,1:돌발,2:공사행사,3:홍보,4:우회,5:정체,6:안전,7:동영상,8:스트리밍영상)")  // N NUMBER(3)
    @Id
    @Column(name = "VMS_SCH_FORM_TYPE", nullable = false, columnDefinition = "NUMBER", length = 3)
    private Integer vmsSchFormType;

    @ApiModelProperty("VMS FORM 표출 우선순위(낮을수록 우선순위가 높음)")  // Y NUMBER(2)
    @Column(name = "VMS_DSPL_PRRT", columnDefinition = "NUMBER", length = 2)
    private Integer vmsDsplPrrt;

    public TbVmsDsplPrrtDto toDto() {
        return TbVmsDsplPrrtDto.builder()
                .vmsSchType(this.vmsSchType)
                .vmsSchFormType(this.vmsSchFormType)
                .vmsDsplPrrt(this.vmsDsplPrrt)
                .build();
    }

    public TbVmsDsplPrrt(String vmsSchType, Integer vmsSchFormType) {
        this.vmsSchType = vmsSchType;
        this.vmsSchFormType = vmsSchFormType;
    }

    public void updateInfo(TbVmsDsplPrrtDto.TbVmsDsplPrrtUpdReq req) {
        this.vmsDsplPrrt = req.getVmsDsplPrrt();
    }

}
