package com.its.op.dto.its.vms;

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

/**
 * VMS_정보제공구간 소통 등급 DTO Class
 */
@Data
@Builder
@ApiModel("TbVmsIfscCmtrGradDto(VMS 정보제공구간 소통 등급)")
public class TbVmsIfscCmtrGradDto implements Serializable {
    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty("소통 등급 코드")  // N VARCHAR(7)
    @JsonProperty("cmtr_grad_cd")
    private String cmtrGradCd;

    @ApiModelProperty("최저속도")  // Y NUMBER(3)
    @JsonProperty("lwstsped")
    private Integer lwstsped;

    @ApiModelProperty("최고속도")  // Y NUMBER(3)
    @JsonProperty("hghssped")
    private Integer hghssped;

    // Code Description Field
    @ApiModelProperty("소통 등급 코드 설명")
    @JsonProperty("cmtr_grad_desc")    // CMTR_GRAD_CD
    private String cmtrGradDesc;

    @Getter
    @Setter
    @ToString
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class CmtrGrad {
        @ApiModelProperty("최저속도")  // Y NUMBER(3)
        @JsonProperty("lwstsped")
        @PositiveOrZero
        private Integer lwstsped;

        @ApiModelProperty("최고속도")  // Y NUMBER(3)
        @JsonProperty("hghssped")
        @PositiveOrZero
        private Integer hghssped;
    }

    @ApiModel("TbVmsIfscCmtrGradAllUpdReq(VMS 정보제공구간 소통등급 전체변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    @AllArgsConstructor
    @Builder
    public static class TbVmsIfscCmtrGradAllUpdReq {

        @ApiModelProperty("원활")
        @JsonProperty("grad1")
        private CmtrGrad grad1;

        @ApiModelProperty("지체")
        @JsonProperty("grad2")
        private CmtrGrad grad2;

        @ApiModelProperty("정체")
        @JsonProperty("grad3")
        private CmtrGrad grad3;

    }

    @ApiModel("TbVmsIfscCmtrGradUpdReq(VMS 정보제공구간 소통등급 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbVmsIfscCmtrGradUpdReq {

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

        @ApiModelProperty("소통 등급 코드, Nullable = N, VARCHAR(7)")  // N VARCHAR(7)
        @JsonProperty("cmtr_grad_cd")
        @Size(min=1, max=7)
        private String cmtrGradCd;

        @ApiModelProperty("최저속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("lwstsped")
        @PositiveOrZero
        private Integer lwstsped;

        @ApiModelProperty("최고속도, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
        @JsonProperty("hghssped")
        @PositiveOrZero
        private Integer hghssped;

        @Builder
        public TbVmsIfscCmtrGradUpdReq(Long vms_ifsc_id, String cmtr_grad_cd, Integer lwstsped, Integer hghssped) {
            this.vmsIfscId = vms_ifsc_id;
            this.cmtrGradCd = cmtr_grad_cd;
            this.lwstsped = lwstsped;
            this.hghssped = hghssped;
        }

        public TbVmsIfscCmtrGrad toEntity() {
            return TbVmsIfscCmtrGrad.builder()
                    .vmsIfscId(this.vmsIfscId)
                    .cmtrGradCd(this.cmtrGradCd)
                    .lwstsped(this.lwstsped)
                    .hghssped(this.hghssped)
                    .build();
        }

    }

}
