67,512
社区成员
发帖
与我相关
我的任务
分享
@Entity
@Table(name = "BMS_Rights")
public class RightsBean extends IdEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String parentId; //父ID
private String name; //模块名称
private String path; //路径
private String remark; //描述
private String direction; //菜单方向
private String iconCls; //菜单图标样式class
private int isButton; //菜单是否为按钮级别,0否,1是
//角色
private List<RoleBean> role = Lists.newArrayList();
//表示资源下所属的功能(资源)
private List<RightsBean> childRights = Lists.newArrayList();
@Column(name="ParentID",length=32)
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
@Column(name="Name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="Path")
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "rights")
public List<RoleBean> getRole() {
return role;
}
public void setRole(List<RoleBean> role) {
this.role = role;
}
@Column(name="Remark")
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Column(name="Direction")
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
/**
* 不查询按钮级别的子菜单
*/
@OneToMany(fetch = FetchType.EAGER, mappedBy="parentId")
@Where(clause = "IsButton=0")
public List<RightsBean> getChildRights() {
return childRights;
}
public void setChildRights(List<RightsBean> childRights) {
this.childRights = childRights;
}
@Column(name="IconCls")
public String getIconCls() {
return iconCls;
}
public void setIconCls(String iconCls) {
this.iconCls = iconCls;
}
@Column(name="IsButton")
public int getIsButton() {
return isButton;
}
public void setIsButton(int isButton) {
this.isButton = isButton;
}
}
package com.cicro.bms.entity.rights;
import java.io.Serializable;
import java.util.List;
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.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.cicro.bms.entity.role.RoleBean;
import com.google.common.collect.Lists;
/**
* 权限
*/
@Entity
@Table(name = "BMS_Rights")
public class RightsBean implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id; //编号
private Integer parentId; //父ID
private String name; //模块名称
private String path; //路径
private String remark; //描述
private String direction; //菜单方向
private String iconCls; //菜单图标样式class
private Integer isButton; //菜单是否为按钮级别,0否,1是
private Integer isSystem; //是否为系统默认权限:0不是 1是
//角色
private List<RoleBean> role = Lists.newArrayList();
//表示资源下所属的功能(资源)
private List<RightsBean> childRights = Lists.newArrayList();
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID", nullable = false)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name="ParentID")
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
@Column(name="Name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="Path")
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "rights")
public List<RoleBean> getRole() {
return role;
}
public void setRole(List<RoleBean> role) {
this.role = role;
}
@Column(name="Remark")
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Column(name="Direction")
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
@Column(name="IconCls")
public String getIconCls() {
return iconCls;
}
public void setIconCls(String iconCls) {
this.iconCls = iconCls;
}
@Column(name="IsButton")
public Integer getIsButton() {
return isButton;
}
public void setIsButton(Integer isButton) {
this.isButton = isButton;
}
@Column(name="IsSystem")
public Integer getIsSystem() {
return isSystem;
}
public void setIsSystem(Integer isSystem) {
this.isSystem = isSystem;
}
@Transient
public List<RightsBean> getChildRights() {
return childRights;
}
public void setChildRights(List<RightsBean> childRights) {
this.childRights = childRights;
}
}