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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.api.its.model.entity.road.TbRoadIfscRltn;
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("TbRoadIfscRltnDto(도로 정보제공구간 관계)")
public class TbRoadIfscRltnDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("도로 ID")  // N NUMBER(10)
    @JsonProperty("road_id")
    private Long roadId;

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

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


    @ApiModelProperty("방향 코드")  // Y VARCHAR(7)
    @JsonProperty("drct_cd")
    private String drctCd;

    @ApiModelProperty("구간 길이")  // Y NUMBER(5)
    @JsonProperty("sect_lngt")
    private Integer sectLngt;

    @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 VARCHAR(7)
    @JsonProperty("sect_grad_cd")
    private String sectGradCd;

    @ApiModelProperty("정보제공구간 명")  // Y VARCHAR(100)
    @JsonProperty("ifsc_nm")
    private String ifscNm;

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

    @ApiModelProperty("방향 코드 설명")
    @JsonProperty("drct_desc")    // DRCT_CD
    private String drctDesc;

    @ApiModelProperty("구간 등급 코드 설명")
    @JsonProperty("sect_grad_desc")    // SECT_GRAD_CD
    private String sectGradDesc;


    @ApiModel("TbRoadIfscRltnUpdReq(도로 정보제공구간 관계 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor(access = AccessLevel.PROTECTED)
    public static class TbRoadIfscRltnUpdReq {

        /*@ApiModelProperty("도로 ID, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("road_id")
        @PositiveOrZero
        private Long roadId;*/

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

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

        @Builder
        public TbRoadIfscRltnUpdReq(Long ifsc_id, Integer ord) {
            this.ifscId = ifsc_id;
            this.ord = ord;
        }

        public TbRoadIfscRltn toEntity(Long roadId) {
            return TbRoadIfscRltn.builder()
                    .roadId(roadId)
                    .ifscId(this.ifscId)
                    .ord(this.ord)
                    .build();
        }

    }

}
