| | |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sandu.common.enums.RoleLevelStatus; |
| | | import com.sandu.common.execption.BusinessException; |
| | |
| | | public class MenuService extends BaseServiceImpl<MenuMapper, Menu> { |
| | | |
| | | private final RoleMenuRelationService roleMenuRelationService; |
| | | private MenuMapper menuMapper; |
| | | |
| | | /** |
| | | * 获取角色下的菜单 |
| | |
| | | if (CollectionUtil.isEmpty(menuIdList)) { |
| | | return null; |
| | | } |
| | | return listByIds(menuIdList); |
| | | |
| | | return menuMapper.listMenuById(menuIdList); |
| | | } |
| | | |
| | | public boolean addMenu(MenuParam param) { |
| | |
| | | } |
| | | |
| | | public List<MenuNode> treeList() { |
| | | List<Menu> list = list(); |
| | | LambdaQueryWrapper<Menu> menuLambdaQueryWrapper = Wrappers.lambdaQuery(Menu.class).orderByAsc(Menu::getSeq); |
| | | List<Menu> list = list(menuLambdaQueryWrapper); |
| | | return list.stream() |
| | | .filter(menu -> menu.getPid().equals(0L)) |
| | | .map(menu -> covertMenuNode(menu, list)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | private MenuMapper menuMapper; |
| | | |
| | | public boolean delMenu(Long menuId) { |
| | | Menu one = getById(menuId); |
| | |
| | | throw new BusinessException("超级管理员才可以删除菜单"); |
| | | } |
| | | List<Long> list = menuMapper.listMenuIfBinding(menuId); |
| | | if (list.size() == 0) { |
| | | List<Long> list1 = menuMapper.listMenuIfBinding1(menuId); |
| | | |
| | | if (list.size() == 0 && list1.size() == 0) { |
| | | return removeById(menuId); |
| | | }else{ |
| | | } else { |
| | | throw new BusinessException("菜单正在使用,请勿删除"); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 通过菜单ID集合获取菜单实体列表 |
| | | * |
| | | * @param menuIds 菜单ID集合 |
| | | */ |
| | | public List<MenuNode> getUserPermissionListById(List<Long> menuIds) { |
| | | List<Menu> menuList = menuMapper.getUserPermissionListById(menuIds); |
| | | |
| | | List<MenuNode> resultList = menuList.stream() |
| | | .filter(menu -> menu.getPid().equals(0L)) |
| | | .map(menu -> covertMenuNode(menu, menuList)).collect(Collectors.toList()); |
| | | return resultList; |
| | | } |
| | | } |