From d7fcf566020fca4062bac010205ab5580b0c8203 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 9 May 2024 17:47:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-j?= =?UTF-8?q?avascript=E8=84=9A=E6=9C=AC=E6=B5=8B=E8=AF=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1152930000896000]后端-javascript脚本测试接口 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1152930000896000 --- .../tenant/api/util/JavascriptTestApi.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java diff --git a/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java b/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java new file mode 100644 index 00000000..7bae3c38 --- /dev/null +++ b/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.module.tenant.api.util; + +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.restful.annotation.*; +import neatlogic.framework.restful.constvalue.OperationTypeEnum; +import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; +import neatlogic.framework.util.javascript.JavascriptUtil; +import org.springframework.stereotype.Service; + +@Service +@OperationType(type = OperationTypeEnum.SEARCH) +public class JavascriptTestApi extends PrivateApiComponentBase { + @Override + public String getName() { + return "测试JavaScript脚本执行"; + } + + @Input({ + @Param(name = "param", type = ApiParamType.STRING, isRequired = true, desc = "参数"), + @Param(name = "script", type = ApiParamType.STRING, isRequired = true, desc = "脚本") + }) + @Output({ + @Param(name = "result", type = ApiParamType.BOOLEAN) + }) + @Description(desc = "") + @Override + public Object myDoService(JSONObject jsonObj) throws Exception { + JSONObject param = jsonObj.getJSONObject("param"); + String script = jsonObj.getString("script"); + JSONObject paramObj = new JSONObject(); + paramObj.put("data", param); + System.out.println("paramObj = " + paramObj); + Object returnValue = JavascriptUtil.runScript(paramObj, script); + Boolean result = Boolean.parseBoolean(returnValue.toString()); + JSONObject resultObj = new JSONObject(); + resultObj.put("result", result); + return resultObj; + } + + @Override + public String getToken() { + return "util/javascript"; + } +} -- Gitee From f21ea2e22304ac99dbebad46e47d6a17459a71e4 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 9 May 2024 17:56:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=90=8E=E7=AB=AF-j?= =?UTF-8?q?avascript=E8=84=9A=E6=9C=AC=E6=B5=8B=E8=AF=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1152930000896000]后端-javascript脚本测试接口 http://192.168.0.96:8090/demo/rdm.html#/task-detail/939050947543040/939050947543050/1152930000896000 --- .../java/neatlogic/module/tenant/api/util/JavascriptTestApi.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java b/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java index 7bae3c38..85bcf6f7 100644 --- a/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java +++ b/src/main/java/neatlogic/module/tenant/api/util/JavascriptTestApi.java @@ -47,7 +47,6 @@ public class JavascriptTestApi extends PrivateApiComponentBase { String script = jsonObj.getString("script"); JSONObject paramObj = new JSONObject(); paramObj.put("data", param); - System.out.println("paramObj = " + paramObj); Object returnValue = JavascriptUtil.runScript(paramObj, script); Boolean result = Boolean.parseBoolean(returnValue.toString()); JSONObject resultObj = new JSONObject(); -- Gitee