完成权限控制
This commit is contained in:
@@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class FlowableManager {
|
||||
private static final String DEFAULT_APPROVE_COMMENT = "审批通过";
|
||||
private final FlowableConfiguration configuration;
|
||||
private final FlowableRepository repository;
|
||||
|
||||
@@ -83,13 +84,21 @@ public abstract class FlowableManager {
|
||||
}
|
||||
|
||||
public void approve(String instanceId) {
|
||||
approve(instanceId, "审批通过");
|
||||
approve(instanceId, DEFAULT_APPROVE_COMMENT);
|
||||
}
|
||||
|
||||
public void approve(String instanceId, String comment) {
|
||||
manualAction(instanceId, FlowableAction.APPROVE, comment);
|
||||
}
|
||||
|
||||
public void approve(String instanceId, Map<String, Object> metadata) {
|
||||
manualAction(instanceId, FlowableAction.APPROVE, DEFAULT_APPROVE_COMMENT, metadata);
|
||||
}
|
||||
|
||||
public void approve(String instanceId, String comment, Map<String, Object> metadata) {
|
||||
manualAction(instanceId, FlowableAction.APPROVE, comment, metadata);
|
||||
}
|
||||
|
||||
public void reject(String instanceId) {
|
||||
reject(instanceId, "审批不通过");
|
||||
}
|
||||
@@ -128,6 +137,15 @@ public abstract class FlowableManager {
|
||||
throw new IllegalArgumentException("ID为" + instance.getInstanceId() + "的流程已结束,无法操作");
|
||||
}
|
||||
|
||||
String accessorClass = node.getAccessor();
|
||||
if (StringHelper.isBlank(accessorClass)) {
|
||||
throw new IllegalArgumentException("权限检查器为空");
|
||||
}
|
||||
FlowableAccessor accessor = createBean(accessorClass);
|
||||
if (!accessor.access(instance.getMetadata())) {
|
||||
throw new IllegalArgumentException("权限校验不通过");
|
||||
}
|
||||
|
||||
String handlerClass = node.getHandler();
|
||||
if (StringHelper.isBlank(handlerClass)) {
|
||||
throw new IllegalArgumentException("节点执行器为空");
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.lanyuanxiaoyao.flowable.core.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 权限校验
|
||||
*
|
||||
@@ -9,5 +7,12 @@ import java.util.Map;
|
||||
* @version 20241231
|
||||
*/
|
||||
public interface FlowableAccessor {
|
||||
boolean access(Map<String, Object> metadata);
|
||||
boolean access(FlowableMetadata metadata);
|
||||
|
||||
class DefaultFlowableAccessor implements FlowableAccessor {
|
||||
@Override
|
||||
public boolean access(FlowableMetadata metadata) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user