package com.uas.platform.b2b.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;

import com.alibaba.fastjson.annotation.JSONField;

@Entity
@Table(name = "attachs")
public class Attach implements Serializable{

	/**
	 * 序列号
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "at_id")
	private Long id;
	/**
	 * 路径
	 */
	@Column(name = "at_path")
	private String path;
	/**
	 * 描述语
	 */
	@Column(name = "at_description")
	private String description;
	/**
	 * 文件名称
	 */
	@Column(name = "at_name")
	private String name;

	/**
	 * 文件大小
	 */
	@Column(name = "at_size")
	private Long size;

	/**
	 * 关联的表
	 */
	@Column(name = "rel_table")
	private String relativeTable;

	/**
	 * 关联的数据主键值
	 */
	@Column(name = "rel_key")
	private Long relativeKey;

	/**
	 * 保存时间
	 */
	@Column(name = "at_date")
	private Date date;

	@Transient
	private String sourceId;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@JsonIgnore
	@JSONField(serialize = false)
	public Date getDate() {
		return date;
	}
	
	public void setDate(Date date) {
		this.date = date;
	}

//	@JsonIgnore
//	@JSONField(serialize = false)
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@JsonIgnore
	@JSONField(serialize = false)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getSize() {
		return size;
	}

	public void setSize(Long size) {
		this.size = size;
	}

	@JsonIgnore
	@JSONField(serialize = false)
	public String getSourceId() {
		return sourceId;
	}

	public void setSourceId(String sourceId) {
		this.sourceId = sourceId;
	}

	@JsonIgnore
	@JSONField(serialize = false)
	public String getRelativeTable() {
		return relativeTable;
	}

	/**
	 * 不再用这种关联方式，如果一对一直接保存ID，如果一对多采用中间表 @since 2017年03月19日 suntg
	 * @param relativeTable
	 */
	@Deprecated
	public void setRelativeTable(String relativeTable) {
		this.relativeTable = relativeTable;
	}

	@JsonIgnore
	@JSONField(serialize = false)
	public Long getRelativeKey() {
		return relativeKey;
	}

	/**
	 * 不再用这种关联方式，如果一对一直接保存ID，如果一对多采用中间表 @since 2017年03月19日 suntg
	 * @param relativeKey
	 */
	@Deprecated
	public void setRelativeKey(Long relativeKey) {
		this.relativeKey = relativeKey;
	}

	public Attach() {
	}

	/**
	 * @param fileName
	 *            文件名
	 * @param filePath
	 *            文件物理路径
	 * @param description
	 *            描述
	 * @param size
	 *            大小
	 */
	public Attach(String fileName, String filePath, String description, long size) {
		this.name = fileName;
		this.path = filePath;
		this.description = description;
		this.size = size;
	}
	
	/**
	 * 
	 * @param fileName
	 * @param filePath
	 * @param description
	 * @param size
	 * @param date
	 */
	public Attach(String fileName, String filePath, String description, long size, Date date) {
		this.name = fileName;
		this.path = filePath;
		this.description = description;
		this.size = size;
		this.date = date;
	}

}
