package com.its.op.dto.its.facility;

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

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

/**
 * 시설물 정보 DTO Class
 */
@Data
@Builder
@ApiModel("UnRegisteredFcltInfrDto(미등록 시설물 정보)")
public class UnRegisteredFcltInfrDto implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("시설물 ID")  // N VARCHAR(50)
    @JsonProperty("fclt_id")
    private String fcltId;

    @ApiModelProperty("시설물 유형")  // Y VARCHAR(7)
    @JsonProperty("fclt_type")
    private String fcltType;

    @ApiModelProperty("시설물 위치")  // Y VARCHAR(100)
    @JsonProperty("fclt_lctn")
    private String fcltLctn;

    @ApiModel("TbRegFcltInfrUpdReq(시설물 정보 정보변경)")
    @Getter
    @Setter
    @ToString
    @NoArgsConstructor//(access = AccessLevel.PROTECTED)
    public static class TbRegFcltInfrUpdReq {

        @ApiModelProperty("시설물 ID, Nullable = N, VARCHAR(50)")  // N VARCHAR(50)
        @JsonProperty("fclt_id")
        @Size(min=1, max=50)
        private String fcltId;

        @ApiModelProperty("시설물 유형, Nullable = Y, VARCHAR(7)")  // Y VARCHAR(7)
        @JsonProperty("fclt_type")
        @Size(min=1, max=7)
        private String fcltType;

        @ApiModelProperty("시설물 위치, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
        @JsonProperty("fclt_lctn")
        @Size(min=1, max=100)
        private String fcltLctn;

        @Builder
        public TbRegFcltInfrUpdReq(String fclt_id, String fclt_type, String fclt_lctn) {
            this.fcltId = fclt_id;
            this.fcltType = fclt_type;
            this.fcltLctn = fclt_lctn;
        }

        public TbFcltInfr toEntity(Long fcltNmbr) {
            return TbFcltInfr.builder()
                    .fcltNmbr(fcltNmbr)
                    .fcltId(this.fcltId)
                    .fcltType(this.fcltType)
                    .fcltLctn(this.fcltLctn)
                    .delYn("N")
                    .amt(Long.valueOf(0))
                    .build();
        }

    }

}
