package com.uas.platform.b2b.model;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 资源表-主表
 * 
 * @author yingp
 *
 */
@Table(name = "sec$resources")
@Entity
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "com.uas.platform.b2b.model.Resource")
public class Resource implements Serializable{

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

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "res_id")
	private Long id;

	/**
	 * 资源名称
	 */
	@Column(name = "res_name")
	private String name;

	/**
	 * 资源的具体作业描述
	 */
	@Column(name = "res_desc")
	private String desc;

	/**
	 * 资源的详细清单
	 */
	@OneToMany(cascade = { CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE }, fetch = FetchType.EAGER)
	@JoinColumn(name = "item_resid")
	@OrderBy("id")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Set<ResourceItem> items;

	/**
	 * 权限显示排序下标
	 */
	@Column(name = "res_index", unique = true)
	@NotNull
	private Long index;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

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

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public Set<ResourceItem> getItems() {
		return items;
	}

	public void setItems(Set<ResourceItem> items) {
		this.items = items;
	}

	public Long getIndex() {
		return index;
	}

	public void setIndex(Long index) {
		this.index = index;
	}
}
