package com.bocloud.ims.entity.resource;

import com.alibaba.fastjson.JSONObject;
import com.bocloud.common.utils.DaySerializer;
import com.bocloud.entity.annotations.Column;
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 java.util.Date;

/**
 * 组织机构-资源实体类
 * 
 * @author dongkai
 *
 */
@Table("object_relation")
public class ObjectRelation extends Generic {

	@PK(value = PKStrategy.AUTO)
	private Long id; // ID
	@Column("target")
	private Long target; // 目标ID
	@Column("res_id")
	private Long resId; // 资源ID
	@Column("shared")
	private Boolean shared; // 是否共享
	@Column("category")
	private String category;// 资源类型
	@Column("catalog")
	private String catalog;// 目标类型
	@Column("used")
	private Boolean used = false; // 是否使用
	@Column
	private Integer size; // 大小
	@Column("expired_time")
	@JsonSerialize(using = DaySerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date expiredTime;// 过期时间

	public ObjectRelation() {

	}

	public ObjectRelation(Long target, Long resId, Boolean shared, String category, String catalog, Integer size) {
		super();
		this.target = target;
		this.resId = resId;
		this.shared = shared;
		this.category = category;
		this.catalog = catalog;
		this.size = size;
	}

	/**
	 * @return the size
	 */
	public Integer getSize() {
		return size;
	}

	/**
	 * @param size
	 *            the size to set
	 */
	public void setSize(Integer size) {
		this.size = size;
	}

	/**
	 * @return the used
	 */
	public Boolean getUsed() {
		return used;
	}

	/**
	 * @param used
	 *            the used to set
	 */
	public void setUsed(Boolean used) {
		this.used = used;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the target
	 */
	public Long getTarget() {
		return target;
	}

	/**
	 * @param target
	 *            the target to set
	 */
	public void setTarget(Long target) {
		this.target = target;
	}

	/**
	 * @return the resId
	 */
	public Long getResId() {
		return resId;
	}

	/**
	 * @param resId
	 *            the resId to set
	 */
	public void setResId(Long resId) {
		this.resId = resId;
	}

	/**
	 * @return the shared
	 */
	public Boolean getShared() {
		return shared;
	}

	/**
	 * @param shared
	 *            the shared to set
	 */
	public void setShared(Boolean shared) {
		this.shared = shared;
	}

	/**
	 * @return the category
	 */
	public String getCategory() {
		return category;
	}

	/**
	 * @param category
	 *            the category to set
	 */
	public void setCategory(String category) {
		this.category = category;
	}

	/**
	 * @return the catalog
	 */
	public String getCatalog() {
		return catalog;
	}

	/**
	 * @param catalog
	 *            the catalog to set
	 */
	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	/**
	 * @return the expiredTime
	 */
	public Date getExpiredTime() {
		return expiredTime;
	}

	/**
	 * @param expiredTime
	 *            the expiredTime to set
	 */
	public void setExpiredTime(Date expiredTime) {
		this.expiredTime = expiredTime;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}

}
