feat: 2.6.0
1. 新增表达式检验逻辑
This commit is contained in:
parent
054ce1fdf2
commit
0d57da22a1
@ -1,9 +1,12 @@
|
|||||||
package com.aizuda.easy.retry.server.job.task.support.expression;
|
package com.aizuda.easy.retry.server.job.task.support.expression;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.aizuda.easy.retry.common.core.exception.EasyRetryCommonException;
|
||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
|
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -22,16 +25,23 @@ public class ExpressionInvocationHandler implements InvocationHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||||
|
|
||||||
Object[] expressionParams = (Object[]) args[1];
|
try {
|
||||||
String params = (String) expressionParams[0];
|
Object[] expressionParams = (Object[]) args[1];
|
||||||
Map<String, Object> contextMap = new HashMap<>();
|
String params = (String) expressionParams[0];
|
||||||
if (StrUtil.isNotBlank(params)) {
|
Map<String, Object> contextMap = new HashMap<>();
|
||||||
contextMap = JsonUtil.parseHashMap(params);
|
if (StrUtil.isNotBlank(params)) {
|
||||||
|
contextMap = JsonUtil.parseHashMap(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
args[1] = new Object[]{contextMap};
|
||||||
|
return method.invoke(expressionEngine, args);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Throwable targetException = e.getTargetException();
|
||||||
|
throw new EasyRetryServerException(targetException.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EasyRetryServerException("表达式执行失败", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
args[1] = new Object[]{contextMap};
|
|
||||||
return method.invoke(expressionEngine, args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.aizuda.easy.retry.server.web.controller;
|
package com.aizuda.easy.retry.server.web.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Pair;
|
||||||
import com.aizuda.easy.retry.server.common.dto.DecisionConfig;
|
import com.aizuda.easy.retry.server.common.dto.DecisionConfig;
|
||||||
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
||||||
import com.aizuda.easy.retry.server.web.annotation.RoleEnum;
|
import com.aizuda.easy.retry.server.web.annotation.RoleEnum;
|
||||||
@ -74,15 +75,15 @@ public class WorkflowController {
|
|||||||
@GetMapping("/workflow-name/list")
|
@GetMapping("/workflow-name/list")
|
||||||
@LoginRequired(role = RoleEnum.USER)
|
@LoginRequired(role = RoleEnum.USER)
|
||||||
public List<WorkflowResponseVO> getWorkflowNameList(
|
public List<WorkflowResponseVO> getWorkflowNameList(
|
||||||
@RequestParam(value = "keywords", required = false) String keywords,
|
@RequestParam(value = "keywords", required = false) String keywords,
|
||||||
@RequestParam(value = "workflowId", required = false) Long workflowId) {
|
@RequestParam(value = "workflowId", required = false) Long workflowId) {
|
||||||
return workflowService.getWorkflowNameList(keywords, workflowId);
|
return workflowService.getWorkflowNameList(keywords, workflowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/check-node-expression")
|
@PostMapping("/check-node-expression")
|
||||||
@LoginRequired(role = RoleEnum.ADMIN)
|
@LoginRequired(role = RoleEnum.ADMIN)
|
||||||
public void checkNodeExpression(@RequestBody DecisionConfig decisionConfig) {
|
public Pair<Integer, String> checkNodeExpression(@RequestBody DecisionConfig decisionConfig) {
|
||||||
workflowService.checkNodeExpression(decisionConfig);
|
return workflowService.checkNodeExpression(decisionConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.aizuda.easy.retry.server.web.service;
|
package com.aizuda.easy.retry.server.web.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Pair;
|
||||||
import com.aizuda.easy.retry.server.common.dto.DecisionConfig;
|
import com.aizuda.easy.retry.server.common.dto.DecisionConfig;
|
||||||
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.WorkflowQueryVO;
|
import com.aizuda.easy.retry.server.web.model.request.WorkflowQueryVO;
|
||||||
@ -33,5 +34,5 @@ public interface WorkflowService {
|
|||||||
|
|
||||||
List<WorkflowResponseVO> getWorkflowNameList(String keywords, Long workflowId);
|
List<WorkflowResponseVO> getWorkflowNameList(String keywords, Long workflowId);
|
||||||
|
|
||||||
void checkNodeExpression(DecisionConfig decisionConfig);
|
Pair<Integer, String> checkNodeExpression(DecisionConfig decisionConfig);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.aizuda.easy.retry.server.web.service.impl;
|
package com.aizuda.easy.retry.server.web.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.lang.Pair;
|
||||||
import cn.hutool.core.util.HashUtil;
|
import cn.hutool.core.util.HashUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
||||||
@ -8,6 +9,7 @@ import com.aizuda.easy.retry.common.core.enums.StatusEnum;
|
|||||||
import com.aizuda.easy.retry.common.core.expression.ExpressionEngine;
|
import com.aizuda.easy.retry.common.core.expression.ExpressionEngine;
|
||||||
import com.aizuda.easy.retry.common.core.expression.ExpressionFactory;
|
import com.aizuda.easy.retry.common.core.expression.ExpressionFactory;
|
||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
|
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||||
import com.aizuda.easy.retry.server.common.WaitStrategy;
|
import com.aizuda.easy.retry.server.common.WaitStrategy;
|
||||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||||
import com.aizuda.easy.retry.server.common.dto.DecisionConfig;
|
import com.aizuda.easy.retry.server.common.dto.DecisionConfig;
|
||||||
@ -326,12 +328,19 @@ public class WorkflowServiceImpl implements WorkflowService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkNodeExpression(DecisionConfig decisionConfig) {
|
public Pair<Integer, String> checkNodeExpression(DecisionConfig decisionConfig) {
|
||||||
ExpressionEngine realExpressionEngine = ExpressionTypeEnum.valueOf(decisionConfig.getExpressionType());
|
try {
|
||||||
Assert.notNull(realExpressionEngine, () -> new EasyRetryServerException("表达式引擎不存在"));
|
ExpressionEngine realExpressionEngine = ExpressionTypeEnum.valueOf(decisionConfig.getExpressionType());
|
||||||
ExpressionInvocationHandler invocationHandler = new ExpressionInvocationHandler(realExpressionEngine);
|
Assert.notNull(realExpressionEngine, () -> new EasyRetryServerException("表达式引擎不存在"));
|
||||||
ExpressionEngine expressionEngine = ExpressionFactory.getExpressionEngine(invocationHandler);
|
ExpressionInvocationHandler invocationHandler = new ExpressionInvocationHandler(realExpressionEngine);
|
||||||
expressionEngine.eval(decisionConfig.getNodeExpression(), new HashMap<>());
|
ExpressionEngine expressionEngine = ExpressionFactory.getExpressionEngine(invocationHandler);
|
||||||
|
expressionEngine.eval(decisionConfig.getNodeExpression(), StrUtil.EMPTY);
|
||||||
|
} catch (Exception e) {
|
||||||
|
EasyRetryLog.LOCAL.error("表达式异常. [{}]", decisionConfig.getNodeExpression(), e);
|
||||||
|
return Pair.of(StatusEnum.NO.getStatus(), e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Pair.of(StatusEnum.YES.getStatus(), StrUtil.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
21
frontend/public/lib/assets/8zF6m6u3.js
Normal file
21
frontend/public/lib/assets/8zF6m6u3.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,16 +1,16 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Easy Retry</title>
|
<title>Easy Retry</title>
|
||||||
<script type="module" crossorigin src="./assets/O1TCl_bu.js"></script>
|
<script type="module" crossorigin src="./assets/8zF6m6u3.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="./assets/gKrsqr4E.css">
|
<link rel="stylesheet" crossorigin href="./assets/EQnfluSr.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -180,7 +180,7 @@ export default {
|
|||||||
z-index: 0;
|
z-index: 0;
|
||||||
|
|
||||||
.gutters {
|
.gutters {
|
||||||
min-height: 108px;
|
min-height: 100%;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
background-color: #1e1f22;
|
background-color: #1e1f22;
|
||||||
color: #7d8799;
|
color: #7d8799;
|
||||||
@ -188,7 +188,6 @@ export default {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
inset-inline-start: 0;
|
inset-inline-start: 0;
|
||||||
z-index: 200;
|
z-index: 200;
|
||||||
|
Loading…
Reference in New Issue
Block a user