-
Notifications
You must be signed in to change notification settings - Fork 40
User role and permission queries
page owner: TFRS Developer
select * from public.user;
select * from public.role;
select * from public.role_permission;
select u.id as user_id, u.username, u.first_name, u.last_name, ur.role_id, r.name as role_name, rp.permission_id, p.code as permission_code, p.name as permission_name from public.user u inner join user_role ur on u.id=ur.user_id inner join role r on ur.role_id=r.id inner join role_permission rp on r.id=rp.role_id inner join permission p on rp.permission_id=p.id where u.username='<user_name>';
select r.id as role_id, r.name as role_name , rp.id as permission_id, p.code as permission_code, p.name as permission_name from role_permission rp Inner join permission p on rp.permission_id=p.id Inner join role r on rp.role_id=r.id order by r.name;
select * from public.user u where u.id in (Select u.id from public.user u Inner join user_role ur on u.id=ur.user_id Group by u.id Having count(u.id)>1);