package com.its.op.dto.its.vds;

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

/**
 * VDS 검지기 링크 관계 DTO Class
 */
@Data
@Builder
@ApiModel("TbVdsDtctRltnLinkDto(VDS 검지기 링크 관계)")
public class TbVdsDtctRltnLinkDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("VDS 검지기 번호")  // N NUMBER(10)
    @JsonProperty("vds_dtct_nmbr")
    private Long vdsDtctNmbr;

    @ApiModelProperty("링크ID")  // N NUMBER(10)
    @JsonProperty("link_id")
    private Long linkId;

    // Code Description Field
    @ApiModel("TbVdsDtctLinkRltnUpdReq(VDS 검지기 링크 관계 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbVdsDtctLinkRltnUpdReq {

        @ApiModelProperty("검지기 번호, Nullable = N, VARCHAR(8)")  // N VARCHAR(8)
        @JsonProperty("dtct_nmbr")
        @Size(min=1, max=8)
        private Long vdsDtctNmbr;

        @ApiModelProperty("링크ID, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("link_id")
        @PositiveOrZero
        private Long linkId;

        @Builder
        public TbVdsDtctLinkRltnUpdReq(Long vdsDtctNmbr, Long link_id) {
            this.vdsDtctNmbr = vdsDtctNmbr;
            this.linkId = link_id;
        }

        public TbVdsDtctLinkRltn toEntity() {
            return TbVdsDtctLinkRltn.builder()
                    .vdsDtctNmbr(this.vdsDtctNmbr)
                    .linkId(this.linkId)
                    .build();
        }

    }

}
