package com.its.op.dto.its.rse;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.rse.TbRseSectTraf;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.PositiveOrZero;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * RSE 구간 소통상황 DTO Class
 */
@Data
@Builder
@ApiModel("TbRseSectTrafDto(RSE 구간 소통상황)")
public class TbRseSectTrafDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("RSE 구간 아이디")  // N NUMBER(10)
    @JsonProperty("rse_sect_id")
    private Long rseSectId;

    @ApiModelProperty("가공 일시")  // N VARCHAR2(14)
    @JsonProperty("prcn_dt")
    private String prcnDt;

    @ApiModelProperty("교통량")  // Y NUMBER(6)
    @JsonProperty("tfvl")
    private Integer tfvl;

    @ApiModelProperty("통행 속도")  // Y NUMBER(3)
    @JsonProperty("trvl_sped")
    private Integer trvlSped;

    @ApiModelProperty("통행 시간")  // Y NUMBER(6)
    @JsonProperty("trvl_hh")
    private Integer trvlHh;

    // Code Description Field
    @ApiModel("TbRseSectTrafUpdReq(RSE 구간 소통상황 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbRseSectTrafUpdReq {

        @ApiModelProperty("RSE 구간 아이디, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("rse_sect_id")
        @PositiveOrZero
        private Long rseSectId;

        @ApiModelProperty("가공 일시, Nullable = N, VARCHAR2(14)")  // N VARCHAR2(14)
        @JsonProperty("prcn_dt")
        @Size(min=1, max=14)
        private String prcnDt;

        @ApiModelProperty("교통량, Nullable = Y, NUMBER(6)")  // Y NUMBER(6)
        @JsonProperty("tfvl")
        @PositiveOrZero
        private Integer tfvl;

        @ApiModelProperty("통행 속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("trvl_sped")
        @PositiveOrZero
        private Integer trvlSped;

        @ApiModelProperty("통행 시간, Nullable = Y, NUMBER(6)")  // Y NUMBER(6)
        @JsonProperty("trvl_hh")
        @PositiveOrZero
        private Integer trvlHh;

        @Builder
        public TbRseSectTrafUpdReq(Long rse_sect_id, String prcn_dt, Integer tfvl, Integer trvl_sped, Integer trvl_hh) {
            this.rseSectId = rse_sect_id;
            this.prcnDt = prcn_dt;
            this.tfvl = tfvl;
            this.trvlSped = trvl_sped;
            this.trvlHh = trvl_hh;
        }

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

    }

}
