mirror of https://gitee.com/stylefeng/roses
【8.3.0】【resource】更新资源存库和初始化角色权限的异步化
parent
696e876a39
commit
1adb01dfc0
|
@ -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<SysResource> allResources = new ArrayList<>();
|
||||
ArrayList<ResourceDefinition> 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<String, ResourceDefinition> resourceDefinitionMap = ResourceFactory.orderedResourceDefinition(resourceDefinitionArrayList);
|
||||
|
|
|
@ -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<SysMenu> totalMenuList = sysMenuService.getTotalMenuList();
|
||||
List<SysMenuOptions> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue