【功能新增】工作流:流程发起时,校验是否有发起流程的权限
This commit is contained in:
parent
9cc8e0d37f
commit
742c2967de
|
@ -37,6 +37,7 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_SELF = new ErrorCode(1_009_004_002, "流程取消失败,该流程不是你发起的");
|
||||
ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_CONFIG = new ErrorCode(1_009_004_003, "审批任务({})的审批人未配置");
|
||||
ErrorCode PROCESS_INSTANCE_START_USER_SELECT_ASSIGNEES_NOT_EXISTS = new ErrorCode(1_009_004_004, "审批任务({})的审批人({})不存在");
|
||||
ErrorCode PROCESS_INSTANCE_START_USER_CAN_START = new ErrorCode(1_009_004_005, "发起流程失败,你没有权限发起该流程");
|
||||
|
||||
// ========== 流程任务 1-009-005-000 ==========
|
||||
ErrorCode TASK_OPERATE_FAIL_ASSIGN_NOT_SELF = new ErrorCode(1_009_005_001, "操作失败,原因:该任务的审批人不是你");
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.Map;
|
|||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 流程定义")
|
||||
@RestController
|
||||
|
@ -87,9 +88,12 @@ public class BpmProcessDefinitionController {
|
|||
// 1.2 移除不可见的流程定义
|
||||
Map<String, BpmProcessDefinitionInfoDO> processDefinitionMap = processDefinitionService.getProcessDefinitionInfoMap(
|
||||
convertSet(list, ProcessDefinition::getId));
|
||||
Long userId = getLoginUserId();
|
||||
list.removeIf(processDefinition -> {
|
||||
BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionMap.get(processDefinition.getId());
|
||||
return processDefinitionInfo != null && Boolean.FALSE.equals(processDefinitionInfo.getVisible());
|
||||
return processDefinitionInfo == null // 不存在
|
||||
|| Boolean.FALSE.equals(processDefinitionInfo.getVisible()) // visible 不可见
|
||||
|| !processDefinitionService.canUserStartProcessDefinition(processDefinitionInfo, userId); // 无权限发起
|
||||
});
|
||||
|
||||
// 2. 拼接 VO 返回
|
||||
|
|
|
@ -135,6 +135,15 @@ public interface BpmProcessDefinitionService {
|
|||
*/
|
||||
ProcessDefinition getActiveProcessDefinition(String key);
|
||||
|
||||
/**
|
||||
* 判断用户是否可以使用该流程定义,进行流程的发起
|
||||
*
|
||||
* @param processDefinition 流程定义
|
||||
* @param userId 用户编号
|
||||
* @return 是否可以发起流程
|
||||
*/
|
||||
boolean canUserStartProcessDefinition(BpmProcessDefinitionInfoDO processDefinition, Long userId);
|
||||
|
||||
/**
|
||||
* 获得 ids 对应的 Deployment Map
|
||||
*
|
||||
|
|
|
@ -85,6 +85,19 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
|||
.processDefinitionKey(key).active().singleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUserStartProcessDefinition(BpmProcessDefinitionInfoDO processDefinition, Long userId) {
|
||||
if (processDefinition == null) {
|
||||
return false;
|
||||
}
|
||||
// 为空,则所有人都可以发起
|
||||
if (CollUtil.isEmpty(processDefinition.getStartUserIds())) {
|
||||
return true;
|
||||
}
|
||||
// 不为空,则需要存在里面
|
||||
return processDefinition.getStartUserIds().contains(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Deployment> getDeploymentList(Set<String> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue