【8.3.1】【role】整理一些基础通用接口的封装

master
stylefeng 2024-10-31 10:04:31 +08:00
parent 11378e8899
commit 191b580fba
5 changed files with 38 additions and 46 deletions

View File

@ -65,4 +65,23 @@ public interface SysMenuServiceApi {
*/ */
Set<Long> getAppMenuAndOptionIds(Long appId); Set<Long> getAppMenuAndOptionIds(Long appId);
/**
* idid
*
* @return idid
* @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);
} }

View File

@ -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; import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;

View File

@ -7,7 +7,6 @@ import cn.stylefeng.roses.kernel.sys.modular.menu.pojo.response.AppGroupDetail;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
@ -125,15 +124,6 @@ public interface SysMenuService extends IService<SysMenu>, SysMenuServiceApi {
*/ */
List<String> getMenuCodeList(List<Long> menuIdList); List<String> getMenuCodeList(List<Long> menuIdList);
/**
* idid
*
* @return idid
* @author fengshuonan
* @since 2024/6/24 12:38
*/
Map<Long, Long> getMenuIdParentIdMap();
/** /**
* *
* <p> * <p>

View File

@ -290,6 +290,21 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
return sysMenuList.stream().collect(Collectors.toMap(SysMenu::getMenuId, SysMenu::getMenuParentId)); 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 @Override
public List<SysMenu> completeParentMenu(List<SysMenu> menuList) { public List<SysMenu> completeParentMenu(List<SysMenu> menuList) {
if (ObjectUtil.isEmpty(menuList)) { if (ObjectUtil.isEmpty(menuList)) {

View File

@ -3,9 +3,8 @@ package cn.stylefeng.roses.kernel.sys.modular.role.service.impl;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.sys.api.enums.PermissionNodeTypeEnum; 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.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.SysMenuOptionsService;
import cn.stylefeng.roses.kernel.sys.modular.menu.service.SysMenuService; import cn.stylefeng.roses.kernel.sys.modular.menu.service.SysMenuService;
import cn.stylefeng.roses.kernel.sys.modular.role.action.RoleAssignOperateAction; 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.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* *
@ -91,7 +89,7 @@ public class RoleBindMenuImpl implements RoleAssignOperateAction, RoleBindLimitA
} }
// 2.1. 查询菜单下的所有菜单功能 // 2.1. 查询菜单下的所有菜单功能
List<Long> menuOptions = this.getMenuOptions(menuId, roleLimitMenuIdsAndOptionIds); List<Long> menuOptions = this.sysMenuService.getMenuOptions(menuId, roleLimitMenuIdsAndOptionIds);
// 菜单下没有菜单功能,则直接返回 // 菜单下没有菜单功能,则直接返回
if (ObjectUtil.isEmpty(menuOptions)) { if (ObjectUtil.isEmpty(menuOptions)) {
@ -150,7 +148,7 @@ public class RoleBindMenuImpl implements RoleAssignOperateAction, RoleBindLimitA
} }
// 2.1. 查询菜单下的所有菜单功能 // 2.1. 查询菜单下的所有菜单功能
List<Long> menuOptionsIds = this.getMenuOptions(menuId); List<Long> menuOptionsIds = this.sysMenuService.getMenuOptions(menuId, null);
// 菜单下没有菜单功能,则直接返回 // 菜单下没有菜单功能,则直接返回
if (ObjectUtil.isEmpty(menuOptionsIds)) { if (ObjectUtil.isEmpty(menuOptionsIds)) {
@ -178,34 +176,4 @@ public class RoleBindMenuImpl implements RoleAssignOperateAction, RoleBindLimitA
this.sysRoleLimitService.saveBatch(sysRoleLimitTotal); 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());
}
} }