1
0

优化代码

This commit is contained in:
2025-01-07 17:14:32 +08:00
parent 1cc8bb5618
commit 77567d997d
3 changed files with 9 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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));

View File

@@ -22,6 +22,9 @@ public class FlowableMetadata implements Serializable {
}
public FlowableMetadata(Map<String, Object> metadata) {
if (metadata == null) {
metadata = new HashMap<>();
}
this.metadata = metadata;
}