package com.bocloud.ims.entity.resource;

import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.Generic;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.format.annotation.DateTimeFormat;

import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialException;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.Date;

/**
 * 批量新增主机错误提示文件
 * 
 * @author liuyuanyuan
 *
 */
@Table("ci_file")
public class File extends Generic {
	@PK(PKStrategy.SELF)
	private String uuid;
	@Column("file_name")
	private String fileName;
	@Column("file")
	private Blob file;
	@IgnoreAll
	private byte[] fileBytes;
	// 创建时间
	@Column("gmt_create")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date gmtCreate;
	// 创建人
	@Column("creator_id")
	private Long creatorId;

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public void setFile(Blob file) {
		this.file = file;
	}

	public void setFileBytes(byte[] fileBytes) {
		this.fileBytes = fileBytes;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public Blob getFile() {
		return file;
	}

	public Date getGmtCreate() {
		return gmtCreate;
	}

	public void setGmtCreate(Date gmtCreate) {
		this.gmtCreate = gmtCreate;
	}

	public Long getCreatorId() {
		return creatorId;
	}

	public void setCreatorId(Long creatorId) {
		this.creatorId = creatorId;
	}

	public void setBytesForFile(byte[] bytes) throws SerialException, SQLException {
		this.file = new SerialBlob(bytes);
	}

	public byte[] getFileBytes() {
		return fileBytes;
	}

}
