mirror of https://gitee.com/stylefeng/roses
【8.3.1】【system】获取应用下所有的菜单和功能id
parent
650263e99f
commit
a311ae31af
|
@ -57,4 +57,12 @@ public interface SysMenuServiceApi {
|
||||||
*/
|
*/
|
||||||
Map<Long, Long> getMenuAppId(List<Long> menuIdList);
|
Map<Long, Long> getMenuAppId(List<Long> menuIdList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定应用下的所有菜单和功能的id
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2024/10/31 0:22
|
||||||
|
*/
|
||||||
|
Set<Long> getAppMenuAndOptionIds(Long appId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import cn.stylefeng.roses.kernel.sys.api.pojo.menu.UserAppMenuInfo;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.app.service.SysAppService;
|
import cn.stylefeng.roses.kernel.sys.modular.app.service.SysAppService;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.menu.constants.MenuConstants;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.constants.MenuConstants;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.menu.entity.SysMenu;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.entity.SysMenu;
|
||||||
|
import cn.stylefeng.roses.kernel.sys.modular.menu.entity.SysMenuOptions;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.menu.enums.SysMenuExceptionEnum;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.enums.SysMenuExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.menu.factory.MenuFactory;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.factory.MenuFactory;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.menu.factory.MenuTreeFactory;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.factory.MenuTreeFactory;
|
||||||
|
@ -25,6 +26,7 @@ import cn.stylefeng.roses.kernel.sys.modular.menu.factory.MenuValidateFactory;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.menu.mapper.SysMenuMapper;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.mapper.SysMenuMapper;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.menu.pojo.request.SysMenuRequest;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.pojo.request.SysMenuRequest;
|
||||||
import cn.stylefeng.roses.kernel.sys.modular.menu.pojo.response.AppGroupDetail;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.pojo.response.AppGroupDetail;
|
||||||
|
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.menu.util.MenuOrderFixUtil;
|
import cn.stylefeng.roses.kernel.sys.modular.menu.util.MenuOrderFixUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
@ -54,6 +56,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
@Resource(name = "menuCodeCache")
|
@Resource(name = "menuCodeCache")
|
||||||
private CacheOperatorApi<String> menuCodeCache;
|
private CacheOperatorApi<String> menuCodeCache;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SysMenuOptionsService sysMenuOptionsService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(SysMenuRequest sysMenuRequest) {
|
public void add(SysMenuRequest sysMenuRequest) {
|
||||||
|
|
||||||
|
@ -425,6 +430,38 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||||
return menuIdAppIdMap;
|
return menuIdAppIdMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Long> getAppMenuAndOptionIds(Long appId) {
|
||||||
|
|
||||||
|
Set<Long> totalIdList = new HashSet<>();
|
||||||
|
if (ObjectUtil.isEmpty(appId)) {
|
||||||
|
return totalIdList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取应用下的所有菜单id
|
||||||
|
LambdaQueryWrapper<SysMenu> sysMenuLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
sysMenuLambdaQueryWrapper.eq(SysMenu::getAppId, appId);
|
||||||
|
sysMenuLambdaQueryWrapper.select(SysMenu::getMenuId);
|
||||||
|
List<SysMenu> list = this.list(sysMenuLambdaQueryWrapper);
|
||||||
|
if (ObjectUtil.isEmpty(totalIdList)) {
|
||||||
|
return totalIdList;
|
||||||
|
}
|
||||||
|
Set<Long> menuIdList = list.stream().map(SysMenu::getMenuId).collect(Collectors.toSet());
|
||||||
|
totalIdList.addAll(menuIdList);
|
||||||
|
|
||||||
|
// 获取应用下的所有功能id
|
||||||
|
LambdaQueryWrapper<SysMenuOptions> optionsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
optionsLambdaQueryWrapper.eq(SysMenuOptions::getAppId, appId);
|
||||||
|
optionsLambdaQueryWrapper.select(SysMenuOptions::getMenuOptionId);
|
||||||
|
List<SysMenuOptions> optionsList = sysMenuOptionsService.list(optionsLambdaQueryWrapper);
|
||||||
|
if (ObjectUtil.isNotEmpty(optionsList)) {
|
||||||
|
Set<Long> optionIdList = optionsList.stream().map(SysMenuOptions::getMenuOptionId).collect(Collectors.toSet());
|
||||||
|
totalIdList.addAll(optionIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalIdList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取信息
|
* 获取信息
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue