feat: 2.6.0

1. 新增表达式检验逻辑
This commit is contained in:
byteblogs168 2024-01-18 10:29:32 +08:00
parent 965f92a2a0
commit 273a45ce7f
6 changed files with 58 additions and 48 deletions

View File

@ -1,9 +1,12 @@
package com.aizuda.easy.retry.server.job.task.support.expression;
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.server.common.exception.EasyRetryServerException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@ -22,16 +25,23 @@ public class ExpressionInvocationHandler implements InvocationHandler {
}
@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];
String params = (String) expressionParams[0];
Map<String, Object> contextMap = new HashMap<>();
if (StrUtil.isNotBlank(params)) {
contextMap = JsonUtil.parseHashMap(params);
try {
Object[] expressionParams = (Object[]) args[1];
String params = (String) expressionParams[0];
Map<String, Object> contextMap = new HashMap<>();
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);
}
}

View File

@ -331,7 +331,7 @@ public class WorkflowServiceImpl implements WorkflowService {
Assert.notNull(realExpressionEngine, () -> new EasyRetryServerException("表达式引擎不存在"));
ExpressionInvocationHandler invocationHandler = new ExpressionInvocationHandler(realExpressionEngine);
ExpressionEngine expressionEngine = ExpressionFactory.getExpressionEngine(invocationHandler);
expressionEngine.eval(decisionConfig.getNodeExpression(), new HashMap<>());
expressionEngine.eval(decisionConfig.getNodeExpression(), StrUtil.EMPTY);
}
}

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

View File

@ -1,16 +1,16 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Easy Retry</title>
<script type="module" crossorigin src="./assets/O1TCl_bu.js"></script>
<link rel="stylesheet" crossorigin href="./assets/gKrsqr4E.css">
</head>
<body>
<div id="app"></div>
</body>
</html>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Easy Retry</title>
<script type="module" crossorigin src="./assets/8zF6m6u3.js"></script>
<link rel="stylesheet" crossorigin href="./assets/EQnfluSr.css">
</head>
<body>
<div id="app"></div>
</body>
</html>