package com.its.op.entity.its.facility;

import com.its.op.dto.its.facility.TbFcltImagDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 시설물 이미지정보 Entity Class
 */
@Getter
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
@ApiModel("시설물 이미지정보")
@Entity
@Table(name = "TB_FCLT_IMAG")
public class TbFcltImag implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("시설물 관리 번호")  // N NUMBER(10)
    @Id
    @Column(name = "FCLT_NMBR", nullable = false, columnDefinition = "NUMBER", length = 10)
    private Long fcltNmbr;

    @ApiModelProperty("시설물 이미지")  // Y BLOB
    @Lob
    @Column(name = "FCLT_IMAG")
    private byte[] fcltImag;

    @ApiModelProperty("이미지 종류(PNG,JPG,BMP,...)")  // Y VARCHAR2(5)
    @Column(name = "IMAG_EXT", length = 5)
    private String imagExt;

    public TbFcltImagDto toDto() {
        return TbFcltImagDto.builder()
                .fcltNmbr(this.fcltNmbr)
                .fcltImag(this.fcltImag)
                .imagExt(this.imagExt)
                .build();
    }

    public TbFcltImag(Long fcltNmbr) {
        this.fcltNmbr = fcltNmbr;
    }

}
