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

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

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

/**
 * 소속 교차로 관리 DTO Class
 */
@Data
@Builder
@ApiModel("TbScPstnIxrMngmDto(소속 교차로 관리)")
public class TbScPstnIxrMngmDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("교차로 그룹")  // N NUMBER(3)
    @JsonProperty("ixr_grop")
    private Integer ixrGrop;

    @ApiModelProperty("일련번호")  // N NUMBER(2)
    @JsonProperty("seq")
    private Integer seq;

    @ApiModelProperty("소속 교차로 번호")  // Y NUMBER(4)
    @JsonProperty("pstn_ixr_nmbr")
    private Integer pstnIxrNmbr;

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

        @ApiModelProperty("교차로 그룹, Nullable = N, NUMBER(3)")  // N NUMBER(3)
        @JsonProperty("ixr_grop")
        @PositiveOrZero
        private Integer ixrGrop;

        @ApiModelProperty("일련번호, Nullable = N, NUMBER(2)")  // N NUMBER(2)
        @JsonProperty("seq")
        @PositiveOrZero
        private Integer seq;

        @ApiModelProperty("소속 교차로 번호, Nullable = Y, NUMBER(4)")  // Y NUMBER(4)
        @JsonProperty("pstn_ixr_nmbr")
        @PositiveOrZero
        private Integer pstnIxrNmbr;

        @Builder
        public TbScPstnIxrMngmUpdReq(Integer ixr_grop, Integer seq, Integer pstn_ixr_nmbr) {
            this.ixrGrop = ixr_grop;
            this.seq = seq;
            this.pstnIxrNmbr = pstn_ixr_nmbr;
        }

        public TbScPstnIxrMngm toEntity() {
            return TbScPstnIxrMngm.builder()
                    .ixrGrop(this.ixrGrop)
                    .seq(this.seq)
                    .pstnIxrNmbr(this.pstnIxrNmbr)
                    .build();
        }

    }

}
