1
0

feat: liteflow任务保存到数据库

This commit is contained in:
2025-09-11 00:13:09 +08:00
parent ced4cde3e3
commit efd7f5e9f2
7 changed files with 59 additions and 7 deletions

View File

@@ -45,6 +45,10 @@
<groupId>com.yomahub</groupId>
<artifactId>liteflow-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>liteflow-rule-sql</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>

View File

@@ -1,10 +1,12 @@
package com.lanyuanxiaoyao.leopard.server.controller;
import cn.hutool.core.util.IdUtil;
import com.lanyuanxiaoyao.leopard.core.entity.TaskTemplate;
import com.lanyuanxiaoyao.leopard.server.service.TaskTemplateService;
import com.lanyuanxiaoyao.service.template.controller.SimpleControllerSupport;
import java.util.function.Function;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -12,6 +14,9 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("task_template")
public class TaskTemplateController extends SimpleControllerSupport<TaskTemplate, TaskTemplateController.Item, TaskTemplateController.Item, TaskTemplateController.Item> {
@Value("${spring.application.name}")
private String application;
public TaskTemplateController(TaskTemplateService service) {
super(service);
}
@@ -23,7 +28,9 @@ public class TaskTemplateController extends SimpleControllerSupport<TaskTemplate
template.setId(item.id());
template.setName(item.name());
template.setDescription(item.description());
template.setChain(item.chain());
template.setApplication(application);
template.setChain(IdUtil.simpleUUID());
template.setExpression(item.expression());
return template;
};
}
@@ -33,7 +40,7 @@ public class TaskTemplateController extends SimpleControllerSupport<TaskTemplate
template.getId(),
template.getName(),
template.getDescription(),
template.getChain()
template.getExpression()
);
}
@@ -51,7 +58,7 @@ public class TaskTemplateController extends SimpleControllerSupport<TaskTemplate
Long id,
String name,
String description,
String chain
String expression
) {
}
}

View File

@@ -3,6 +3,7 @@ package com.lanyuanxiaoyao.leopard.server.service;
import com.lanyuanxiaoyao.leopard.core.entity.TaskTemplate;
import com.lanyuanxiaoyao.leopard.core.repository.TaskTemplateRepository;
import com.lanyuanxiaoyao.service.template.service.SimpleServiceSupport;
import com.yomahub.liteflow.meta.LiteflowMetaOperator;
import org.springframework.stereotype.Service;
@Service
@@ -10,4 +11,29 @@ public class TaskTemplateService extends SimpleServiceSupport<TaskTemplate> {
public TaskTemplateService(TaskTemplateRepository repository) {
super(repository);
}
@Override
public Long save(TaskTemplate entity) {
Long id = super.save(entity);
LiteflowMetaOperator.reloadAllChain();
return id;
}
@Override
public void save(Iterable<TaskTemplate> taskTemplates) {
super.save(taskTemplates);
LiteflowMetaOperator.reloadAllChain();
}
@Override
public void remove(Iterable<Long> ids) {
super.remove(ids);
LiteflowMetaOperator.reloadAllChain();
}
@Override
public void remove(Long id) {
super.remove(id);
LiteflowMetaOperator.reloadAllChain();
}
}

View File

@@ -37,5 +37,11 @@ fenix:
print-banner: false
liteflow:
print-banner: false
rule-source: flow.xml
check-node-exists: false
check-node-exists: false
rule-source-ext-data-map:
applicationName: ${spring.application.name}
sqlLogEnabled: true
chainTableName: leopard_task_template
chainApplicationNameField: application
chainNameField: chain
elDataField: expression