| | |
| | | public class MenuService extends BaseServiceImpl<MenuMapper, Menu> { |
| | | |
| | | private final RoleMenuRelationService roleMenuRelationService; |
| | | |
| | | /** |
| | | * 获取角色下的菜单 |
| | | */ |
| | |
| | | |
| | | public boolean addMenu(MenuParam param) { |
| | | Menu menu = new Menu(); |
| | | BeanUtils.copyProperties(param,menu); |
| | | BeanUtils.copyProperties(param, menu); |
| | | return save(menu); |
| | | } |
| | | |
| | |
| | | return node; |
| | | } |
| | | |
| | | public boolean updateMenu(Long menuId,MenuParam param) { |
| | | public boolean updateMenu(Long menuId, MenuParam param) { |
| | | Menu one = getById(menuId); |
| | | if (one == null) { |
| | | throw new BusinessException("找不到菜单信息"); |
| | |
| | | |
| | | List<Role> roles = SpringContextHolder.getBean(RoleService.class).listByAdminId(SecurityUtils.getUserId()); |
| | | Integer roleLevel = roles.stream().map(Role::getLevel).min(Integer::compareTo).orElse(RoleLevelStatus.COMMON.getCode()); |
| | | if(!RoleLevelStatus.SUPER.getCode().equals(roleLevel)){ |
| | | if (!RoleLevelStatus.SUPER.getCode().equals(roleLevel)) { |
| | | throw new BusinessException("超级管理员才可以编辑菜单"); |
| | | } |
| | | |
| | | Menu menu = new Menu(); |
| | | BeanUtils.copyProperties(param,menu); |
| | | BeanUtils.copyProperties(param, menu); |
| | | menu.setId(menuId); |
| | | return updateById(menu); |
| | | } |
| | |
| | | .map(menu -> covertMenuNode(menu, list)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | private MenuMapper menuMapper; |
| | | |
| | | public boolean delMenu(Long menuId) { |
| | | Menu one = getById(menuId); |
| | | if (one == null) { |
| | |
| | | |
| | | List<Role> roles = SpringContextHolder.getBean(RoleService.class).listByAdminId(SecurityUtils.getUserId()); |
| | | Integer roleLevel = roles.stream().map(Role::getLevel).min(Integer::compareTo).orElse(RoleLevelStatus.COMMON.getCode()); |
| | | if(!RoleLevelStatus.SUPER.getCode().equals(roleLevel)){ |
| | | if (!RoleLevelStatus.SUPER.getCode().equals(roleLevel)) { |
| | | throw new BusinessException("超级管理员才可以删除菜单"); |
| | | } |
| | | return removeById(menuId); |
| | | List<Long> list = menuMapper.listMenuIfBinding(menuId); |
| | | if (list.size() == 0) { |
| | | return removeById(menuId); |
| | | }else{ |
| | | throw new BusinessException("菜单正在使用,请勿删除"); |
| | | } |
| | | |
| | | } |
| | | } |