权限系统基本分析

来源:互联网 发布:硕鼠mac 版下载 编辑:程序博客网 时间:2024/04/30 17:12

权限系统的存在就是为了用户登录系统存在的,而登录的作用就是判断用户的权限,登录的过程,是用户输入用户名,密码来得到用户的权限,角色,部门及其系统中的栏目(或称菜单)的过程,这个里面有很多的实现,先分析栏目和部门绑定的过程。

 

-- 查询登陆帐号对应的权限
select * from Fucdefine as fucdefine where fucdefine.id in
 (select rolefucperm.fucdefineid from Rolefucperm as rolefucperm where rolefucperm.roleid in
  (select userrole.roleid from Userrole as userrole where userrole.cmsuserid in
   (select account.cmsuserid from Account as account where account.id=account.loginname=? and account.loginpassword=?)
  )
 )
order by fucdefine.id asc

 

-- 查询登陆帐号对应的用户对应的部门编号
select cmsuser.departmentid from Cmsuser as cmsuser where cmsuser.id in
 (select account.cmsuserid from Account as account where account.id=account.loginname=? and account.loginpassword=?)

 

-- 查询登陆帐号对应的用户对应的部门编号对应的栏目
select deptcolumn.columninfoid from Deptcolumn as deptcolumn where deptcolumn.departmentid in
 (select cmsuser.departmentid from Cmsuser as cmsuser where cmsuser.id in
  (select account.cmsuserid from Account as account where account.loginname=? and account.loginpassword=?)
 )
    

 

通过相关sql,可以看到权限系统涉及到很多的表,账户表,用户表,角色表,权限表,部门表,栏目表

多对多关系有:角色表和权限表、部门表和栏目表两种,所以增加两张表:角色权限表和部门栏目表

 

得到权限的过程

 1)账户表account与用户表cmsuser存在关系,通过账户名、密码找到帐户表记录中的cmsuserid
 2)用户表与角色表userrole存在关系,通过cmsuserid找到角色id
 3)角色表与角色权限表rolefucperm存在关系,通过roleid找到权限id
 4)角色权限表与权限表fucdefine存在关系,通过权限id找到权限

 

得到部门的过程

 1)账户表account与用户表cmsuser存在关系,通过账户名、密码找到帐户表记录中的cmsuserid
 2)根据cmsuserid查询用户表,得到对应部门id

 

得到栏目的过程

1)账户表account与用户表cmsuser存在关系,通过账户名、密码找到帐户表记录中的cmsuserid
2)根据cmsuserid查询用户表,得到对应部门id

3)根据部门id查询部门栏目表,得到栏目id

 

先简单介绍到这里,mark下

原创粉丝点击