优化代码
This commit is contained in:
@@ -11,7 +11,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
@@ -21,8 +20,8 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
* @author lanyuanxiaoyao
|
||||
* @version 20250103
|
||||
*/
|
||||
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableJpaRepositories("com.lanyuanxiaoyao.flowable.jpa.repository")
|
||||
@EnableConfigurationProperties(SpringFlowableConfiguration.class)
|
||||
public class SpringFlowableAutoConfiguration {
|
||||
|
||||
@@ -81,11 +81,16 @@ public abstract class FlowableManager {
|
||||
}
|
||||
|
||||
public String start(String nodeId, Map<String, Object> metadata) {
|
||||
return start(nodeId, metadata, null);
|
||||
}
|
||||
|
||||
public String start(String nodeId, Map<String, Object> metadata, String extra) {
|
||||
FlowableNode node = repository.getNode(nodeId);
|
||||
FlowableInstance instance = FlowableInstance.builder()
|
||||
.instanceId(createId())
|
||||
.currentNodeId(node.getNodeId())
|
||||
.metadata(new FlowableMetadata(metadata))
|
||||
.extra(extra)
|
||||
.build();
|
||||
repository.saveInstance(instance);
|
||||
callListeners(node.getListeners(), listener -> listener.onFlowStart(instance, node));
|
||||
|
||||
@@ -22,6 +22,9 @@ public class FlowableMetadata implements Serializable {
|
||||
}
|
||||
|
||||
public FlowableMetadata(Map<String, Object> metadata) {
|
||||
if (metadata == null) {
|
||||
metadata = new HashMap<>();
|
||||
}
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user