Merge branch 'test' of http://172.16.46.63:30001/gitlab/base-version/ztcloud into test
This commit is contained in:
13
pom.xml
13
pom.xml
@@ -242,6 +242,19 @@
|
||||
<config.version>1.0.0</config.version>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>klw-dev</id>
|
||||
<properties>
|
||||
<env.name>dev</env.name>
|
||||
<!--Nacos 配置-->
|
||||
<config.server-addr>172.16.46.63:30848</config.server-addr>
|
||||
<config.namespace>klw</config.namespace>
|
||||
<config.group>DEFAULT_GROUP</config.group>
|
||||
<config.username>nacos</config.username>
|
||||
<config.password>P@ssword25</config.password>
|
||||
<config.version>1.0.0</config.version>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>env-prod</id>
|
||||
<properties>
|
||||
|
||||
@@ -120,6 +120,7 @@ CREATE TABLE bpm_process_definition_info (
|
||||
simple_model text NULL,
|
||||
sort bigint DEFAULT 0 NULL,
|
||||
visible bit DEFAULT '1' NOT NULL,
|
||||
restart bit DEFAULT '1' NOT NULL,
|
||||
start_user_ids varchar(256) DEFAULT NULL NULL,
|
||||
start_dept_ids varchar(256) DEFAULT NULL NULL,
|
||||
manager_user_ids varchar(256) DEFAULT NULL NULL,
|
||||
@@ -156,6 +157,7 @@ COMMENT ON COLUMN bpm_process_definition_info.form_custom_view_path IS '自定
|
||||
COMMENT ON COLUMN bpm_process_definition_info.simple_model IS 'SIMPLE 设计器模型数据 JSON 格式';
|
||||
COMMENT ON COLUMN bpm_process_definition_info.sort IS '排序值';
|
||||
COMMENT ON COLUMN bpm_process_definition_info.visible IS '是否可见';
|
||||
COMMENT ON COLUMN bpm_process_definition_info.restart IS '是否允许重新发起';
|
||||
COMMENT ON COLUMN bpm_process_definition_info.start_user_ids IS '可发起用户编号数组';
|
||||
COMMENT ON COLUMN bpm_process_definition_info.start_dept_ids IS '可发起部门编号数组';
|
||||
COMMENT ON COLUMN bpm_process_definition_info.manager_user_ids IS '可管理用户编号数组';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
10
sql/dm/流程定义扩展信息表新增字段_20251230.sql
Normal file
10
sql/dm/流程定义扩展信息表新增字段_20251230.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- 达梦8数据库DDL脚本
|
||||
-- 为 bpm_process_definition_info 表添加 restart 字段
|
||||
|
||||
-- 是否允许重新发起
|
||||
ALTER TABLE bpm_process_definition_info ADD COLUMN restart bit DEFAULT '1' NOT NULL;
|
||||
|
||||
-- 添加字段注释
|
||||
COMMENT ON COLUMN bpm_process_definition_info.restart IS '是否允许重新发起';
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.zt.plat.framework.common.util.json.JsonUtils;
|
||||
import com.zt.plat.framework.common.util.spring.SpringUtils;
|
||||
import com.zt.plat.framework.security.core.LoginUser;
|
||||
import com.zt.plat.framework.tenant.core.context.CompanyContextHolder;
|
||||
import com.zt.plat.framework.tenant.core.context.DeptContextHolder;
|
||||
import com.zt.plat.framework.web.core.util.WebFrameworkUtils;
|
||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||
import com.zt.plat.module.system.api.dept.dto.CompanyDeptInfoRespDTO;
|
||||
@@ -197,6 +198,9 @@ public class BusinessDeptHandleUtil {
|
||||
}
|
||||
CompanyContextHolder.setIgnore(false);
|
||||
CompanyContextHolder.setCompanyId(Long.valueOf(info.getCompanyId()));
|
||||
DeptContextHolder.setIgnore(false);
|
||||
DeptContextHolder.setCompanyId(Long.valueOf(info.getCompanyId()));
|
||||
DeptContextHolder.setDeptId(Long.valueOf(info.getDeptId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# 数据权限忽略与上下文覆盖说明
|
||||
|
||||
本文说明新增的公司/部门数据权限忽略能力,以及部门上下文对数据权限的覆盖策略。
|
||||
|
||||
## 新增注解
|
||||
|
||||
- `@CompanyDataPermissionIgnore(enable = "true")`
|
||||
- `@DeptDataPermissionIgnore(enable = "true")`
|
||||
|
||||
用法:
|
||||
- 可标记在类或方法上。
|
||||
- `enable` 支持 Spring EL,计算结果为 `true` 时生效,默认开启。
|
||||
- 生效后,在方法执行期间临时设置忽略标记,结束后自动恢复。
|
||||
|
||||
## 忽略生效范围
|
||||
|
||||
- 公司数据权限:切面在进入方法时将 `CompanyContextHolder.setIgnore(true)`,数据权限规则检测到后直接放行。
|
||||
- 部门数据权限:切面在进入方法时将 `DeptContextHolder.setIgnore(true)`,部门数据权限规则检测到后直接放行。
|
||||
|
||||
## 部门上下文覆盖策略
|
||||
|
||||
当未忽略部门数据权限且上下文存在有效部门 ID 时:
|
||||
- 优先使用上下文中的单一部门作为过滤条件,避免因默认的 `ALL` 或“无部门且不可查看自己”导致放行或误判无权。
|
||||
- 上下文部门不会修改原有的数据权限 DTO,仅在当前计算中使用。
|
||||
- 若上下文公司与缓存公司不一致,会记录告警日志,但仍按上下文部门过滤。
|
||||
|
||||
## 典型场景
|
||||
|
||||
1) **任务/全局调用需要暂时关闭数据权限**
|
||||
- 在方法上标记 `@DeptDataPermissionIgnore` 或 `@CompanyDataPermissionIgnore`。
|
||||
|
||||
2) **带部门上下文的接口调用**
|
||||
- 请求预先设置 `DeptContextHolder.setContext(deptId, companyId)`。
|
||||
- 即便数据权限声明为 `all=true`,也会按该部门过滤,避免读出全量。
|
||||
|
||||
3) **无部门权限但指定了上下文部门**
|
||||
- 即使 `deptIds` 为空且 `self=false`,只要上下文提供部门,也会使用该部门过滤,而非直接判定无权。
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 忽略标记只作用于当前线程上下文,切面会在 `finally` 中恢复旧值,嵌套调用安全。
|
||||
- 若需要同时忽略公司与部门数据权限,可叠加两个注解或在业务代码中分别设置忽略标记。
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zt.plat.framework.datapermission.config;
|
||||
|
||||
import com.zt.plat.framework.datapermission.core.aop.CompanyDataPermissionIgnoreAspect;
|
||||
import com.zt.plat.framework.datapermission.core.aop.DataPermissionAnnotationAdvisor;
|
||||
import com.zt.plat.framework.datapermission.core.aop.DeptDataPermissionIgnoreAspect;
|
||||
import com.zt.plat.framework.datapermission.core.db.DataPermissionRuleHandler;
|
||||
import com.zt.plat.framework.datapermission.core.rule.DataPermissionRule;
|
||||
import com.zt.plat.framework.datapermission.core.rule.DataPermissionRuleFactory;
|
||||
@@ -43,4 +45,14 @@ public class ZtDataPermissionAutoConfiguration {
|
||||
return new DataPermissionAnnotationAdvisor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DeptDataPermissionIgnoreAspect deptDataPermissionIgnoreAspect() {
|
||||
return new DeptDataPermissionIgnoreAspect();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CompanyDataPermissionIgnoreAspect companyDataPermissionIgnoreAspect() {
|
||||
return new CompanyDataPermissionIgnoreAspect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.zt.plat.framework.datapermission.core.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 忽略公司数据权限的注解。
|
||||
* <p>
|
||||
* 标记在方法或类上时,匹配的调用会临时忽略公司类型的数据权限规则。
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface CompanyDataPermissionIgnore {
|
||||
|
||||
/**
|
||||
* 是否开启忽略,默认开启。
|
||||
* 支持 Spring EL 表达式,返回 true 时生效。
|
||||
*/
|
||||
String enable() default "true";
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.zt.plat.framework.datapermission.core.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 忽略部门数据权限的注解。
|
||||
* <p>
|
||||
* 标记在方法或类上时,匹配的调用会临时忽略部门类型的数据权限规则。
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface DeptDataPermissionIgnore {
|
||||
|
||||
/**
|
||||
* 是否开启忽略,默认开启。
|
||||
* 支持 Spring EL 表达式,返回 true 时生效。
|
||||
*/
|
||||
String enable() default "true";
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.zt.plat.framework.datapermission.core.aop;
|
||||
|
||||
import com.zt.plat.framework.common.util.spring.SpringExpressionUtils;
|
||||
import com.zt.plat.framework.datapermission.core.annotation.CompanyDataPermissionIgnore;
|
||||
import com.zt.plat.framework.tenant.core.context.CompanyContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
|
||||
/**
|
||||
* 公司数据权限忽略切面,基于 {@link CompanyDataPermissionIgnore} 注解。
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
public class CompanyDataPermissionIgnoreAspect {
|
||||
|
||||
@Around("@within(companyDataPermissionIgnore) || @annotation(companyDataPermissionIgnore)")
|
||||
public Object around(ProceedingJoinPoint joinPoint, CompanyDataPermissionIgnore companyDataPermissionIgnore) throws Throwable {
|
||||
boolean oldIgnore = CompanyContextHolder.isIgnore();
|
||||
try {
|
||||
Object enable = SpringExpressionUtils.parseExpression(companyDataPermissionIgnore.enable());
|
||||
if (Boolean.TRUE.equals(enable)) {
|
||||
CompanyContextHolder.setIgnore(true);
|
||||
}
|
||||
return joinPoint.proceed();
|
||||
} finally {
|
||||
CompanyContextHolder.setIgnore(oldIgnore);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user