| | |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.node.ForestNodeMerger; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.CollectionUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.system.entity.Role; |
| | |
| | | @Override |
| | | public List<RoleVO> tree(String tenantId) { |
| | | String userRole = AuthUtil.getUserRole(); |
| | | String roleId = AuthUtil.getUser().getRoleId(); |
| | | String excludeRole = null; |
| | | if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMIN) && !CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMINISTRATOR)) { |
| | | excludeRole = RoleConstant.ADMIN; |
| | | } |
| | | return ForestNodeMerger.merge(baseMapper.tree(tenantId, excludeRole)); |
| | | List<RoleVO> merge = ForestNodeMerger.merge(baseMapper.tree(tenantId, excludeRole)); |
| | | List<RoleVO> copy = BeanUtil.copy(merge, RoleVO.class); |
| | | if (!AuthUtil.isAdministrator()) { |
| | | List<RoleVO> collect = copy.stream().filter(item -> roleId.contains(item.getId().toString())).collect(Collectors.toList()); |
| | | return collect; |
| | | } |
| | | return merge; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | // 新增配置 |
| | | roleMenuService.saveBatch(roleMenus); |
| | | // 递归设置下属角色菜单集合 |
| | | recursionRoleMenu(roleIds, menuIds); |
| | | // recursionRoleMenu(roleIds, menuIds); |
| | | return true; |
| | | } |
| | | |