feat: EL表达式简写,默认套任务监控模板
This commit is contained in:
5
.idea/codeStyles/Project.xml
generated
5
.idea/codeStyles/Project.xml
generated
@@ -104,5 +104,10 @@
|
|||||||
<codeStyleSettings language="kotlin">
|
<codeStyleSettings language="kotlin">
|
||||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="yaml">
|
||||||
|
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
|
||||||
|
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
|
||||||
|
<option name="LINE_COMMENT_ADD_SPACE_ON_REFORMAT" value="true" />
|
||||||
|
</codeStyleSettings>
|
||||||
</code_scheme>
|
</code_scheme>
|
||||||
</component>
|
</component>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.lanyuanxiaoyao.leopard.server.controller;
|
package com.lanyuanxiaoyao.leopard.server.controller;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.lanyuanxiaoyao.leopard.core.entity.TaskTemplate;
|
import com.lanyuanxiaoyao.leopard.core.entity.TaskTemplate;
|
||||||
import com.lanyuanxiaoyao.leopard.server.service.TaskTemplateService;
|
import com.lanyuanxiaoyao.leopard.server.service.TaskTemplateService;
|
||||||
import com.lanyuanxiaoyao.service.template.controller.SimpleControllerSupport;
|
import com.lanyuanxiaoyao.service.template.controller.SimpleControllerSupport;
|
||||||
@@ -30,7 +31,7 @@ public class TaskTemplateController extends SimpleControllerSupport<TaskTemplate
|
|||||||
template.setDescription(item.description());
|
template.setDescription(item.description());
|
||||||
template.setApplication(application);
|
template.setApplication(application);
|
||||||
template.setChain(IdUtil.simpleUUID());
|
template.setChain(IdUtil.simpleUUID());
|
||||||
template.setExpression(item.expression());
|
template.setExpression(StrUtil.format("CATCH(THEN(task_start, ({}), task_end)).DO(task_error)", item.expression()));
|
||||||
return template;
|
return template;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.lanyuanxiaoyao.leopard.server.service;
|
|||||||
import com.lanyuanxiaoyao.leopard.core.entity.TaskTemplate;
|
import com.lanyuanxiaoyao.leopard.core.entity.TaskTemplate;
|
||||||
import com.lanyuanxiaoyao.leopard.core.repository.TaskTemplateRepository;
|
import com.lanyuanxiaoyao.leopard.core.repository.TaskTemplateRepository;
|
||||||
import com.lanyuanxiaoyao.service.template.service.SimpleServiceSupport;
|
import com.lanyuanxiaoyao.service.template.service.SimpleServiceSupport;
|
||||||
|
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
|
||||||
import com.yomahub.liteflow.meta.LiteflowMetaOperator;
|
import com.yomahub.liteflow.meta.LiteflowMetaOperator;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -12,8 +13,16 @@ public class TaskTemplateService extends SimpleServiceSupport<TaskTemplate> {
|
|||||||
super(repository);
|
super(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void validateExpression(String expression) {
|
||||||
|
var response = LiteFlowChainELBuilder.validateWithEx(expression);
|
||||||
|
if (!response.isSuccess()) {
|
||||||
|
throw new RuntimeException(response.getCause());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long save(TaskTemplate entity) {
|
public Long save(TaskTemplate entity) {
|
||||||
|
validateExpression(entity.getExpression());
|
||||||
Long id = super.save(entity);
|
Long id = super.save(entity);
|
||||||
LiteflowMetaOperator.reloadAllChain();
|
LiteflowMetaOperator.reloadAllChain();
|
||||||
return id;
|
return id;
|
||||||
@@ -21,6 +30,7 @@ public class TaskTemplateService extends SimpleServiceSupport<TaskTemplate> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(Iterable<TaskTemplate> taskTemplates) {
|
public void save(Iterable<TaskTemplate> taskTemplates) {
|
||||||
|
taskTemplates.forEach(template -> validateExpression(template.getExpression()));
|
||||||
super.save(taskTemplates);
|
super.save(taskTemplates);
|
||||||
LiteflowMetaOperator.reloadAllChain();
|
LiteflowMetaOperator.reloadAllChain();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user