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

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

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

/**
 * VMS_정보제공구간 소통 등급 Entity Class
 */
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("VMS_정보제공구간 소통 등급")
@Entity
@Table(name = "TB_VMS_IFSC_CMTR_GRAD")
@IdClass(TbVmsIfscCmtrGradKey.class)
public class TbVmsIfscCmtrGrad implements Serializable {
    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("소통 등급 코드")  // N VARCHAR(7)
    @Id
    @Column(name = "CMTR_GRAD_CD", nullable = false, length = 7)
    private String cmtrGradCd;

    @ApiModelProperty("최저속도")  // Y NUMBER(3)
    @Column(name = "LWSTSPED", columnDefinition = "NUMBER", length = 3)
    private Integer lwstsped;

    @ApiModelProperty("최고속도")  // Y NUMBER(3)
    @Column(name = "HGHSSPED", columnDefinition = "NUMBER", length = 3)
    private Integer hghssped;

    public TbVmsIfscCmtrGradDto toDto() {
        return TbVmsIfscCmtrGradDto.builder()
                .vmsIfscId(this.vmsIfscId)
                .cmtrGradCd(this.cmtrGradCd)
                .lwstsped(this.lwstsped)
                .hghssped(this.hghssped)
                .build();
    }

    public TbVmsIfscCmtrGrad(Long vmsIfscId, String cmtrGradCd) {
        this.vmsIfscId = vmsIfscId;
        this.cmtrGradCd = cmtrGradCd;
    }

    public void updateInfo(TbVmsIfscCmtrGradDto.TbVmsIfscCmtrGradUpdReq req) {
        this.lwstsped = req.getLwstsped();
        this.hghssped = req.getHghssped();
    }

}
