关于用户、角色及权限管理。如下设计是在oracle数据库环境下demo.
1、table user(用户表)
------------------------------------------------- ID username password name ... ------------------------------------------------- 1 admin admin 测试1 2 lx lx 测试2
2、table group(用户组)
------------------------------------------------- ID name description ... ------------------------------------------------- 1 js 技术人员 2 yw 业务人员
3、table permission(权限及菜单表)
------------------------------------------------------------------------------------- ID name depth parentid link description showmenu ... ------------------------------------------------------------------------------------- 1 系统管理 1 0 1 2 用户管理 2 1 1 3 用户组管理 2 1 1 4 添加用户 3 2 /user/adduser.do 1 5 查询用户 3 2 /user/listuser.do 1
说明:depth 为菜单级次,1为1级主菜单...
4、table user_permission(用户权限对照表)
------------------------------------------------- userId permissionid -------------------------------------------------5、table group_permission(用户组权限对照表)
------------------------------------------------- groupId permissionid ------------------------------------------------- 2 1 2 2 2 3 2 4 2 56、table user_group(用户用户组对照表)
------------------------------------------------- userId groupId ------------------------------------------------- 1 2 2 2
7、Start with...Connect By子句递归查询
select p.id, p.name, p.link , p.depth , p.parentId, p.description , p.showAsMenu from permission p join (select gp.permissionid from user_group ug join group_permission gp on ug.userid=1 and ug.groupid=gp.groupid union select up.permissionid from user_permission up where up.userid=1) t on p.id=t.permissionid and p.showasmenu=1 and p.depth<=3 start with p.parentid=1 connect by prior p.id=p.parentid order siblings by p.id
O了, 显示效果就不写了!
相关资源:JAVA用户、角色、权限、菜单、工作流管理系统