mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 02:39:19 +08:00
调整获取用户路由的接口
This commit is contained in:
-7
@@ -62,11 +62,4 @@ public interface CompanyMenuService extends IService<CompanyMenuPO> {
|
||||
*/
|
||||
List<MenuVO> getCompanyMenusForRoute(Long companyId);
|
||||
|
||||
/**
|
||||
* 根据职位获取菜单(以MenuVO格式返回,用于动态路由)
|
||||
*
|
||||
* @param positionId 职位ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<MenuVO> getPositionMenusForRoute(Long positionId);
|
||||
}
|
||||
|
||||
+9
@@ -2,6 +2,7 @@ package top.xyquan.ecomdmbbackend.modules.org.service;
|
||||
|
||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.position.BatchAssignPositionMenuDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.PositionMenuVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,4 +50,12 @@ public interface PositionCompanyMenuService {
|
||||
* @return 是否有权限
|
||||
*/
|
||||
boolean hasPositionMenu(Long positionId, Long companyMenuId);
|
||||
|
||||
/**
|
||||
* 根据职位获取菜单(以MenuVO格式返回,用于动态路由)
|
||||
*
|
||||
* @param positionId 职位ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<MenuVO> getPositionMenusForRoute(Long positionId);
|
||||
}
|
||||
|
||||
+1
-79
@@ -11,9 +11,7 @@ import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.CreateCompan
|
||||
import top.xyquan.ecomdmbbackend.modules.org.model.dto.company.menu.UpdateCompanyMenuDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.model.po.CompanyMenuPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.CompanyMenuVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.model.vo.PositionMenuVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyMenuService;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.service.PositionCompanyMenuService;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.po.MenuPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.service.MenuService;
|
||||
@@ -32,11 +30,9 @@ public class CompanyMenuServiceImpl extends ServiceImpl<CompanyMenuMapper, Compa
|
||||
implements CompanyMenuService {
|
||||
|
||||
private final MenuService menuService;
|
||||
private final PositionCompanyMenuService positionCompanyMenuService;
|
||||
|
||||
public CompanyMenuServiceImpl(MenuService menuService, PositionCompanyMenuService positionCompanyMenuService) {
|
||||
public CompanyMenuServiceImpl(MenuService menuService) {
|
||||
this.menuService = menuService;
|
||||
this.positionCompanyMenuService = positionCompanyMenuService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,80 +234,6 @@ public class CompanyMenuServiceImpl extends ServiceImpl<CompanyMenuMapper, Compa
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuVO> getPositionMenusForRoute(Long positionId) {
|
||||
// 使用PositionCompanyMenuService的现有方法获取职位菜单权限
|
||||
List<PositionMenuVO> positionMenus = positionCompanyMenuService.getMenusByPositionId(positionId);
|
||||
|
||||
if (positionMenus.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 获取公司菜单ID列表
|
||||
List<Long> companyMenuIds = positionMenus.stream()
|
||||
.map(PositionMenuVO::getCompanyMenuId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查询公司菜单信息
|
||||
LambdaQueryWrapper<CompanyMenuPO> companyMenuWrapper = new LambdaQueryWrapper<>();
|
||||
companyMenuWrapper.in(CompanyMenuPO::getId, companyMenuIds)
|
||||
.eq(CompanyMenuPO::getStatus, 1) // 只查询启用的菜单
|
||||
.orderByAsc(CompanyMenuPO::getCustomOrder);
|
||||
|
||||
List<CompanyMenuPO> companyMenus = this.list(companyMenuWrapper);
|
||||
|
||||
if (companyMenus.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 获取菜单ID列表
|
||||
List<Long> menuIds = companyMenus.stream()
|
||||
.map(CompanyMenuPO::getMenuId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查询系统菜单信息
|
||||
LambdaQueryWrapper<MenuPO> menuWrapper = new LambdaQueryWrapper<>();
|
||||
menuWrapper.in(MenuPO::getId, menuIds)
|
||||
.eq(MenuPO::getStatus, 1) // 只查询启用的菜单
|
||||
.orderByAsc(MenuPO::getOrder);
|
||||
|
||||
List<MenuPO> menus = menuService.list(menuWrapper);
|
||||
|
||||
// 构建公司菜单ID到公司菜单的映射
|
||||
Map<Long, CompanyMenuPO> companyMenuMap = companyMenus.stream()
|
||||
.collect(Collectors.toMap(CompanyMenuPO::getId, cm -> cm));
|
||||
|
||||
// 转换为MenuVO,使用公司自定义字段
|
||||
return menus.stream()
|
||||
.map(menu -> {
|
||||
MenuVO menuVO = new MenuVO();
|
||||
BeanUtils.copyProperties(menu, menuVO);
|
||||
|
||||
// 查找对应的公司菜单
|
||||
CompanyMenuPO companyMenu = companyMenuMap.values().stream()
|
||||
.filter(cm -> cm.getMenuId().equals(menu.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (companyMenu != null) {
|
||||
if (companyMenu.getCustomName() != null) {
|
||||
menuVO.setName(companyMenu.getCustomName());
|
||||
}
|
||||
if (companyMenu.getCustomTitle() != null) {
|
||||
menuVO.setTitle(companyMenu.getCustomTitle());
|
||||
}
|
||||
if (companyMenu.getCustomIcon() != null) {
|
||||
menuVO.setIcon(companyMenu.getCustomIcon());
|
||||
}
|
||||
if (companyMenu.getCustomOrder() != null) {
|
||||
menuVO.setOrder(companyMenu.getCustomOrder());
|
||||
}
|
||||
}
|
||||
|
||||
return menuVO;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
|
||||
+83
-1
@@ -2,6 +2,7 @@ package top.xyquan.ecomdmbbackend.modules.org.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.xyquan.ecomdmbbackend.common.exception.BusinessException;
|
||||
@@ -14,6 +15,9 @@ import top.xyquan.ecomdmbbackend.modules.org.model.vo.PositionMenuVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyMenuService;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.service.PositionCompanyMenuService;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.service.PositionService;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.po.MenuPO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.service.MenuService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -31,13 +35,16 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
||||
private final CurrentUserContext currentUserContext;
|
||||
private final PositionService positionService;
|
||||
private final CompanyMenuService companyMenuService;
|
||||
private final MenuService menuService;
|
||||
|
||||
public PositionCompanyMenuServiceImpl(CurrentUserContext currentUserContext,
|
||||
PositionService positionService,
|
||||
CompanyMenuService companyMenuService) {
|
||||
CompanyMenuService companyMenuService,
|
||||
MenuService menuService) {
|
||||
this.currentUserContext = currentUserContext;
|
||||
this.positionService = positionService;
|
||||
this.companyMenuService = companyMenuService;
|
||||
this.menuService = menuService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -198,4 +205,79 @@ public class PositionCompanyMenuServiceImpl extends ServiceImpl<PositionCompanyM
|
||||
|
||||
return this.count(wrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MenuVO> getPositionMenusForRoute(Long positionId) {
|
||||
// 使用现有的方法获取职位菜单权限
|
||||
List<PositionMenuVO> positionMenus = this.getMenusByPositionId(positionId);
|
||||
|
||||
if (positionMenus.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 获取公司菜单ID列表
|
||||
List<Long> companyMenuIds = positionMenus.stream()
|
||||
.map(PositionMenuVO::getCompanyMenuId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查询公司菜单信息
|
||||
LambdaQueryWrapper<CompanyMenuPO> companyMenuWrapper = new LambdaQueryWrapper<>();
|
||||
companyMenuWrapper.in(CompanyMenuPO::getId, companyMenuIds)
|
||||
.eq(CompanyMenuPO::getStatus, 1) // 只查询启用的菜单
|
||||
.orderByAsc(CompanyMenuPO::getCustomOrder);
|
||||
|
||||
List<CompanyMenuPO> companyMenus = companyMenuService.list(companyMenuWrapper);
|
||||
|
||||
if (companyMenus.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 获取菜单ID列表
|
||||
List<Long> menuIds = companyMenus.stream()
|
||||
.map(CompanyMenuPO::getMenuId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查询系统菜单信息
|
||||
LambdaQueryWrapper<MenuPO> menuWrapper = new LambdaQueryWrapper<>();
|
||||
menuWrapper.in(MenuPO::getId, menuIds)
|
||||
.eq(MenuPO::getStatus, 1) // 只查询启用的菜单
|
||||
.orderByAsc(MenuPO::getOrder);
|
||||
|
||||
List<MenuPO> menus = menuService.list(menuWrapper);
|
||||
|
||||
// 构建公司菜单ID到公司菜单的映射
|
||||
Map<Long, CompanyMenuPO> companyMenuMap = companyMenus.stream()
|
||||
.collect(Collectors.toMap(CompanyMenuPO::getId, cm -> cm));
|
||||
|
||||
// 转换为MenuVO,使用公司自定义字段
|
||||
return menus.stream()
|
||||
.map(menu -> {
|
||||
MenuVO menuVO = new MenuVO();
|
||||
BeanUtils.copyProperties(menu, menuVO);
|
||||
|
||||
// 查找对应的公司菜单
|
||||
CompanyMenuPO companyMenu = companyMenuMap.values().stream()
|
||||
.filter(cm -> cm.getMenuId().equals(menu.getId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (companyMenu != null) {
|
||||
if (companyMenu.getCustomName() != null) {
|
||||
menuVO.setName(companyMenu.getCustomName());
|
||||
}
|
||||
if (companyMenu.getCustomTitle() != null) {
|
||||
menuVO.setTitle(companyMenu.getCustomTitle());
|
||||
}
|
||||
if (companyMenu.getCustomIcon() != null) {
|
||||
menuVO.setIcon(companyMenu.getCustomIcon());
|
||||
}
|
||||
if (companyMenu.getCustomOrder() != null) {
|
||||
menuVO.setOrder(companyMenu.getCustomOrder());
|
||||
}
|
||||
}
|
||||
|
||||
return menuVO;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-45
@@ -6,12 +6,10 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyMenuService;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.dto.menu.CreateMenuDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.dto.menu.UpdateMenuDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.service.MenuService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,13 +22,9 @@ import java.util.List;
|
||||
public class MenuController {
|
||||
|
||||
private final MenuService menuService;
|
||||
private final CompanyMenuService companyMenuService;
|
||||
private final CurrentUserContext currentUserContext;
|
||||
|
||||
public MenuController(MenuService menuService, CompanyMenuService companyMenuService, CurrentUserContext currentUserContext) {
|
||||
public MenuController(MenuService menuService) {
|
||||
this.menuService = menuService;
|
||||
this.companyMenuService = companyMenuService;
|
||||
this.currentUserContext = currentUserContext;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建菜单", description = "创建新的菜单")
|
||||
@@ -86,42 +80,4 @@ public class MenuController {
|
||||
return ApiResponse.success(menuTree);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取用户菜单(动态路由)", description = "根据用户角色获取对应的菜单,用于前端动态路由")
|
||||
@GetMapping("/all")
|
||||
public ApiResponse<List<MenuVO>> getUserMenus() {
|
||||
// 获取当前用户信息
|
||||
String userRole = currentUserContext.getCurrentUserRole();
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
Long positionId = currentUserContext.getCurrentUserPositionId();
|
||||
|
||||
List<MenuVO> menus;
|
||||
|
||||
switch (userRole) {
|
||||
case "super":
|
||||
// 超级管理员获取所有系统菜单
|
||||
menus = menuService.getAllMenus();
|
||||
break;
|
||||
case "admin":
|
||||
// 公司管理员获取公司所有菜单
|
||||
if (companyId == null) {
|
||||
menus = List.of();
|
||||
} else {
|
||||
menus = companyMenuService.getCompanyMenusForRoute(companyId);
|
||||
}
|
||||
break;
|
||||
case "user":
|
||||
// 普通用户根据职位获取菜单
|
||||
if (positionId == null) {
|
||||
menus = List.of();
|
||||
} else {
|
||||
menus = companyMenuService.getPositionMenusForRoute(positionId);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
menus = List.of();
|
||||
break;
|
||||
}
|
||||
|
||||
return ApiResponse.success(menus);
|
||||
}
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.RouteVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.service.RouteService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 路由管理控制器
|
||||
*/
|
||||
@Tag(name = "系统-路由管理", description = "动态路由相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/route")
|
||||
public class RouteController {
|
||||
|
||||
private final RouteService routeService;
|
||||
|
||||
public RouteController(RouteService routeService) {
|
||||
this.routeService = routeService;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取用户路由(动态路由)", description = "根据用户角色获取对应的路由,用于前端动态路由")
|
||||
@GetMapping("/routes")
|
||||
public ApiResponse<List<RouteVO>> getUserRoutes() {
|
||||
List<RouteVO> routes = routeService.getUserRoutes();
|
||||
return ApiResponse.success(routes);
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.model.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 路由VO
|
||||
*/
|
||||
@Data
|
||||
public class RouteVO {
|
||||
|
||||
/**
|
||||
* 路由ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父路由ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 路由名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 路由标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 路由路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 页面组件
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 重定向地址
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 路由图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 顺序
|
||||
*/
|
||||
private Integer order;
|
||||
|
||||
/**
|
||||
* 路由类型 (目录,菜单,按钮,内联,外链)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 是否显示在菜单中 (0-否 1-是)
|
||||
*/
|
||||
private Integer visible;
|
||||
|
||||
/**
|
||||
* 状态 (0-禁用 1-启用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否缓存
|
||||
*/
|
||||
private Integer keepAlive;
|
||||
|
||||
/**
|
||||
* 子路由列表
|
||||
*/
|
||||
private List<RouteVO> children;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.service;
|
||||
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.RouteVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 路由服务接口
|
||||
*/
|
||||
public interface RouteService {
|
||||
|
||||
/**
|
||||
* 获取用户路由(动态路由)
|
||||
* 根据用户角色获取对应的路由,用于前端动态路由
|
||||
*
|
||||
* @return 路由列表
|
||||
*/
|
||||
List<RouteVO> getUserRoutes();
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.sys.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.service.CompanyMenuService;
|
||||
import top.xyquan.ecomdmbbackend.modules.org.service.PositionCompanyMenuService;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.MenuVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.model.vo.RouteVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.service.MenuService;
|
||||
import top.xyquan.ecomdmbbackend.modules.sys.service.RouteService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 路由服务实现类
|
||||
*/
|
||||
@Service
|
||||
public class RouteServiceImpl implements RouteService {
|
||||
|
||||
private final MenuService menuService;
|
||||
private final CompanyMenuService companyMenuService;
|
||||
private final PositionCompanyMenuService positionCompanyMenuService;
|
||||
private final CurrentUserContext currentUserContext;
|
||||
|
||||
public RouteServiceImpl(MenuService menuService,
|
||||
CompanyMenuService companyMenuService,
|
||||
PositionCompanyMenuService positionCompanyMenuService,
|
||||
CurrentUserContext currentUserContext) {
|
||||
this.menuService = menuService;
|
||||
this.companyMenuService = companyMenuService;
|
||||
this.positionCompanyMenuService = positionCompanyMenuService;
|
||||
this.currentUserContext = currentUserContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RouteVO> getUserRoutes() {
|
||||
// 获取当前用户信息
|
||||
String userRole = currentUserContext.getCurrentUserRole();
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
Long positionId = currentUserContext.getCurrentUserPositionId();
|
||||
|
||||
List<MenuVO> menus;
|
||||
|
||||
switch (userRole) {
|
||||
case "super":
|
||||
// 超级管理员获取所有系统菜单
|
||||
menus = menuService.getAllMenus();
|
||||
break;
|
||||
case "admin":
|
||||
// 公司管理员获取公司所有菜单
|
||||
if (companyId == null) {
|
||||
menus = List.of();
|
||||
} else {
|
||||
menus = companyMenuService.getCompanyMenusForRoute(companyId);
|
||||
}
|
||||
break;
|
||||
case "user":
|
||||
// 普通用户根据职位获取菜单
|
||||
if (positionId == null) {
|
||||
menus = List.of();
|
||||
} else {
|
||||
menus = positionCompanyMenuService.getPositionMenusForRoute(positionId);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
menus = List.of();
|
||||
break;
|
||||
}
|
||||
|
||||
// 转换为RouteVO
|
||||
return convertToRouteVO(menus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将MenuVO转换为RouteVO
|
||||
*/
|
||||
private List<RouteVO> convertToRouteVO(List<MenuVO> menus) {
|
||||
return menus.stream()
|
||||
.map(this::convertMenuToRoute)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将单个MenuVO转换为RouteVO
|
||||
*/
|
||||
private RouteVO convertMenuToRoute(MenuVO menu) {
|
||||
RouteVO route = new RouteVO();
|
||||
BeanUtils.copyProperties(menu, route);
|
||||
|
||||
// 如果有子菜单,递归转换
|
||||
if (menu.getChildren() != null && !menu.getChildren().isEmpty()) {
|
||||
List<RouteVO> childRoutes = menu.getChildren().stream()
|
||||
.map(this::convertMenuToRoute)
|
||||
.toList();
|
||||
route.setChildren(childRoutes);
|
||||
}
|
||||
|
||||
return route;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user