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

import com.its.op.dto.its.vms.TbVmsIfscDto;
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;
import java.util.ArrayList;

/**
 * VMS 정보제공구간 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("VMS 정보제공구간")
@Entity
@Table(name = "TB_VMS_IFSC")
public class TbVmsIfsc 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("VMS 정보제공구간 명")  // Y VARCHAR(60)
    @Column(name = "VMS_IFSC_NM", length = 60)
    private String vmsIfscNm;

    @ApiModelProperty("표출 시작 노드 명")  // Y VARCHAR(30)
    @Column(name = "DSPL_STRT_NODE_NM", length = 30)
    private String dsplStrtNodeNm;

    @ApiModelProperty("표출 종료 노드 명")  // Y VARCHAR(30)
    @Column(name = "DSPL_END_NODE_NM", length = 30)
    private String dsplEndNodeNm;

    @ApiModelProperty("우회도로 ID")  // Y NUMBER(10)
    @Column(name = "DETR_ID", columnDefinition = "NUMBER", length = 10)
    private Long detrId;

    @ApiModelProperty("도로명")  // Y VARCHAR(30)
    @Column(name = "ROAD_NM", length = 30)
    private String roadNm;

    @ApiModelProperty("지점명")  // Y VARCHAR(30)
    @Column(name = "SPOT_NM", length = 30)
    private String spotNm;

    @ApiModelProperty("축정보 생성용")  // Y CHAR(1)
    @Column(name = "AXIS_YN", columnDefinition = "CHAR", length = 1)
    private String axisYn;

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

    @ApiModelProperty("정체폼생성시 정체판정기준속도")  // Y NUMBER(3)
    @Column(name = "CNGS_SPD", columnDefinition = "NUMBER", length = 3)
    private Integer cngsSpd;

    public TbVmsIfscDto toDto() {
        return TbVmsIfscDto.builder()
                .vmsIfscId(this.vmsIfscId)
                .vmsIfscNm(this.vmsIfscNm)
                .dsplStrtNodeNm(this.dsplStrtNodeNm)
                .dsplEndNodeNm(this.dsplEndNodeNm)
                .detrId(this.detrId)
                .axisYn(this.axisYn)
                .roadNm(this.roadNm)
                .spotNm(this.spotNm)
                .useYn(this.useYn)
                .cngsSpd(this.cngsSpd)
                .build();
    }

    public TbVmsIfsc(Long vmsIfscId) {
        this.vmsIfscId = vmsIfscId;
    }

    public void updateInfo(TbVmsIfscDto.TbVmsIfscUpdReq req) {
        this.vmsIfscNm = req.getVmsIfscNm();
        this.dsplStrtNodeNm = req.getDsplStrtNodeNm();
        this.dsplEndNodeNm = req.getDsplEndNodeNm();
        this.detrId = req.getDetrId();
        this.axisYn = req.getAxisYn();
        this.roadNm = req.getRoadNm();
        this.spotNm = req.getSpotNm();
        this.useYn = req.getUseYn();
        this.cngsSpd = req.getCngsSpd();
    }

}
