作者:守护琳的心 | 来源:互联网 | 2023-10-12 15:19
一、表关系一共有8张表分别用来实现用户-角色-部门-区域-菜单-权限管理,详细如下:二、SQL语句[java] viewplain copy********************
一、表关系
一共有8张表分别用来实现用户-角色-部门-区域-菜单-权限管理,详细如下:
二、SQL语句
-
- select * from sys_user;
- select * from sys_menu;
- select * from sys_role;
- select * from sys_user_role;
- select * from sys_role_menu;
- select * from sys_area;
- select * from sys_office;
- select * from sys_role_office;
-
-
- select * from sys_user where id=‘11‘
- select * from sys_user_role where user_id=‘11‘
- select * from sys_role where id=‘3‘
-
- select count(1),user_id from sys_user_role GROUP BY user_id
- select count(*) from sys_user_role where user_id=‘1‘
-
- select us.name,sr.name as rolename from (select * from sys_user where id=‘1‘) us
- left JOIN sys_user_role usrole on us.id=usrole.user_id
- LEFT JOIN sys_role sr on usrole.role_id = sr.id
-
- select su.name as username,sr.name as rolename from sys_user su
- LEFT JOIN sys_user_role sur on su.id = sur.user_id
- LEFT JOIN sys_role sr on sur.role_id = sr.id
-
- SELECT u.name as uname,a.name as rolename FROM sys_role a
- LEFT JOIN sys_user_role ur ON ur.role_id = a.id
- LEFT JOIN sys_user u ON u.id = ur.user_id
-
- select * from sys_user_role;
- select * from sys_role;
-
-
-
- SELECT u.id as userid,u.name as username,a.id as roleid,a.name as rolename,sm.name menuname FROM sys_role a
- LEFT JOIN sys_user_role ur ON ur.role_id = a.id
- LEFT JOIN sys_user u ON u.id = ur.user_id
- LEFT JOIN sys_role_menu srm on srm.role_id = a.id
- LEFT JOIN sys_menu sm on srm.menu_id = sm.id
-
- select a.name as menuname FROM sys_menu a
-
- select a.name as menuname FROM sys_menu a
- LEFT JOIN sys_menu p ON p.id = a.parent_id
-
- select a.name as menuname,r.name as rolename,u.name as username FROM sys_menu a
- LEFT JOIN sys_menu p ON p.id = a.parent_id
- JOIN sys_role_menu rm ON rm.menu_id = a.id
- JOIN sys_role r ON r.id = rm.role_id AND r.useable=‘1‘
- JOIN sys_user_role ur ON ur.role_id = r.id
- JOIN sys_user u ON u.id = ur.user_id
-
- select * from sys_user_role;
- select * from sys_role;
- select * from sys_role_menu;
-
-
-
-
- select su.name as username,so.name as companyname from sys_user su
- LEFT JOIN sys_office so on su.company_id = so.id
-
- select of.* from sys_user us
- left JOIN sys_office of on us.company_id = of.id where us.id=‘11‘
-
- select su.name as username,so.name as officename from sys_user su
- LEFT JOIN sys_office so on su.office_id = so.id
-
- select of.* from sys_user us
- left JOIN sys_office of on us.office_id = of.id where us.id=‘11‘
-
- select * from sys_user;
- select * from sys_office;
-
-
- SELECT u.name as uname,a.id as roleid,a.name as rolename,so.name as officename FROM sys_role a
- LEFT JOIN sys_user_role ur ON ur.role_id = a.id
- LEFT JOIN sys_user u ON u.id = ur.user_id
- LEFT JOIN sys_role_office sro on a.id = sro.role_id
- LEFT JOIN sys_office so on sro.office_id = so.id
-
- select * from sys_user;
- select * from sys_user_role;
- select * from sys_role;
- select * from sys_office;
- select * from sys_role_office;
-
-
- select of.name as officename,ar.name as areaname from sys_office of
- LEFT JOIN sys_area ar on of.area_id=ar.id
-
- select * from sys_area;
- select * from sys_office;
JEESITE快速开发平台(五)用户-角色-部门-区域-菜单-权限表关系