【8.3.1】【system】获取应用下所有的菜单和功能id

master
stylefeng 2024-10-31 00:28:32 +08:00
parent 650263e99f
commit a311ae31af
2 changed files with 45 additions and 0 deletions

View File

@ -57,4 +57,12 @@ public interface SysMenuServiceApi {
*/
Map<Long, Long> getMenuAppId(List<Long> menuIdList);
/**
* id
*
* @author fengshuonan
* @since 2024/10/31 0:22
*/
Set<Long> getAppMenuAndOptionIds(Long appId);
}

View File

@ -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.menu.constants.MenuConstants;
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.factory.MenuFactory;
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.pojo.request.SysMenuRequest;
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.util.MenuOrderFixUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -54,6 +56,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
@Resource(name = "menuCodeCache")
private CacheOperatorApi<String> menuCodeCache;
@Resource
private SysMenuOptionsService sysMenuOptionsService;
@Override
public void add(SysMenuRequest sysMenuRequest) {
@ -425,6 +430,38 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
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;
}
/**
*
*