mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
feat(flow): 扩展流程发起人权限验证支持岗位类型
- 在NodeUserTypeEnum中新增POST类型以支持岗位权限验证 - 修改CombinationGroupServiceImpl中的权限验证逻辑,增加对岗位权限的检查 - 调整PigxUser结构以支持多部门、多角色、多岗位的存储 - 更新AssignUserLeaderStrategyImpl以适配用户的多部门信息 - 在SysDeptServiceImpl的getOrgTree方法中增加对岗位类型的支持 - 优化UserVO中集合属性的初始化以避免空指针异常
This commit is contained in:
1 parent
7710baa92a
commit
d16d8bc18a
8 files changed
+160
-173
No files matched your search
@@ -5,7 +5,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
## Project Overview
|
||||
|
||||
PigX is a proprietary enterprise-grade microservices platform built on Spring Cloud Alibaba, focusing on AI knowledge
|
||||
management, document processing, and intelligent Q&A capabilities. The current version is 5.10.2-SNAPSHOT.
|
||||
management, document processing, and intelligent Q&A capabilities. The current version is 5.10.0.
|
||||
|
||||
**Important**: This is NOT an open-source project. All rights reserved by the author. Commercial use requires proper
|
||||
licensing.
|
||||
|
||||
@@ -188,13 +188,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-flow-task-api</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-flow-engine-api</artifactId>
|
||||
<artifactId>pigx-flow-api</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
+20
-24
@@ -25,34 +25,30 @@ package com.pig4cloud.pigx.common.core.constant;
|
||||
*/
|
||||
public interface ServiceNameConstants {
|
||||
|
||||
/**
|
||||
* 认证中心
|
||||
*/
|
||||
String AUTH_SERVICE = "pigx-auth";
|
||||
/**
|
||||
* 认证中心
|
||||
*/
|
||||
String AUTH_SERVICE = "pigx-auth";
|
||||
|
||||
/**
|
||||
* UMPS模块
|
||||
*/
|
||||
String UPMS_SERVICE = "pigx-upms-biz";
|
||||
/**
|
||||
* UMPS模块
|
||||
*/
|
||||
String UPMS_SERVICE = "pigx-upms-biz";
|
||||
|
||||
/**
|
||||
* app服务
|
||||
*/
|
||||
String APP_SERVER = "pigx-app-server-biz";
|
||||
/**
|
||||
* app服务
|
||||
*/
|
||||
String APP_SERVER = "pigx-app-server-biz";
|
||||
|
||||
/**
|
||||
* 流程引擎
|
||||
*/
|
||||
String FLOW_ENGINE_SERVER = "pigx-flow-engine-biz";
|
||||
/**
|
||||
* 流程引擎
|
||||
*/
|
||||
String FLOW_ENGINE_SERVER = "pigx-flow-biz";
|
||||
|
||||
/**
|
||||
* 流程工单
|
||||
*/
|
||||
String FLOW_TASK_SERVER = "pigx-flow-task-biz";
|
||||
|
||||
/**
|
||||
* 代码生成模块
|
||||
*/
|
||||
String CODEGEN_SERVICE = "pigx-codegen";
|
||||
/**
|
||||
* 代码生成模块
|
||||
*/
|
||||
String CODEGEN_SERVICE = "pigx-codegen";
|
||||
|
||||
}
|
||||
+90
-97
@@ -22,13 +22,11 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysDept;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysRole;
|
||||
import com.pig4cloud.pigx.admin.api.feign.RemoteDataScopeService;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.enums.UserTypeEnum;
|
||||
import com.pig4cloud.pigx.common.core.util.RetOps;
|
||||
import com.pig4cloud.pigx.common.security.service.PigxUser;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -51,115 +49,110 @@ import java.util.Objects;
|
||||
@RequiredArgsConstructor
|
||||
public class PigxDefaultDataScopeHandle implements DataScopeHandle {
|
||||
|
||||
private final RemoteDataScopeService dataScopeService;
|
||||
private final RemoteDataScopeService dataScopeService;
|
||||
|
||||
@Override
|
||||
public Boolean calcScope(DataScope dataScope) {
|
||||
// 对于TOC客户端,不进行数据权限校验
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
if (UserTypeEnum.TOC.getStatus().equals(user.getUserType())) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public Boolean calcScope(DataScope dataScope) {
|
||||
// 对于TOC客户端,不进行数据权限校验
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
if (UserTypeEnum.TOC.getStatus().equals(user.getUserType())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 业务代码里的规则,覆盖计算规则
|
||||
if (StrUtil.isNotBlank(dataScope.getUsername()) || CollUtil.isNotEmpty(dataScope.getDeptList())) {
|
||||
return false;
|
||||
}
|
||||
// 业务代码里的规则,覆盖计算规则
|
||||
if (StrUtil.isNotBlank(dataScope.getUsername()) || CollUtil.isNotEmpty(dataScope.getDeptList())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取用户角色ID列表
|
||||
List<String> roleIdList = user.getAuthorities()
|
||||
.stream()
|
||||
.map(GrantedAuthority::getAuthority)
|
||||
.filter(authority -> authority.startsWith(SecurityConstants.ROLE))
|
||||
.map(authority -> authority.split(StrUtil.UNDERLINE)[1])
|
||||
.toList();
|
||||
if (CollUtil.isEmpty(roleIdList)) {
|
||||
return false;
|
||||
}
|
||||
// 获取用户角色ID列表
|
||||
List<Long> roleIdList = user.getRoleIds();
|
||||
if (CollUtil.isEmpty(roleIdList)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取角色列表
|
||||
List<SysRole> roleList = RetOps.of(dataScopeService.getRoleList(roleIdList))
|
||||
.getData()
|
||||
.orElseGet(Collections::emptyList);
|
||||
if (CollUtil.isEmpty(roleList)) {
|
||||
return false;
|
||||
}
|
||||
// 获取角色列表
|
||||
List<SysRole> roleList = RetOps.of(dataScopeService.getRoleList(roleIdList))
|
||||
.getData()
|
||||
.orElseGet(Collections::emptyList);
|
||||
if (CollUtil.isEmpty(roleList)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 处理数据权限
|
||||
return processDataScope(user, dataScope, roleList);
|
||||
}
|
||||
// 处理数据权限
|
||||
return processDataScope(user, dataScope, roleList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据权限
|
||||
*/
|
||||
private boolean processDataScope(PigxUser user, DataScope dataScope, List<SysRole> roleList) {
|
||||
List<Long> deptList = dataScope.getDeptList();
|
||||
/**
|
||||
* 处理数据权限
|
||||
*/
|
||||
private boolean processDataScope(PigxUser user, DataScope dataScope, List<SysRole> roleList) {
|
||||
List<Long> deptList = dataScope.getDeptList();
|
||||
|
||||
for (SysRole role : roleList) {
|
||||
Integer dsType = role.getDsType();
|
||||
for (SysRole role : roleList) {
|
||||
Integer dsType = role.getDsType();
|
||||
|
||||
// 处理不同数据权限类型
|
||||
switch (Objects.requireNonNull(DataScopeTypeEnum.getByType(dsType))) {
|
||||
case ALL:
|
||||
return true;
|
||||
case CUSTOM:
|
||||
handleCustomScope(role, deptList);
|
||||
break;
|
||||
case OWN_CHILD_LEVEL:
|
||||
handleOwnChildLevelScope(user, deptList);
|
||||
break;
|
||||
case OWN_LEVEL:
|
||||
handleOwnLevelScope(user, deptList);
|
||||
break;
|
||||
case SELF_LEVEL:
|
||||
handleSelfLevelScope(user, dataScope);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 处理不同数据权限类型
|
||||
switch (Objects.requireNonNull(DataScopeTypeEnum.getByType(dsType))) {
|
||||
case ALL:
|
||||
return true;
|
||||
case CUSTOM:
|
||||
handleCustomScope(role, deptList);
|
||||
break;
|
||||
case OWN_CHILD_LEVEL:
|
||||
handleOwnChildLevelScope(user, deptList);
|
||||
break;
|
||||
case OWN_LEVEL:
|
||||
handleOwnLevelScope(user, deptList);
|
||||
break;
|
||||
case SELF_LEVEL:
|
||||
handleSelfLevelScope(user, dataScope);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理自定义数据权限
|
||||
*/
|
||||
private void handleCustomScope(SysRole role, List<Long> deptList) {
|
||||
if (StrUtil.isNotBlank(role.getDsScope())) {
|
||||
deptList.addAll(Arrays.stream(role.getDsScope().split(StrUtil.COMMA)).map(Long::parseLong).toList());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 处理自定义数据权限
|
||||
*/
|
||||
private void handleCustomScope(SysRole role, List<Long> deptList) {
|
||||
if (StrUtil.isNotBlank(role.getDsScope())) {
|
||||
deptList.addAll(Arrays.stream(role.getDsScope().split(StrUtil.COMMA)).map(Long::parseLong).toList());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理本级及下级数据权限
|
||||
*/
|
||||
private void handleOwnChildLevelScope(PigxUser user, List<Long> deptList) {
|
||||
/**
|
||||
* 处理本级及下级数据权限
|
||||
*/
|
||||
private void handleOwnChildLevelScope(PigxUser user, List<Long> deptList) {
|
||||
|
||||
for (Long deptId : user.getDeptIds()) {
|
||||
List<Long> descendantDeptIds = RetOps.of(dataScopeService.getDescendantList(deptId))
|
||||
.getData()
|
||||
.orElseGet(Collections::emptyList)
|
||||
.stream()
|
||||
.map(SysDept::getDeptId)
|
||||
.toList();
|
||||
deptList.addAll(descendantDeptIds);
|
||||
}
|
||||
for (Long deptId : user.getDeptIds()) {
|
||||
List<Long> descendantDeptIds = RetOps.of(dataScopeService.getDescendantList(deptId))
|
||||
.getData()
|
||||
.orElseGet(Collections::emptyList)
|
||||
.stream()
|
||||
.map(SysDept::getDeptId)
|
||||
.toList();
|
||||
deptList.addAll(descendantDeptIds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理本级数据权限
|
||||
*/
|
||||
private void handleOwnLevelScope(PigxUser user, List<Long> deptList) {
|
||||
deptList.addAll(user.getDeptIds());
|
||||
}
|
||||
/**
|
||||
* 处理本级数据权限
|
||||
*/
|
||||
private void handleOwnLevelScope(PigxUser user, List<Long> deptList) {
|
||||
deptList.addAll(user.getDeptIds());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理个人数据权限
|
||||
*/
|
||||
private void handleSelfLevelScope(PigxUser user, DataScope dataScope) {
|
||||
dataScope.setUsername(user.getUsername());
|
||||
}
|
||||
/**
|
||||
* 处理个人数据权限
|
||||
*/
|
||||
private void handleSelfLevelScope(PigxUser user, DataScope dataScope) {
|
||||
dataScope.setUsername(user.getUsername());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-flow</artifactId>
|
||||
<version>5.10.2-SNAPSHOT</version>
|
||||
<version>5.10.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pigx-flow-api</artifactId>
|
||||
@@ -33,5 +33,9 @@
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+41
-41
@@ -20,53 +20,53 @@ import java.util.List;
|
||||
* 主要包括流程查询、流程启动等操作。该接口用于微服务间的远程调用,
|
||||
* 使其他服务能够便捷地使用流程引擎的功能。
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2025/07/12
|
||||
*/
|
||||
@FeignClient(contextId = "remoteFlowApiFlowService", value = ServiceNameConstants.FLOW_SERVER)
|
||||
@FeignClient(contextId = "remoteFlowApiFlowService", value = ServiceNameConstants.FLOW_ENGINE_SERVER)
|
||||
public interface RemoteFlowApiFlowService {
|
||||
|
||||
/**
|
||||
* 查询当前用户可发起的流程列表
|
||||
* <p>
|
||||
* 根据当前登录用户的权限,查询该用户有权发起的所有流程。
|
||||
* 返回结果按分组组织,方便前端展示。
|
||||
* </p>
|
||||
*
|
||||
* @return 分组后的流程列表,包含分组信息和各分组下的流程
|
||||
*/
|
||||
@GetMapping("/combination/group/listCurrentUserStartGroup")
|
||||
R<List<FormGroupVo>> listCurrentUserStartGroup();
|
||||
/**
|
||||
* 查询当前用户可发起的流程列表
|
||||
* <p>
|
||||
* 根据当前登录用户的权限,查询该用户有权发起的所有流程。
|
||||
* 返回结果按分组组织,方便前端展示。
|
||||
* </p>
|
||||
*
|
||||
* @return 分组后的流程列表,包含分组信息和各分组下的流程
|
||||
*/
|
||||
@GetMapping("/combination/group/listCurrentUserStartGroup")
|
||||
R<List<FormGroupVo>> listCurrentUserStartGroup();
|
||||
|
||||
/**
|
||||
* 获取流程详细信息
|
||||
* <p>
|
||||
* 根据流程ID获取流程的完整配置信息,包括:
|
||||
* - 流程基本信息(名称、图标、描述等)
|
||||
* - 表单配置(表单项定义、验证规则等)
|
||||
* - 流程配置(节点定义、流转规则等)
|
||||
* </p>
|
||||
*
|
||||
* @param flowId 流程定义ID
|
||||
* @return 流程详细信息视图对象
|
||||
*/
|
||||
@GetMapping("/process/getDetail")
|
||||
R<ProcessVO> getDetail(@RequestParam("flowId") String flowId);
|
||||
/**
|
||||
* 获取流程详细信息
|
||||
* <p>
|
||||
* 根据流程ID获取流程的完整配置信息,包括:
|
||||
* - 流程基本信息(名称、图标、描述等)
|
||||
* - 表单配置(表单项定义、验证规则等)
|
||||
* - 流程配置(节点定义、流转规则等)
|
||||
* </p>
|
||||
*
|
||||
* @param flowId 流程定义ID
|
||||
* @return 流程详细信息视图对象
|
||||
*/
|
||||
@GetMapping("/process/getDetail")
|
||||
R<ProcessVO> getDetail(@RequestParam("flowId") String flowId);
|
||||
|
||||
/**
|
||||
* 启动流程实例
|
||||
* <p>
|
||||
* 根据流程定义创建新的流程实例。启动流程时需要提供:
|
||||
* - 流程ID
|
||||
* - 表单数据
|
||||
* - 需要自选的节点执行人信息
|
||||
* </p>
|
||||
*
|
||||
* @param paramDto 流程实例启动参数,包含流程ID、表单数据等
|
||||
* @return 启动成功后的流程实例ID
|
||||
*/
|
||||
@PostMapping("/process-instance/startProcessInstance")
|
||||
R<String> startProcessInstance(@RequestBody ProcessInstanceParamDto paramDto);
|
||||
/**
|
||||
* 启动流程实例
|
||||
* <p>
|
||||
* 根据流程定义创建新的流程实例。启动流程时需要提供:
|
||||
* - 流程ID
|
||||
* - 表单数据
|
||||
* - 需要自选的节点执行人信息
|
||||
* </p>
|
||||
*
|
||||
* @param paramDto 流程实例启动参数,包含流程ID、表单数据等
|
||||
* @return 启动成功后的流程实例ID
|
||||
*/
|
||||
@PostMapping("/process-instance/startProcessInstance")
|
||||
R<String> startProcessInstance(@RequestBody ProcessInstanceParamDto paramDto);
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-flow</artifactId>
|
||||
<version>5.10.2-SNAPSHOT</version>
|
||||
<version>5.10.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pigx-flow-biz</artifactId>
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx</artifactId>
|
||||
<version>5.10.2-SNAPSHOT</version>
|
||||
<version>5.10.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>pigx-flow</artifactId>
|
||||
|
||||
Reference in new issue
Block a user