2021与蓝度共同重构项目,服务端
fix
zhanzhiqin
2022-03-01 e8ff379d1a31f09e4d024e96eb788e5b65e0931d
ximon-admin/src/main/java/com/sandu/ximon/admin/service/MenuService.java
@@ -35,6 +35,7 @@
public class MenuService extends BaseServiceImpl<MenuMapper, Menu> {
    private final RoleMenuRelationService roleMenuRelationService;
    /**
     * 获取角色下的菜单
     */
@@ -49,7 +50,7 @@
    public boolean addMenu(MenuParam param) {
        Menu menu = new Menu();
        BeanUtils.copyProperties(param,menu);
        BeanUtils.copyProperties(param, menu);
        return save(menu);
    }
@@ -78,7 +79,7 @@
        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("找不到菜单信息");
@@ -86,12 +87,12 @@
        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);
    }
@@ -103,6 +104,8 @@
                .map(menu -> covertMenuNode(menu, list)).collect(Collectors.toList());
    }
    private MenuMapper menuMapper;
    public boolean delMenu(Long menuId) {
        Menu one = getById(menuId);
        if (one == null) {
@@ -111,9 +114,15 @@
        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("菜单正在使用,请勿删除");
        }
    }
}