阅读本文大概需要 2.8 分钟。
作者:Orson
来源:www.cnblogs.com/java-class/p/5985916.html
select a.uuid,a.name
from menu a
left join role_menu b
on a.uuid = b.menuid
left join role_user c
on b.roleid = c.roleid
where c.userid = '用户uuid';
RoleUserPO roleUserPO = roleService.findUserRoleByUserId("用户ID");
if (roleUserPO == null) {
return "当前用户没有设置角色!";
}
List<RoleMenuPO> roleMenuPOs = roleService.findRoleMenusByRoleId(roleUserPO.getRoleid());
if (roleMenuPOs == null) {
return "当用户所在角色没有设置菜单!";
}
List<MenuPO> menuPOLis = new ArrayList<MenuPO>();
for (RoleMenuPO roleMenuPO : roleMenuPOs) {
menuPOLis.add(menuService.findMenuById(roleMenuPO.getMenuid()));
}
return menuPOLis;
select a.*
from user a
LEFT JOIN role_user b
on a.UUID = b.userid
LEFT JOIN orga_user c
on a.uuid = c.userid
where b.ROLEID = 'c9845b33973511e6acede16e8241c0fe'
and c.ORGAID = '75284c22973211e6acede16e8241c0fe'
List<UserPO> userPO1s = roleService.findUsersByRoleId("角色ID");
if (userPO1s == null) {
return "当前角色没有添加用户!";
}
List<UserPO> userPO2s = orgaService.findUsersByOrgaId("组织机构ID");
if (userPO2s == null) {
return "当前机构没有添加用户!";
}
List<UserPO> userPOList = new ArrayList<UserPO>();
for (UserPO userPO1 : userPO1s) {
for (UserPO userPO2 : userPO2s) {
if (userPO1.getUuid().equals(userPO2.getUuid())) {
userPOList.add(userPO1);
break;
}
}
}
return userPOList;
<END>
推荐阅读:
微信扫描二维码,关注我的公众号
朕已阅