From 5bee81ad23320c31310229b1cc817e8854d0e481 Mon Sep 17 00:00:00 2001 From: stylefeng Date: Sun, 6 Oct 2024 21:57:21 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=908.3.0=E3=80=91=E3=80=90resource?= =?UTF-8?q?=E3=80=91=E5=AE=8C=E5=96=84=E9=94=99=E8=AF=AF=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modular/resource/service/DefaultResourceReporter.java | 6 ++++++ .../roses/kernel/sys/starter/init/InitAdminService.java | 8 ++++++++ 2 files changed, 14 insertions(+) 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 8f23a6954..7df1c6626 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 @@ -10,6 +10,7 @@ import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.SysResourcePersistenc import cn.stylefeng.roses.kernel.sys.modular.resource.entity.SysResource; import cn.stylefeng.roses.kernel.sys.modular.resource.factory.ResourceFactory; import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; @@ -26,6 +27,7 @@ import java.util.concurrent.CompletableFuture; * @since 2023/6/18 10:34 */ @Service +@Slf4j public class DefaultResourceReporter implements ResourceReportApi { @Resource @@ -64,8 +66,12 @@ public class DefaultResourceReporter implements ResourceReportApi { CompletableFuture.runAsync(() -> { // 根据project删除该项目下的所有资源 this.sysResourceService.deleteResourceByProjectCode(projectCode); + // 将资源存入库中 sysResourceService.batchSaveResourceList(allResources); + }).exceptionally(ex -> { + log.error("资源扫描保存到库中出现错误,请检查问题,以免影响后续运行!", ex); + return null; }); // 将资源存入缓存一份 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 019bbb288..33d30634c 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 @@ -35,6 +35,7 @@ import cn.stylefeng.roses.kernel.sys.modular.role.service.SysRoleMenuService; import cn.stylefeng.roses.kernel.sys.modular.role.service.SysRoleService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -47,6 +48,7 @@ import java.util.concurrent.CompletableFuture; * @since 2020/12/17 21:56 */ @Service +@Slf4j public class InitAdminService { @Resource @@ -89,11 +91,17 @@ public class InitAdminService { // 获取所有的菜单和绑定所有的菜单 CompletableFuture.supplyAsync(() -> sysMenuService.getTotalMenuList()).thenAccept((totalMenuList) -> { sysRoleMenuService.bindRoleMenus(superAdminRole.getRoleId(), totalMenuList); + }).exceptionally(ex -> { + log.error("超级管理员绑定菜单出现错误!请及时检查错误,以免影响程序后续运行!", ex); + return null; }); // 获取所有的菜单功能和绑定所有的菜单功能 CompletableFuture.supplyAsync(() -> sysMenuOptionsService.getTotalMenuOptionsList()).thenAccept((totalMenuOptionsList) -> { sysRoleMenuOptionsService.bindRoleMenuOptions(superAdminRole.getRoleId(), totalMenuOptionsList); + }).exceptionally(ex -> { + log.error("超级管理员绑定菜单功能出现错误!请及时检查错误,以免影响程序后续运行!", ex); + return null; }); }