mirror of https://gitee.com/stylefeng/roses
【8.3.1】【role】整理一些基础通用接口的封装
parent
11378e8899
commit
191b580fba
|
@ -65,4 +65,23 @@ public interface SysMenuServiceApi {
|
|||
*/
|
||||
Set<Long> getAppMenuAndOptionIds(Long appId);
|
||||
|
||||
/**
|
||||
* 获取所有菜单的id和父级id的映射关系
|
||||
*
|
||||
* @return 菜单id和父级id的映射关系
|
||||
* @author fengshuonan
|
||||
* @since 2024/6/24 12:38
|
||||
*/
|
||||
Map<Long, Long> getMenuIdParentIdMap();
|
||||
|
||||
/**
|
||||
* 获取菜单下的所有功能
|
||||
*
|
||||
* @param menuId 指定菜单id
|
||||
* @param roleLimitMenuIdsAndOptionIds 被限制的功能和id集合
|
||||
* @author fengshuonan
|
||||
* @since 2024/10/31 9:51
|
||||
*/
|
||||
List<Long> getMenuOptions(Long menuId, Set<Long> roleLimitMenuIdsAndOptionIds);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.menu.factory;
|
||||
package cn.stylefeng.roses.kernel.sys.api.factory;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
|
||||
|
|
@ -7,7 +7,6 @@ import cn.stylefeng.roses.kernel.sys.modular.menu.pojo.response.AppGroupDetail;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -125,15 +124,6 @@ public interface SysMenuService extends IService<SysMenu>, SysMenuServiceApi {
|
|||
*/
|
||||
List<String> getMenuCodeList(List<Long> menuIdList);
|
||||
|
||||
/**
|
||||
* 获取所有菜单的id和父级id的映射关系
|
||||
*
|
||||
* @return 菜单id和父级id的映射关系
|
||||
* @author fengshuonan
|
||||
* @since 2024/6/24 12:38
|
||||
*/
|
||||
Map<Long, Long> getMenuIdParentIdMap();
|
||||
|
||||
/**
|
||||
* 将指定的菜单补全父级菜单
|
||||
* <p>
|
||||
|
|
|
@ -290,6 +290,21 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
return sysMenuList.stream().collect(Collectors.toMap(SysMenu::getMenuId, SysMenu::getMenuParentId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getMenuOptions(Long menuId, Set<Long> roleLimitMenuIdsAndOptionIds) {
|
||||
LambdaQueryWrapper<SysMenuOptions> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysMenuOptions::getMenuId, menuId);
|
||||
if (ObjectUtil.isNotEmpty(roleLimitMenuIdsAndOptionIds)) {
|
||||
queryWrapper.in(SysMenuOptions::getMenuOptionId, roleLimitMenuIdsAndOptionIds);
|
||||
}
|
||||
queryWrapper.select(SysMenuOptions::getMenuOptionId);
|
||||
List<SysMenuOptions> list = sysMenuOptionsService.list(queryWrapper);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return list.stream().map(SysMenuOptions::getMenuOptionId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenu> completeParentMenu(List<SysMenu> menuList) {
|
||||
if (ObjectUtil.isEmpty(menuList)) {
|
||||
|
|
|
@ -3,9 +3,8 @@ package cn.stylefeng.roses.kernel.sys.modular.role.service.impl;
|
|||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.sys.api.enums.PermissionNodeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.api.factory.MenuPathCalcFactory;
|
||||
import cn.stylefeng.roses.kernel.sys.api.pojo.role.request.RoleBindPermissionRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.menu.entity.SysMenuOptions;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.menu.factory.MenuPathCalcFactory;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.menu.service.SysMenuOptionsService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.menu.service.SysMenuService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.action.RoleAssignOperateAction;
|
||||
|
@ -26,7 +25,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 角色绑定菜单的相关操作
|
||||
|
@ -91,7 +89,7 @@ public class RoleBindMenuImpl implements RoleAssignOperateAction, RoleBindLimitA
|
|||
}
|
||||
|
||||
// 2.1. 查询菜单下的所有菜单功能
|
||||
List<Long> menuOptions = this.getMenuOptions(menuId, roleLimitMenuIdsAndOptionIds);
|
||||
List<Long> menuOptions = this.sysMenuService.getMenuOptions(menuId, roleLimitMenuIdsAndOptionIds);
|
||||
|
||||
// 菜单下没有菜单功能,则直接返回
|
||||
if (ObjectUtil.isEmpty(menuOptions)) {
|
||||
|
@ -150,7 +148,7 @@ public class RoleBindMenuImpl implements RoleAssignOperateAction, RoleBindLimitA
|
|||
}
|
||||
|
||||
// 2.1. 查询菜单下的所有菜单功能
|
||||
List<Long> menuOptionsIds = this.getMenuOptions(menuId);
|
||||
List<Long> menuOptionsIds = this.sysMenuService.getMenuOptions(menuId, null);
|
||||
|
||||
// 菜单下没有菜单功能,则直接返回
|
||||
if (ObjectUtil.isEmpty(menuOptionsIds)) {
|
||||
|
@ -178,34 +176,4 @@ public class RoleBindMenuImpl implements RoleAssignOperateAction, RoleBindLimitA
|
|||
this.sysRoleLimitService.saveBatch(sysRoleLimitTotal);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单下的所有菜单功能
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/9/8 16:02
|
||||
*/
|
||||
private List<Long> getMenuOptions(Long menuId) {
|
||||
return this.getMenuOptions(menuId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单下的所有菜单功能
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/9/8 16:02
|
||||
*/
|
||||
private List<Long> getMenuOptions(Long menuId, Set<Long> roleLimitMenuIdsAndOptionIds) {
|
||||
LambdaQueryWrapper<SysMenuOptions> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysMenuOptions::getMenuId, menuId);
|
||||
if (ObjectUtil.isNotEmpty(roleLimitMenuIdsAndOptionIds)) {
|
||||
queryWrapper.in(SysMenuOptions::getMenuOptionId, roleLimitMenuIdsAndOptionIds);
|
||||
}
|
||||
queryWrapper.select(SysMenuOptions::getMenuOptionId);
|
||||
List<SysMenuOptions> list = sysMenuOptionsService.list(queryWrapper);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return list.stream().map(SysMenuOptions::getMenuOptionId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue