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)