fix : js 执行函数报错
This commit is contained in:
@@ -41,9 +41,15 @@ public class JavaScriptEngine {
|
||||
* @return 返回结构
|
||||
*/
|
||||
public static Object execute(String script, String functionName, Object args) {
|
||||
try {
|
||||
Value executeFunction = getFunction(functionName, script);
|
||||
Value result = executeFunction.execute(JSON.toJSONString(args));
|
||||
Value javaObjectAsValue = Value.asValue(args);
|
||||
Value result = executeFunction.execute(javaObjectAsValue);
|
||||
return result.as(Object.class);
|
||||
} catch (Exception e) {
|
||||
remove(functionName);
|
||||
throw new CustomException("运行失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,4 +96,12 @@ public class JavaScriptEngine {
|
||||
}
|
||||
|
||||
|
||||
private static void remove(String functionName) {
|
||||
SegmentLock.lock(functionName, () -> {
|
||||
functionMap.remove(functionName);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ public class PortalVo extends SimplePortalVo {
|
||||
*/
|
||||
private Boolean page;
|
||||
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 条件映射
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,9 @@ public class JavaEngineExecuteHandler implements EngineExecuteHandler {
|
||||
|
||||
@Override
|
||||
public EngineResult mockExecute(DataAdapter dataAdapter, Object data) {
|
||||
if (!DataAdapterType.JAVA.equals(dataAdapter.getType())) {
|
||||
return null;
|
||||
}
|
||||
return javaCodeEngine.mockExecute(dataAdapter.getExecuteCode(), getClassName(dataAdapter),
|
||||
"execute", new Object[]{data});
|
||||
}
|
||||
|
||||
@@ -129,8 +129,15 @@ public class PortalServiceImpl implements PortalService {
|
||||
}
|
||||
if (PortalEnum.LOCAL.equals(portal.getType())) {
|
||||
UniQuery uniQuery = queryMapper.selectById(portal.getQueryId());
|
||||
if (!ObjectUtils.isEmpty(uniQuery)) {
|
||||
portalVo.setQueryType(uniQuery.getType());
|
||||
}
|
||||
} else {
|
||||
PortalInterface portalInterface = portalInterfaceMapper.selectById(portal.getInterfaceId());
|
||||
if (!ObjectUtils.isEmpty(portalInterface)) {
|
||||
portalVo.setUrl(portalInterface.getUrl());
|
||||
}
|
||||
}
|
||||
if (portal.getCreateDataAdapter()) {
|
||||
DataAdapter dataAdapter = adapterMapper.selectById(portal.getAdapterId());
|
||||
if (!ObjectUtils.isEmpty(dataAdapter)) {
|
||||
|
||||
Reference in New Issue
Block a user