ThinkPHP 中权限管理控制(RBAC)

1.  查询当前用户可以访问哪些应用

select node.id,node.name from rice_role as role, rice_role_user as user,
rice_access as access, rice_node as node where user.user_id=3 and
user.role_id=role.id and (access.role_id=role.id or (access.role_id=role.pid and role.pid!=0))

 and role.status=1 and access.node_id=node.id  and node.level=1 and node.status=1 group by id

2. 查询当前用户可以访问哪些模块

SELECT node.id, node.name
FROM rice_role AS role, rice_role_user AS user, rice_access AS access, rice_node AS node
WHERE user.user_id =3
AND user.role_id = role.id
AND (
access.role_id = role.id
OR (
access.role_id = role.pid
AND role.pid !=0))
AND role.status =1
AND access.node_id = node.id
AND node.level =2
AND node.pid =1
AND node.status =1 group by id

 

3. 查询具体模块对应的方法

select node.id,node.name from
                    rice_role as role,
                    rice_role_user as user,
                    rice_access as access ,
                    rice_node as node
                    where user.user_id=3 and user.role_id=role.id and ( access.role_id=role.id  or (access.role_id=role.pid and role.pid!=0 ) ) and role.status=1 and access.node_id=node.id and node.level=3 and node.pid={$moduleId} and node.status=1  group by id

 

 

 

 

 

 

ThinkPHP 中权限管理控制(RBAC),古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。