处理问题

This commit is contained in:
wanggeng 2022-05-31 12:16:51 +08:00
parent e642afd0e2
commit 7d73684052

View File

@ -64,8 +64,8 @@ public class IndexRouteController {
}
@GetMapping("default-main/{rootMenuId}")
public ModelAndView defaultMain(@PathVariable("rootMenuId") String rootMenuId) {
@GetMapping("default-main/{menuIdAndDefaultHome}")
public ModelAndView defaultMain(@PathVariable("menuIdAndDefaultHome") String menuIdAndDefaultHome) {
ModelAndView mv = new ModelAndView("default-main");
UserInfoBO userInfoBO = securityComponent.getCurrentUser();
mv.addObject("userUsername", userInfoBO.getUserUsername());
@ -89,9 +89,15 @@ public class IndexRouteController {
if (!StringUtils.isBlank(config.get(IUserCenterConst.MENU_MODE))) {
mv.addObject(IUserCenterConst.MENU_MODE, config.get(IUserCenterConst.MENU_MODE));
}
// 得到根节点菜单ID与默认home页面
String[] menuIdAndDefaultHomeArray = menuIdAndDefaultHome.split(SYSTEM_HOME_SPLIT);
String rootMenuId = menuIdAndDefaultHomeArray[0];
// 处理系统菜单
if (menuBaseService != null) {
// 所有系统菜单
List<MenuDTO> systems = menuBaseService.listByParentId("0");
// 查询所有系统菜单
List<MenuDTO> systemsRootMenus = menuBaseService.listByParentId("0");
List<MenuDTO> menus;
if (securityComponent.isAdmin()) {
// 管理员
@ -99,10 +105,10 @@ public class IndexRouteController {
if (menuIds.isEmpty()) {
menus = menuBaseService.listSystemMenu(rootMenuId);
// 移除菜单中的第一个斜杠保证跳转正常
systems = MenuUtil.listSystems(systems);
systemsRootMenus = MenuUtil.listSystems(systemsRootMenus);
} else {
menus = menuBaseService.listSystemMenu(rootMenuId, menuIds);
systems = MenuUtil.listSystems(systems, menuIds);
systemsRootMenus = MenuUtil.listSystems(systemsRootMenus, menuIds);
}
} else {
// 普通用户
@ -117,16 +123,17 @@ public class IndexRouteController {
List<String> menuIds = roleMenuBaseService.listMenuId(roleIds);
menus = menuBaseService.listSystemMenu(rootMenuId, menuIds);
// 去除多余的系统
systems = MenuUtil.listSystems(systems, menuIds);
systemsRootMenus = MenuUtil.listSystems(systemsRootMenus, menuIds);
}
}
mv.addObject("menus", menus);
mv.addObject("systems", systems.isEmpty() ? null : systems);
mv.addObject("systems", systemsRootMenus.isEmpty() ? null : systemsRootMenus);
}
// 默认home页面
String defaultHome = "default-home";
// 含有系统首页分隔符并且有内容
if (rootMenuId.contains(SYSTEM_HOME_SPLIT) && !rootMenuId.endsWith(SYSTEM_HOME_SPLIT)) {
if (menuIdAndDefaultHomeArray.length > 1) {
String systemHomeUrl = rootMenuId.split(SYSTEM_HOME_SPLIT)[1];
if (!StringUtils.isBlank(systemHomeUrl)) {
defaultHome = systemHomeUrl;