package com.its.api.its.model.dto.link;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.link.TbLinkSyopTraf;
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;

/**
 * 링크 운영자 소통상황 DTO Class
 */
@Data
@Builder
@ApiModel("TbLinkSyopTrafDto(링크 운영자 소통상황)")
public class TbLinkSyopTrafDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("링크ID")  // N NUMBER(10)
    @JsonProperty("link_id")
    private Long linkId;

    @ApiModelProperty("생성 일시")  // N VARCHAR(14)
    @JsonProperty("crtn_dt")
    private String crtnDt;

    @ApiModelProperty("적용 시작 일시")  // Y VARCHAR(14)
    @JsonProperty("aply_strt_dt")
    private String aplyStrtDt;

    @ApiModelProperty("적용 종료 일시")  // Y VARCHAR(14)
    @JsonProperty("aply_end_dt")
    private String aplyEndDt;

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

    @ApiModelProperty("속도")  // Y NUMBER(3)
    @JsonProperty("sped")
    private Integer sped;

    @ApiModelProperty("점유 율")  // Y NUMBER(5,2)
    @JsonProperty("ocpy_rate")
    private Double ocpyRate;

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

    // Code Description Field
    @ApiModelProperty("도로명")  // Y VARCHAR(50)
    @JsonProperty("road_name")
    private String roadName;

    @ApiModelProperty("시작노드")
    @JsonProperty("from_node")
    private String fromNodeInfo;
    @ApiModelProperty("종료노드")
    @JsonProperty("to_node")
    private String toNodeInfo;

    @ApiModel("TbLinkSyopTrafUpdReq(링크 운영자 소통상황 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbLinkSyopTrafUpdReq {

        @ApiModelProperty("링크ID, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("link_id")
        @PositiveOrZero
        private Long linkId;

        @ApiModelProperty("생성 일시, Nullable = N, VARCHAR(14)")  // N VARCHAR(14)
        @JsonProperty("crtn_dt")
        @Size(min=1, max=14)
        private String crtnDt;

        @ApiModelProperty("적용 시작 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("aply_strt_dt")
        @Size(min=1, max=14)
        private String aplyStrtDt;

        @ApiModelProperty("적용 종료 일시, Nullable = Y, VARCHAR(14)")  // Y VARCHAR(14)
        @JsonProperty("aply_end_dt")
        @Size(min=1, max=14)
        private String aplyEndDt;

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

        @ApiModelProperty("속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("sped")
        @PositiveOrZero
        private Integer sped;

        @ApiModelProperty("점유 율, , NUMBER(5,2)")  // Y NUMBER(5,2)
        @JsonProperty("ocpy_rate")
        private Double ocpyRate;

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

        @Builder
        public TbLinkSyopTrafUpdReq(Long link_id, String crtn_dt, String aply_strt_dt, String aply_end_dt, Integer tfvl, Integer sped, Double ocpy_rate, Integer trvl_hh) {
            this.linkId = link_id;
            this.crtnDt = crtn_dt;
            this.aplyStrtDt = aply_strt_dt;
            this.aplyEndDt = aply_end_dt;
            this.tfvl = tfvl;
            this.sped = sped;
            this.ocpyRate = ocpy_rate;
            this.trvlHh = trvl_hh;
        }

        public TbLinkSyopTraf toEntity() {
            return TbLinkSyopTraf.builder()
                    .linkId(this.linkId)
                    .crtnDt(this.crtnDt)
                    .aplyStrtDt(this.aplyStrtDt)
                    .aplyEndDt(this.aplyEndDt)
                    .tfvl(this.tfvl)
                    .sped(this.sped)
                    .ocpyRate(this.ocpyRate)
                    .trvlHh(this.trvlHh)
                    .build();
        }

    }

}
