package cn.iocoder.yudao.module.system.controller.admin.auth;
|
|
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthPermissionInfoRespVO.MenuVO;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
/** Maps already-authorized, visible menus to implemented mobile pages. Does not grant permissions. */
|
public final class MobileMenuAdapter {
|
private MobileMenuAdapter() { }
|
private static final Map<String, String> PAGES = Map.ofEntries(
|
Map.entry("mes/pro/scan-in/index", "inbound"),
|
Map.entry("mes/pro/bagCode/index", "bags"),
|
Map.entry("mes/pro/pallet/index", "pallets"),
|
Map.entry("mes/pro/batch/index", "batches"),
|
Map.entry("wls/materialstock/index", "stock"),
|
Map.entry("mes/qc/seedQuality/index", "quality"),
|
Map.entry("mes/qc/seedQuality/record", "quality-records"),
|
Map.entry("wls/productsales/index", "sales"),
|
Map.entry("wls/productissue/index", "productissue"),
|
Map.entry("wls/miscissue/index", "miscissue"),
|
Map.entry("wls/transfer/index", "transfer"),
|
Map.entry("wls/stocktaking/task/index", "stocktaking"),
|
Map.entry("wls/returnsales/index", "returnsales"),
|
Map.entry("wls/returnissue/index", "returnissue"));
|
|
public static List<MenuVO> adapt(List<MenuVO> menus) {
|
List<MenuVO> result = new ArrayList<>();
|
collect(menus, result);
|
return result;
|
}
|
|
private static void collect(List<MenuVO> menus, List<MenuVO> result) {
|
if (menus == null) return;
|
for (MenuVO menu : menus) {
|
if (!Boolean.TRUE.equals(menu.getVisible())) continue;
|
String component = menu.getComponent();
|
String key = component == null ? null : PAGES.get(component.replaceFirst("^/", ""));
|
if (key != null) {
|
result.add(MenuVO.builder().id(menu.getId()).parentId(0L).name(menu.getName())
|
.path("/mobile/" + key).component("mobile/" + key).visible(true)
|
.keepAlive(false).alwaysShow(false).build());
|
}
|
collect(menu.getChildren(), result);
|
}
|
}
|
}
|