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

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

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

    @ApiModelProperty("방향 구분(01:북, 02:동, 03:남, 04:서, 05:북동, 06:남동, 07:남서, 08:북서)")  // N NUMBER(1)
    @JsonProperty("drct_dvsn_cd")
    private Integer drctDvsnCd;

    @ApiModelProperty("접근로 전체 차로 수")  // Y NUMBER(1)
    @JsonProperty("acrd_whol_lane_cnt")
    private Integer acrdWholLaneCnt;

    @ApiModelProperty("좌회전 형태")  // Y NUMBER(1)
    @JsonProperty("left_shpe")
    private Integer leftShpe;

    @ApiModelProperty("우회전 형태")  // Y NUMBER(1)
    @JsonProperty("rght_shpe")
    private Integer rghtShpe;

    @ApiModelProperty("좌회전 전용 차로 수")  // Y NUMBER(1)
    @JsonProperty("left_dvrs_lane_cnt")
    private Integer leftDvrsLaneCnt;

    @ApiModelProperty("직진 전용 차로 수")  // Y NUMBER(1)
    @JsonProperty("go_dvrs_lane_cnt")
    private Integer goDvrsLaneCnt;

    @ApiModelProperty("우회전 전용 차로 수")  // Y NUMBER(1)
    @JsonProperty("rght_dvrs_lane_cnt")
    private Integer rghtDvrsLaneCnt;

    @ApiModelProperty("좌회전 차로 수")  // Y NUMBER(1)
    @JsonProperty("left_lane_cnt")
    private Integer leftLaneCnt;

    @ApiModelProperty("우회전 차로 수")  // Y NUMBER(1)
    @JsonProperty("rght_lane_cnt")
    private Integer rghtLaneCnt;

    @ApiModelProperty("방향 X 좌표")  // Y VARCHAR2(20)
    @JsonProperty("drct_x_crdn")
    private String drctXCrdn;

    @ApiModelProperty("방향 Y 좌표")  // Y VARCHAR2(20)
    @JsonProperty("drct_y_crdn")
    private String drctYCrdn;

    @ApiModelProperty("비보호 좌회전")  // Y NUMBER(1)
    @JsonProperty("uprt_left")
    private Integer uprtLeft;

    @ApiModelProperty("옵셋")  // Y NUMBER(3)
    @JsonProperty("ofst")
    private Integer ofst;

    @ApiModelProperty("비보호 좌회전 차량 대수")  // Y NUMBER(4)
    @JsonProperty("uprt_left_vhcl_unum")
    private Integer uprtLeftVhclUnum;

    @ApiModelProperty("신호 운영 형태(0:양방향보호좌회전, 1:직좌동시신호, 2:비보호좌회전)")  // Y NUMBER(1)
    @JsonProperty("sgnl_oper_shpe")
    private Integer sgnlOperShpe;

    @ApiModelProperty("버스 전용 차로 수")  // Y NUMBER(1)
    @JsonProperty("bus_dvrs_lane_cnt")
    private Integer busDvrsLaneCnt;

    @ApiModelProperty("버스 전용 차로 유형")  // Y NUMBER(1)
    @JsonProperty("bus_dvrs_lane_type")
    private Integer busDvrsLaneType;

    // Code Description Field
    @ApiModelProperty("방향 구분(01:북, 02:동, 03:남, 04:서, 05:북동, 06:남동, 07:남서, 08:북서) 설명")
    @JsonProperty("drct_dvsn_desc")    // DRCT_DVSN_CD
    private String drctDvsnDesc;

    @ApiModel("TbScIxrGemtMngmUpdReq(교차로 기하구조 관리 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbScIxrGemtMngmUpdReq {

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

        @ApiModelProperty("방향 구분(01:북, 02:동, 03:남, 04:서, 05:북동, 06:남동, 07:남서, 08:북서), Nullable = N, NUMBER(1)")  // N NUMBER(1)
        @JsonProperty("drct_dvsn_cd")
        @PositiveOrZero
        private Integer drctDvsnCd;

        @ApiModelProperty("접근로 전체 차로 수, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("acrd_whol_lane_cnt")
        @PositiveOrZero
        private Integer acrdWholLaneCnt;

        @ApiModelProperty("좌회전 형태, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("left_shpe")
        @PositiveOrZero
        private Integer leftShpe;

        @ApiModelProperty("우회전 형태, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("rght_shpe")
        @PositiveOrZero
        private Integer rghtShpe;

        @ApiModelProperty("좌회전 전용 차로 수, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("left_dvrs_lane_cnt")
        @PositiveOrZero
        private Integer leftDvrsLaneCnt;

        @ApiModelProperty("직진 전용 차로 수, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("go_dvrs_lane_cnt")
        @PositiveOrZero
        private Integer goDvrsLaneCnt;

        @ApiModelProperty("우회전 전용 차로 수, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("rght_dvrs_lane_cnt")
        @PositiveOrZero
        private Integer rghtDvrsLaneCnt;

        @ApiModelProperty("좌회전 차로 수, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("left_lane_cnt")
        @PositiveOrZero
        private Integer leftLaneCnt;

        @ApiModelProperty("우회전 차로 수, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("rght_lane_cnt")
        @PositiveOrZero
        private Integer rghtLaneCnt;

        @ApiModelProperty("방향 X 좌표, Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("drct_x_crdn")
        @Size(min=1, max=20)
        private String drctXCrdn;

        @ApiModelProperty("방향 Y 좌표, Nullable = Y, VARCHAR2(20)")  // Y VARCHAR2(20)
        @JsonProperty("drct_y_crdn")
        @Size(min=1, max=20)
        private String drctYCrdn;

        @ApiModelProperty("비보호 좌회전, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("uprt_left")
        @PositiveOrZero
        private Integer uprtLeft;

        @ApiModelProperty("옵셋, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("ofst")
        @PositiveOrZero
        private Integer ofst;

        @ApiModelProperty("비보호 좌회전 차량 대수, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("uprt_left_vhcl_unum")
        @PositiveOrZero
        private Integer uprtLeftVhclUnum;

        @ApiModelProperty("신호 운영 형태(0:양방향보호좌회전, 1:직좌동시신호, 2:비보호좌회전), Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("sgnl_oper_shpe")
        @PositiveOrZero
        private Integer sgnlOperShpe;

        @ApiModelProperty("버스 전용 차로 수, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("bus_dvrs_lane_cnt")
        @PositiveOrZero
        private Integer busDvrsLaneCnt;

        @ApiModelProperty("버스 전용 차로 유형, Nullable = Y, NUMBER(1)")  // Y NUMBER(1)
        @JsonProperty("bus_dvrs_lane_type")
        @PositiveOrZero
        private Integer busDvrsLaneType;

        @Builder
        public TbScIxrGemtMngmUpdReq(String ixr_id, Integer drct_dvsn_cd, Integer acrd_whol_lane_cnt, Integer left_shpe, Integer rght_shpe, Integer left_dvrs_lane_cnt, Integer go_dvrs_lane_cnt, Integer rght_dvrs_lane_cnt, Integer left_lane_cnt, Integer rght_lane_cnt, String drct_x_crdn, String drct_y_crdn, Integer uprt_left, Integer ofst, Integer uprt_left_vhcl_unum, Integer sgnl_oper_shpe, Integer bus_dvrs_lane_cnt, Integer bus_dvrs_lane_type) {
            this.ixrId = ixr_id;
            this.drctDvsnCd = drct_dvsn_cd;
            this.acrdWholLaneCnt = acrd_whol_lane_cnt;
            this.leftShpe = left_shpe;
            this.rghtShpe = rght_shpe;
            this.leftDvrsLaneCnt = left_dvrs_lane_cnt;
            this.goDvrsLaneCnt = go_dvrs_lane_cnt;
            this.rghtDvrsLaneCnt = rght_dvrs_lane_cnt;
            this.leftLaneCnt = left_lane_cnt;
            this.rghtLaneCnt = rght_lane_cnt;
            this.drctXCrdn = drct_x_crdn;
            this.drctYCrdn = drct_y_crdn;
            this.uprtLeft = uprt_left;
            this.ofst = ofst;
            this.uprtLeftVhclUnum = uprt_left_vhcl_unum;
            this.sgnlOperShpe = sgnl_oper_shpe;
            this.busDvrsLaneCnt = bus_dvrs_lane_cnt;
            this.busDvrsLaneType = bus_dvrs_lane_type;
        }

        public TbScIxrGemtMngm toEntity() {
            return TbScIxrGemtMngm.builder()
                    .ixrId(this.ixrId)
                    .drctDvsnCd(this.drctDvsnCd)
                    .acrdWholLaneCnt(this.acrdWholLaneCnt)
                    .leftShpe(this.leftShpe)
                    .rghtShpe(this.rghtShpe)
                    .leftDvrsLaneCnt(this.leftDvrsLaneCnt)
                    .goDvrsLaneCnt(this.goDvrsLaneCnt)
                    .rghtDvrsLaneCnt(this.rghtDvrsLaneCnt)
                    .leftLaneCnt(this.leftLaneCnt)
                    .rghtLaneCnt(this.rghtLaneCnt)
                    .drctXCrdn(this.drctXCrdn)
                    .drctYCrdn(this.drctYCrdn)
                    .uprtLeft(this.uprtLeft)
                    .ofst(this.ofst)
                    .uprtLeftVhclUnum(this.uprtLeftVhclUnum)
                    .sgnlOperShpe(this.sgnlOperShpe)
                    .busDvrsLaneCnt(this.busDvrsLaneCnt)
                    .busDvrsLaneType(this.busDvrsLaneType)
                    .build();
        }

    }

}
