针对权限管理模块的简单操作 -- 小样
权限模块
管理员 - 角色 - 资源 - 权限
管理员 -> 管理员-角色 <- 角色
角色 -> <角色-资源-权限> <- 资源
<- 权限
import java.util.HashSet;
/**
* 系统角色信息
*
*/
public class SysRole {
private String roleNo ; //角色编码
private String roleName ; //角色名称
private String roleDesc ; //角色描述
private java.util.Set<Role_Menu_Perm> rmpSet = new java.util.HashSet<Role_Menu_Perm>();
public java.util.Set<Role_Menu_Perm> getRmpSet() {
return rmpSet;
}
public void setRmpSet(java.util.Set<Role_Menu_Perm> rmpSet) {
this.rmpSet = rmpSet;
}
public String getRoleNo() {
return roleNo;
}
public void setRoleNo(String roleNo) {
this.roleNo = roleNo;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getRoleDesc() {
return roleDesc;
}
public void setRoleDesc(String roleDesc) {
this.roleDesc = roleDesc;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.permissions.model.SysRole" table="SysRole">
<id column="roleNo" name="roleNo" type="string">
<generator class="assigned"/>
</id>
<property column="roleName" name="roleName" type="string" length="20" not-null="true" unique="true"/>
<property column="roleDesc" name="roleDesc" type="string" length="200"/>
<!-- 如果这里的注释信息打开,Role_Menu_Perm类中的注释部分也要打开
<set name="rmpSet" table="Role_Menu_Perm" inverse="false" lazy="false">
<key column="roleNo" not-null="true"></key>
<composite-element class="com.permissions.model.Role_Menu_Perm">
<property name="menuNo"></property>
<property name="permNo"></property>
</composite-element>
</set>
-->
<set name="rmpSet" table="Role_Menu_Perm" inverse="false" lazy="false">
<key column="roleNo" not-null="true"></key>
<composite-element class="com.permissions.model.Role_Menu_Perm">
<many-to-one name="menu" column="menuNo"></many-to-one>
<many-to-one name="perm" column="permNo"></many-to-one>
</composite-element>
</set>
</class>
</hibernate-mapping>
/**
*角色-资源-权限
*
**/
public class Role_Menu_Perm {
// private String roleNo ;
//
// private String menuNo ;
//
// private String permNo ;
//
private SysRole role ;
private SysMenu menu ;
private SysPermissions perm ;
public SysRole getRole() {
return role;
}
public void setRole(SysRole role) {
this.role = role;
}
public SysMenu getMenu() {
return menu;
}
public void setMenu(SysMenu menu) {
this.menu = menu;
}
public SysPermissions getPerm() {
return perm;
}
public void setPerm(SysPermissions perm) {
this.perm = perm;
}
// public String getRoleNo() {
// return roleNo;
// }
//
// public void setRoleNo(String roleNo) {
// this.roleNo = roleNo;
// }
//
// public String getMenuNo() {
// return menuNo;
// }
//
// public void setMenuNo(String menuNo) {
// this.menuNo = menuNo;
// }
//
// public String getPermNo() {
// return permNo;
// }
//
// public void setPermNo(String permNo) {
// this.permNo = permNo;
// }
}