| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Constants; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<MenuVO> routes(String roleId, Long topMenuId, Integer labelType) { |
| | | public List<MenuVO> routes(String roleId, Long topMenuId, Integer labelType,Integer menuType) { |
| | | if (StringUtil.isBlank(roleId)) { |
| | | return null; |
| | | } |
| | | List<Menu> allMenus = baseMapper.allMenu(); |
| | | List<Menu> allMenus = baseMapper.selectList(Wrappers.<Menu>lambdaQuery().eq(Menu::getCategory,1).eq(Menu::getMenuType,menuType)); |
| | | List<Menu> roleMenus; |
| | | // 超级管理员并且不是顶部菜单请求则返回全部菜单 |
| | | if (AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) { |
| | | roleMenus = allMenus.stream().filter(a -> a.getMenuType().equals(0)).collect(Collectors.toList()); |
| | | roleMenus = allMenus; |
| | | } |
| | | // 非超级管理员并且不是顶部菜单请求则返回对应角色权限菜单 |
| | | else if (!AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) { |
| | | roleMenus = tenantPackageMenu(baseMapper.roleMenuByRoleId(Func.toLongList(roleId))); |
| | | UserHouseLabelDTO userHouseLabelDTO = new UserHouseLabelDTO(); |
| | | userHouseLabelDTO.setUserId(AuthUtil.getUserId()); |
| | | userHouseLabelDTO.setLableType(labelType); |
| | | List<Integer> integers = iUserHouseLabelService.selectUserLabelList(userHouseLabelDTO); |
| | | Iterator<Menu> iterator = roleMenus.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Menu next = iterator.next(); |
| | | if (!next.getParentId().equals(0)) { |
| | | if (StringUtils.isNotBlank(next.getLabelId())) { |
| | | String[] split = next.getLabelId().split(","); |
| | | List<Integer> integerList = Arrays.stream(split).map(Integer::valueOf).collect(Collectors.toList()); |
| | | Collection<? extends Serializable> union = CollectionUtils.intersection(integerList, integers); |
| | | if (union.size() == 0) { |
| | | iterator.remove(); |
| | | } |
| | | } else { |
| | | if (next.getName().trim().equals("标签报事")) { |
| | | iterator.remove(); |
| | | } |
| | | if (next.getName().trim().equals("取保候审")) { |
| | | iterator.remove(); |
| | | } |
| | | if (next.getName().trim().equals("打金店")) { |
| | | iterator.remove(); |
| | | } |
| | | if (next.getName().trim().equals("旅馆安全")) { |
| | | iterator.remove(); |
| | | } |
| | | if (next.getName().trim().equals("二手车交易")) { |
| | | iterator.remove(); |
| | | } |
| | | if (next.getName().trim().equals("二手手机维修")) { |
| | | iterator.remove(); |
| | | } |
| | | if (next.getName().trim().equals("校园安全")) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | } |
| | | roleMenus = tenantPackageMenu(baseMapper.roleMenuByRoleId(Func.toLongList(roleId), menuType)); |
| | | // 1:居民,居民需要通过人的标签来显示取保候审 |
| | | if(CommonConstant.NUMBER_ONE.equals(labelType)){ |
| | | extracted(labelType, roleMenus); |
| | | } |
| | | } |
| | | // 顶部菜单请求返回对应角色权限菜单 |
| | | else { |
| | | // 角色配置对应菜单 |
| | | List<Menu> roleIdMenus = baseMapper.roleMenuByRoleId(Func.toLongList(roleId)); |
| | | List<Menu> roleIdMenus = baseMapper.roleMenuByRoleId(Func.toLongList(roleId),menuType); |
| | | // 反向递归角色菜单所有父级 |
| | | List<Menu> routes = new LinkedList<>(roleIdMenus); |
| | | roleIdMenus.forEach(roleMenu -> recursion(allMenus, routes, roleMenu)); |
| | |
| | | return buildRoutes(allMenus, roleMenus); |
| | | } |
| | | |
| | | /** |
| | | * 房屋的时候才通过人的标签过滤 |
| | | * @param roleMenus |
| | | * @param labelType |
| | | */ |
| | | private void extracted(Integer labelType, List<Menu> roleMenus) { |
| | | UserHouseLabelDTO userHouseLabelDTO = new UserHouseLabelDTO(); |
| | | userHouseLabelDTO.setUserId(AuthUtil.getUserId()); |
| | | userHouseLabelDTO.setLableType(labelType); |
| | | List<Integer> integers = iUserHouseLabelService.selectUserLabelList(userHouseLabelDTO); |
| | | Iterator<Menu> iterator = roleMenus.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Menu next = iterator.next(); |
| | | if (!next.getParentId().equals(0)) { |
| | | if (StringUtils.isNotBlank(next.getLabelId())) { |
| | | String[] split = next.getLabelId().split(","); |
| | | List<Integer> integerList = Arrays.stream(split).map(Integer::valueOf).collect(Collectors.toList()); |
| | | Collection<? extends Serializable> union = CollectionUtils.intersection(integerList, integers); |
| | | if (union.size() == 0) { |
| | | iterator.remove(); |
| | | } |
| | | } else { |
| | | if (next.getName().trim().equals("取保候审")) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<MenuVO> routesExt(String roleId, Long topMenuId) { |
| | | if (StringUtil.isBlank(roleId)) { |