From d21dcba1ee816e201e55b8a9460f47165eaca31f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 5 Mar 2023 21:59:45 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E7=A7=9F=E6=88=B7?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=8A=A5=E9=94=99=202.=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=203.=20=E4=BF=AE=E5=A4=8D=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YudaoDeptDataPermissionAutoConfiguration.java | 14 +++++++++++++- .../operatelog/core/aop/OperateLogAspect.java | 2 +- .../service/OperateLogFrameworkServiceImpl.java | 1 - .../core/security/TenantSecurityWebFilter.java | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/config/YudaoDeptDataPermissionAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/config/YudaoDeptDataPermissionAutoConfiguration.java index 6016fcdad..dfc11bea0 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/config/YudaoDeptDataPermissionAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/main/java/cn/iocoder/yudao/framework/datapermission/config/YudaoDeptDataPermissionAutoConfiguration.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.framework.datapermission.config; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.extra.spring.SpringUtil; import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRule; import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer; import cn.iocoder.yudao.framework.security.core.LoginUser; @@ -10,6 +12,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; import java.util.List; +import java.util.Map; /** * 基于部门的数据权限 AutoConfiguration @@ -18,12 +21,21 @@ import java.util.List; */ @AutoConfiguration @ConditionalOnClass(LoginUser.class) -@ConditionalOnBean(value = {PermissionApi.class, DeptDataPermissionRuleCustomizer.class}) +@ConditionalOnBean(value = DeptDataPermissionRuleCustomizer.class) public class YudaoDeptDataPermissionAutoConfiguration { @Bean public DeptDataPermissionRule deptDataPermissionRule(PermissionApi permissionApi, List customizers) { + // Cloud 专属逻辑:优先使用本地的 PermissionApi 实现类,而不是 Feign 调用 + // 原因:在创建租户时,租户还没创建好,导致 Feign 调用获取数据权限时,报“租户不存在”的错误 + try { + PermissionApi permissionApiImpl = SpringUtil.getBean("permissionApiImpl", PermissionApi.class); + if (permissionApiImpl != null) { + permissionApi = permissionApiImpl; + } + } catch (Exception ignored) {} + // 创建 DeptDataPermissionRule 对象 DeptDataPermissionRule rule = new DeptDataPermissionRule(permissionApi); // 补全表配置 diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java index 5db6baae4..d0bbaf0c4 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java @@ -196,7 +196,7 @@ public class OperateLogAspect { operateLogObj.setName(operateLog.name()); } if (StrUtil.isEmpty(operateLogObj.getName()) && operation != null) { - operateLogObj.setName(operation.description()); + operateLogObj.setName(operation.summary()); } // type 属性 if (operateLog != null && ArrayUtil.isNotEmpty(operateLog.type())) { diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java index 845889d83..5581aed22 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/service/OperateLogFrameworkServiceImpl.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.framework.operatelog.core.service; import cn.hutool.core.bean.BeanUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO; import lombok.RequiredArgsConstructor; diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java index 803e541c5..27c75eb88 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/security/TenantSecurityWebFilter.java @@ -66,7 +66,7 @@ public class TenantSecurityWebFilter extends ApiRequestFilter { protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { Long tenantId = TenantContextHolder.getTenantId(); - boolean isRpcRequest = !WebFrameworkUtils.isRpcRequest(request); + boolean isRpcRequest = WebFrameworkUtils.isRpcRequest(request); // 1. 登陆的用户,校验是否有权限访问该租户,避免越权问题。 LoginUser user = SecurityFrameworkUtils.getLoginUser(); if (user != null) {