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

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

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

/**
 * RSE 제공 방향 정보 DTO Class
 */
@Data
@Builder
@ApiModel("TbRseOffrDrctDto(RSE 제공 방향 정보)")
public class TbRseOffrDrctDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @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;

    @ApiModelProperty("이전 RSE 제어기 번호")  // N NUMBER(10)
    @JsonProperty("pre_rse_ctlr_nmbr")
    private Long preRseCtlrNmbr;

    @ApiModelProperty("교차로 방향 개수")  // N NUMBER(1)
    @JsonProperty("ixr_drct_num")
    private Integer ixrDrctNum;

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

        @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;

        @ApiModelProperty("이전 RSE 제어기 번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("pre_rse_ctlr_nmbr")
        @PositiveOrZero
        private Long preRseCtlrNmbr;

        @ApiModelProperty("교차로 방향 개수, Nullable = N, NUMBER(1)")  // N NUMBER(1)
        @JsonProperty("ixr_drct_num")
        @PositiveOrZero
        private Integer ixrDrctNum;

        @Builder
        public TbRseOffrDrctUpdReq(Long rse_ctlr_nmbr, Integer obu_entr_drct_nmbr, Long pre_rse_ctlr_nmbr, Integer ixr_drct_num) {
            this.rseCtlrNmbr = rse_ctlr_nmbr;
            this.obuEntrDrctNmbr = obu_entr_drct_nmbr;
            this.preRseCtlrNmbr = pre_rse_ctlr_nmbr;
            this.ixrDrctNum = ixr_drct_num;
        }

        public TbRseOffrDrct toEntity() {
            return TbRseOffrDrct.builder()
                    .rseCtlrNmbr(this.rseCtlrNmbr)
                    .obuEntrDrctNmbr(this.obuEntrDrctNmbr)
                    .preRseCtlrNmbr(this.preRseCtlrNmbr)
                    .ixrDrctNum(this.ixrDrctNum)
                    .build();
        }

    }

}
