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

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

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

    @ApiModelProperty("시설물 관리 번호")  // N NUMBER(10)
    @JsonProperty("fclt_nmbr")
    private Long fcltNmbr;

    @ApiModelProperty("시설물 이미지")  // Y BLOB
    @JsonProperty("fclt_imag")
    private byte[] fcltImag;

    @ApiModelProperty("이미지 종류(PNG,JPG,BMP,...)")  // Y VARCHAR2(5)
    @JsonProperty("imag_ext")
    private String imagExt;

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

        @ApiModelProperty("시설물 관리 번호, Nullable = N, NUMBER(10)")  // N NUMBER(10)
        @JsonProperty("fclt_nmbr")
        @PositiveOrZero
        private Long fcltNmbr;

        @ApiModelProperty("시설물 이미지, Nullable = Y, Image Data")  // Y BLOB
        @JsonProperty("fclt_imag")
        private byte[] fcltImag;

        @ApiModelProperty("이미지 종류(PNG,JPG,BMP,...), Nullable = Y, VARCHAR2(5)")  // Y VARCHAR2(5)
        @JsonProperty("imag_ext")
        @Size(min=1, max=5)
        private String imagExt;

        @Builder
        public TbFcltImagUpdReq(Long fclt_nmbr, byte[] fclt_imag, String imag_ext) {
            this.fcltNmbr = fclt_nmbr;
            this.fcltImag = fclt_imag;
            this.imagExt = imag_ext;
        }

        public TbFcltImag toEntity() {
            return TbFcltImag.builder()
                    .fcltNmbr(this.fcltNmbr)
                    .fcltImag(this.fcltImag)
                    .imagExt(this.imagExt)
                    .build();
        }

    }

}
