package com.its.op.dto.its.ifsc;

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

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

/**
 * 정보제공구간 링크 관계 DTO Class
 */
@Data
@Builder
@ApiModel("TbIfscLinkRltnDto(정보제공구간 링크 관계)")
public class TbIfscLinkRltnDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("정보제공구간 ID")  // N NUMBER(10)
    @JsonProperty("ifsc_id")
    private Long ifscId;

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

    @ApiModelProperty("순서")  // Y NUMBER(3)
    @JsonProperty("ord")
    private Integer ord;

    @ApiModelProperty("시작노드ID")  // Y NUMBER(10)
    @JsonProperty("f_node_id")
    private Long fNodeId;

    @ApiModelProperty("종료노드ID")  // Y NUMBER(10)
    @JsonProperty("t_node_id")
    private Long tNodeId;

    @ApiModelProperty("차로수")  // Y NUMBER(4)
    @JsonProperty("lanes")
    private Integer lanes;

    @ApiModelProperty("도로등급")  // Y VARCHAR(3)
    @JsonProperty("road_rank")
    private String roadRank;

    @ApiModelProperty("도로유형")  // Y VARCHAR(3)
    @JsonProperty("road_type")
    private String roadType;

    @ApiModelProperty("도로번호")  // Y VARCHAR(5)
    @JsonProperty("road_no")
    private String roadNo;

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

    @ApiModelProperty("연장")  // Y NUMBER(5)
    @JsonProperty("link_leng")
    private Integer linkLeng;

    @ApiModelProperty("구간 등급 코드")  // Y VARCHAR(7)
    @JsonProperty("sect_grad_cd")
    private String sectGradCd;

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

    @ApiModelProperty("도로등급 설명")
    @JsonProperty("road_rank_desc")
    private String roadRankDesc;
    @ApiModelProperty("도로유형 설명")
    @JsonProperty("road_type_desc")
    private String roadTypeDesc;
    @ApiModelProperty("구간 등급 코드 설명")
    @JsonProperty("sect_grad_desc")
    private String sectGradDesc;

    // Code Description Field
    @ApiModel("TbIfscLinkRltnUpdReq(정보제공구간 링크 관계 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbIfscLinkRltnUpdReq {
/*
        @ApiModelProperty("정보제공구간 ID, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("ifsc_id")
        @PositiveOrZero
        private Long ifscId;*/

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

        @ApiModelProperty("순서, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("ord")
        @PositiveOrZero
        private Integer ord;

        @Builder
        public TbIfscLinkRltnUpdReq(Long link_id, Integer ord) {
            this.linkId = link_id;
            this.ord = ord;
        }

        public TbIfscRltnLink toEntity(Long ifscId) {
            return TbIfscRltnLink.builder()
                    .ifscId(ifscId)
                    .linkId(this.linkId)
                    .ord(this.ord)
                    .build();
        }

    }

}
