content: package org.catframework.agileworking.domain;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.persistence.CascadeType;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.FetchType;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.JoinTable;
  import javax.persistence.ManyToMany;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  
  @Entity
  public class Team implements Serializable {
  
  	private static final long serialVersionUID = 1L;
  
  	@Id
  	@GeneratedValue
  	private Long id;
  
  	@Column(nullable = false)
  	private String name;
  
  	// desc 和 mysql 中的关键字有冲突，所以使用了 'team_desc'
  	@Column(name = "team_desc")
  	private String desc;
  
  	/** 用于注册校验的 token */
  	private String token;
  
  	@ManyToMany(cascade = { CascadeType.PERSIST}, fetch = FetchType.EAGER)
  	@JoinTable(name = "team_user_mapping", joinColumns = {
  			@JoinColumn(name = "team_id", referencedColumnName = "id") }, inverseJoinColumns = {
  					@JoinColumn(name = "user_id", referencedColumnName = "id") })
  	@JsonIgnore
  	private List<User> users = new ArrayList<>();
  
  	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 List<User> getUsers() {
  		return users;
  	}
  
  	public void setUsers(List<User> users) {
  		this.users = users;
  	}
  
  	public void addUser(User user) {
  		this.users.add(user);
  	}
  
  	@JsonIgnore
  	public String getToken() {
  		return token;
  	}
  
  	public void setToken(String token) {
  		this.token = token;
  	}
  }
  