diff --git a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/resource/service/DefaultResourceReporter.java b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/resource/service/DefaultResourceReporter.java index 1a52743f2..8f23a6954 100644 --- a/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/resource/service/DefaultResourceReporter.java +++ b/kernel-s-system/system-business-permission/src/main/java/cn/stylefeng/roses/kernel/sys/modular/resource/service/DefaultResourceReporter.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.concurrent.CompletableFuture; /** * 资源扫描的搜集 @@ -48,9 +49,6 @@ public class DefaultResourceReporter implements ResourceReportApi { return new ArrayList<>(); } - // 根据project删除该项目下的所有资源 - this.sysResourceService.deleteResourceByProjectCode(projectCode); - // 获取当前应用的所有资源 ArrayList allResources = new ArrayList<>(); ArrayList resourceDefinitionArrayList = new ArrayList<>(); @@ -63,8 +61,12 @@ public class DefaultResourceReporter implements ResourceReportApi { } } - // 将资源存入库中 - sysResourceService.batchSaveResourceList(allResources); + CompletableFuture.runAsync(() -> { + // 根据project删除该项目下的所有资源 + this.sysResourceService.deleteResourceByProjectCode(projectCode); + // 将资源存入库中 + sysResourceService.batchSaveResourceList(allResources); + }); // 将资源存入缓存一份 Map resourceDefinitionMap = ResourceFactory.orderedResourceDefinition(resourceDefinitionArrayList); diff --git a/kernel-s-system/system-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/sys/starter/init/InitAdminService.java b/kernel-s-system/system-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/sys/starter/init/InitAdminService.java index 83f0be5ef..019bbb288 100644 --- a/kernel-s-system/system-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/sys/starter/init/InitAdminService.java +++ b/kernel-s-system/system-spring-boot-starter/src/main/java/cn/stylefeng/roses/kernel/sys/starter/init/InitAdminService.java @@ -27,8 +27,6 @@ package cn.stylefeng.roses.kernel.sys.starter.init; import cn.stylefeng.roses.kernel.db.mp.tenant.holder.TenantIdHolder; import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants; import cn.stylefeng.roses.kernel.sys.api.expander.TenantConfigExpander; -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.service.SysMenuOptionsService; import cn.stylefeng.roses.kernel.sys.modular.menu.service.SysMenuService; import cn.stylefeng.roses.kernel.sys.modular.role.entity.SysRole; @@ -40,7 +38,7 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; +import java.util.concurrent.CompletableFuture; /** * 初始化admin管理员的服务 @@ -88,13 +86,16 @@ public class InitAdminService { TenantIdHolder.remove(); } - // 获取所有的菜单和功能 - List totalMenuList = sysMenuService.getTotalMenuList(); - List totalMenuOptionsList = sysMenuOptionsService.getTotalMenuOptionsList(); + // 获取所有的菜单和绑定所有的菜单 + CompletableFuture.supplyAsync(() -> sysMenuService.getTotalMenuList()).thenAccept((totalMenuList) -> { + sysRoleMenuService.bindRoleMenus(superAdminRole.getRoleId(), totalMenuList); + }); + + // 获取所有的菜单功能和绑定所有的菜单功能 + CompletableFuture.supplyAsync(() -> sysMenuOptionsService.getTotalMenuOptionsList()).thenAccept((totalMenuOptionsList) -> { + sysRoleMenuOptionsService.bindRoleMenuOptions(superAdminRole.getRoleId(), totalMenuOptionsList); + }); - // 后台管理员绑定所有的菜单和菜单功能 - sysRoleMenuService.bindRoleMenus(superAdminRole.getRoleId(), totalMenuList); - sysRoleMenuOptionsService.bindRoleMenuOptions(superAdminRole.getRoleId(), totalMenuOptionsList); } }