package com.its.op.dto.its.rse;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.its.op.entity.its.rse.TbRseOffrSect;
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;

/**
 * RSE 제공 구간 DTO Class
 */
@Data
@Builder
@ApiModel("TbRseOffrSectDto(RSE 제공 구간)")
public class TbRseOffrSectDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("제공 구간 아이디")  // N NUMBER(10)
    @JsonProperty("offr_sect_id")
    private Long offrSectId;

    @ApiModelProperty("제공 방향 명")  // Y VARCHAR2(30)
    @JsonProperty("offr_drct_nm")
    private String offrDrctNm;

    @ApiModelProperty("정체 기준 속도")  // Y NUMBER(3)
    @JsonProperty("cngs_basi_sped")
    private Integer cngsBasiSped;

    @ApiModelProperty("지체 기준 속도")  // Y NUMBER(3)
    @JsonProperty("dely_basi_sped")
    private Integer delyBasiSped;

    @ApiModelProperty("RSE 제어기 번호")  // N NUMBER(10)
    @JsonProperty("rse_ctlr_nmbr")
    private Long rseCtlrNmbr;

    @ApiModelProperty("OBU 진입 방향 번호")  // N NUMBER(1)
    @JsonProperty("obu_entr_drct_nmbr")
    private Integer obuEntrDrctNmbr;

    // Code Description Field
    @ApiModel("TbRseOffrSectUpdReq(RSE 제공 구간 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbRseOffrSectUpdReq {

        @ApiModelProperty("제공 구간 아이디, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("offr_sect_id")
        @PositiveOrZero
        private Long offrSectId;

        @ApiModelProperty("제공 방향 명, Nullable = Y, VARCHAR2(30)")  // Y VARCHAR2(30)
        @JsonProperty("offr_drct_nm")
        @Size(min=1, max=30)
        private String offrDrctNm;

        @ApiModelProperty("정체 기준 속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("cngs_basi_sped")
        @PositiveOrZero
        private Integer cngsBasiSped;

        @ApiModelProperty("지체 기준 속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("dely_basi_sped")
        @PositiveOrZero
        private Integer delyBasiSped;

        @ApiModelProperty("RSE 제어기 번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("rse_ctlr_nmbr")
        @PositiveOrZero
        private Long rseCtlrNmbr;

        @ApiModelProperty("OBU 진입 방향 번호, Nullable = N, NUMBER(1)")  // N NUMBER(1)
        @JsonProperty("obu_entr_drct_nmbr")
        @PositiveOrZero
        private Integer obuEntrDrctNmbr;

        @Builder
        public TbRseOffrSectUpdReq(Long offr_sect_id, String offr_drct_nm, Integer cngs_basi_sped, Integer dely_basi_sped, Long rse_ctlr_nmbr, Integer obu_entr_drct_nmbr) {
            this.offrSectId = offr_sect_id;
            this.offrDrctNm = offr_drct_nm;
            this.cngsBasiSped = cngs_basi_sped;
            this.delyBasiSped = dely_basi_sped;
            this.rseCtlrNmbr = rse_ctlr_nmbr;
            this.obuEntrDrctNmbr = obu_entr_drct_nmbr;
        }

        public TbRseOffrSect toEntity() {
            return TbRseOffrSect.builder()
                    .offrSectId(this.offrSectId)
                    .offrDrctNm(this.offrDrctNm)
                    .cngsBasiSped(this.cngsBasiSped)
                    .delyBasiSped(this.delyBasiSped)
                    .rseCtlrNmbr(this.rseCtlrNmbr)
                    .obuEntrDrctNmbr(this.obuEntrDrctNmbr)
                    .build();
        }

    }

}
