package com.its.op.entity.its.rse;

import com.its.op.dto.its.rse.TbRseSectTrafDto;
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.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * RSE 구간 소통상황 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("RSE 구간 소통상황")
@Entity
@Table(name = "TB_RSE_SECT_TRAF")
public class TbRseSectTraf implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("RSE 구간 아이디")  // N NUMBER(10)
    @Id
    @Column(name = "RSE_SECT_ID", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long rseSectId;

    @ApiModelProperty("가공 일시")  // N VARCHAR2(14)
    @Column(name = "PRCN_DT", nullable = false, length = 14)
    private String prcnDt;

    @ApiModelProperty("교통량")  // Y NUMBER(6)
    @Column(name = "TFVL", columnDefinition = "NUMBER", length = 6)
    private Integer tfvl;

    @ApiModelProperty("통행 속도")  // Y NUMBER(3)
    @Column(name = "TRVL_SPED", columnDefinition = "NUMBER", length = 3)
    private Integer trvlSped;

    @ApiModelProperty("통행 시간")  // Y NUMBER(6)
    @Column(name = "TRVL_HH", columnDefinition = "NUMBER", length = 6)
    private Integer trvlHh;

    public TbRseSectTrafDto toDto() {
        return TbRseSectTrafDto.builder()
                .rseSectId(this.rseSectId)
                .prcnDt(this.prcnDt)
                .tfvl(this.tfvl)
                .trvlSped(this.trvlSped)
                .trvlHh(this.trvlHh)
                .build();
    }

    public TbRseSectTraf(Long rseSectId) {
        this.rseSectId = rseSectId;
    }

    public void updateInfo(TbRseSectTrafDto.TbRseSectTrafUpdReq req) {
        this.prcnDt = req.getPrcnDt();
        this.tfvl = req.getTfvl();
        this.trvlSped = req.getTrvlSped();
        this.trvlHh = req.getTrvlHh();
    }

}
