package com.its.op.dto.its.scrs;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.scrs.TbScIxrMngm;
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("TbScIxrMngmDto(교차로 관리)")
public class TbScIxrMngmDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("교차로 ID")  // N VARCHAR2(10)
    @JsonProperty("ixr_id")
    private String ixrId;

    @ApiModelProperty("교차로 명")  // Y VARCHAR2(50)
    @JsonProperty("ixr_nm")
    private String ixrNm;

    @ApiModelProperty("현시 수")  // Y NUMBER(1)
    @JsonProperty("phas_cnt")
    private Integer phasCnt;

    @ApiModelProperty("지점 특성")  // Y VARCHAR2(20)
    @JsonProperty("spot_fetr")
    private String spotFetr;

    @ApiModelProperty("교차로 X 좌표")  // Y VARCHAR2(20)
    @JsonProperty("ixr_x_crdn")
    private String ixrXCrdn;

    @ApiModelProperty("교차로 Y 좌표")  // Y VARCHAR2(20)
    @JsonProperty("ixr_y_crdn")
    private String ixrYCrdn;

    @ApiModelProperty("교차로 유형")  // Y NUMBER(1)
    @JsonProperty("ixr_type")
    private Integer ixrType;

    @ApiModelProperty("구분")  // Y NUMBER(1)
    @JsonProperty("dvsn")
    private Integer dvsn;

    @ApiModelProperty("사용 유무")  // Y NUMBER(1)
    @JsonProperty("use_en")
    private Integer useEn;

    @ApiModelProperty("노드ID")  // N NUMBER(10)
    @JsonProperty("node_id")
    private Long nodeId;

    // Code Description Field
    @ApiModel("TbScIxrMngmUpdReq(교차로 관리 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbScIxrMngmUpdReq {

        @ApiModelProperty("교차로 ID, Nullable = N, VARCHAR2(10)")  // N VARCHAR2(10)
        @JsonProperty("ixr_id")
        @Size(min=1, max=10)
        private String ixrId;

        @ApiModelProperty("교차로 명, Nullable = Y, VARCHAR2(50)")  // Y VARCHAR2(50)
        @JsonProperty("ixr_nm")
        @Size(min=1, max=50)
        private String ixrNm;

        @ApiModelProperty("현시 수, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("phas_cnt")
        @PositiveOrZero
        private Integer phasCnt;

        @ApiModelProperty("지점 특성, Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("spot_fetr")
        @Size(min=1, max=20)
        private String spotFetr;

        @ApiModelProperty("교차로 X 좌표, Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("ixr_x_crdn")
        @Size(min=1, max=20)
        private String ixrXCrdn;

        @ApiModelProperty("교차로 Y 좌표, Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("ixr_y_crdn")
        @Size(min=1, max=20)
        private String ixrYCrdn;

        @ApiModelProperty("교차로 유형, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("ixr_type")
        @PositiveOrZero
        private Integer ixrType;

        @ApiModelProperty("구분, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("dvsn")
        @PositiveOrZero
        private Integer dvsn;

        @ApiModelProperty("사용 유무, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("use_en")
        @PositiveOrZero
        private Integer useEn;

        @ApiModelProperty("노드ID, Nullable = Y, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("node_id")
        @PositiveOrZero
        private Long nodeId;

        @Builder
        public TbScIxrMngmUpdReq(String ixr_id, String ixr_nm, Integer phas_cnt, String spot_fetr, String ixr_x_crdn, String ixr_y_crdn, Integer ixr_type, Integer dvsn, Integer use_en, Long node_id) {
            this.ixrId = ixr_id;
            this.ixrNm = ixr_nm;
            this.phasCnt = phas_cnt;
            this.spotFetr = spot_fetr;
            this.ixrXCrdn = ixr_x_crdn;
            this.ixrYCrdn = ixr_y_crdn;
            this.ixrType = ixr_type;
            this.dvsn = dvsn;
            this.useEn = use_en;
            this.nodeId = node_id;
        }

        public TbScIxrMngm toEntity() {
            return TbScIxrMngm.builder()
                    .ixrId(this.ixrId)
                    .ixrNm(this.ixrNm)
                    .phasCnt(this.phasCnt)
                    .spotFetr(this.spotFetr)
                    .ixrXCrdn(this.ixrXCrdn)
                    .ixrYCrdn(this.ixrYCrdn)
                    .ixrType(this.ixrType)
                    .dvsn(this.dvsn)
                    .useEn(this.useEn)
                    .nodeId(this.nodeId)
                    .build();
        }

    }

}
