diff --git a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/AppServiceApi.java b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/AppServiceApi.java index 7901b52bc..b26f64195 100644 --- a/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/AppServiceApi.java +++ b/kernel-s-system/system-api/src/main/java/cn/stylefeng/roses/kernel/system/AppServiceApi.java @@ -32,4 +32,13 @@ public interface AppServiceApi { */ String getAppNameByAppCode(String appCode); + /** + * 获取当前激活的应用编码 + * + * @return 激活的应用编码 + * @author fengshuonan + * @date 2021/1/8 19:01 + */ + String getActiveAppCode(); + } diff --git a/kernel-s-system/system-business-app/src/main/java/cn/stylefeng/roses/kernel/app/modular/service/impl/SysAppServiceImpl.java b/kernel-s-system/system-business-app/src/main/java/cn/stylefeng/roses/kernel/app/modular/service/impl/SysAppServiceImpl.java index 63a56f5bf..92a830cbe 100644 --- a/kernel-s-system/system-business-app/src/main/java/cn/stylefeng/roses/kernel/app/modular/service/impl/SysAppServiceImpl.java +++ b/kernel-s-system/system-business-app/src/main/java/cn/stylefeng/roses/kernel/app/modular/service/impl/SysAppServiceImpl.java @@ -183,6 +183,20 @@ public class SysAppServiceImpl extends ServiceImpl impleme } } + @Override + public String getActiveAppCode() { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.select(SysApp::getAppCode); + queryWrapper.eq(SysApp::getActiveFlag, YesOrNotEnum.Y.getCode()); + queryWrapper.eq(SysApp::getDelFlag, YesOrNotEnum.N.getCode()); + List list = this.list(queryWrapper); + if (list.isEmpty()) { + return null; + } else { + return list.get(0).getAppCode(); + } + } + /** * 获取系统应用 * diff --git a/kernel-s-system/system-business-menu/src/main/java/cn/stylefeng/roses/kernel/menu/modular/service/impl/SysMenuServiceImpl.java b/kernel-s-system/system-business-menu/src/main/java/cn/stylefeng/roses/kernel/menu/modular/service/impl/SysMenuServiceImpl.java index d572571e0..b9e821f0d 100644 --- a/kernel-s-system/system-business-menu/src/main/java/cn/stylefeng/roses/kernel/menu/modular/service/impl/SysMenuServiceImpl.java +++ b/kernel-s-system/system-business-menu/src/main/java/cn/stylefeng/roses/kernel/menu/modular/service/impl/SysMenuServiceImpl.java @@ -253,7 +253,18 @@ public class SysMenuServiceImpl extends ServiceImpl impl List currentUserMenus = this.getCurrentUserMenus(); // 组装每个应用的菜单树 - return LayuiMenusFactory.createLayuiAppIndexMenus(currentUserMenus); + List layuiAppIndexMenus = LayuiMenusFactory.createLayuiAppIndexMenus(currentUserMenus); + + // 给应用排序,激活的应用放在前边 + String activeAppCode = appServiceApi.getActiveAppCode(); + if (activeAppCode != null) { + List layuiAppIndexMenusArrayList = + layuiAppIndexMenus.stream().filter(i -> activeAppCode.equals(i.getAppCode())).collect(Collectors.toList()); + layuiAppIndexMenusArrayList.addAll(layuiAppIndexMenus.stream().filter(i -> !activeAppCode.equals(i.getAppCode())).collect(Collectors.toList())); + return layuiAppIndexMenusArrayList; + } + + return layuiAppIndexMenus; } @Override