diff --git a/common/pom.xml b/common/pom.xml
index b2ea702f..5155b077 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -18,6 +18,7 @@
none
execute
+ true
diff --git a/common/src/main/java/com/hzya/frame/util/GroovyUtil.java b/common/src/main/java/com/hzya/frame/util/GroovyUtil.java
new file mode 100644
index 00000000..eec3019b
--- /dev/null
+++ b/common/src/main/java/com/hzya/frame/util/GroovyUtil.java
@@ -0,0 +1,58 @@
+package com.hzya.frame.util;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.hzya.frame.web.exception.BaseSystemException;
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Groovy脚本执行工具类
+ * @author 👻👻👻👻👻👻👻👻👻👻 gjh
+ * @version 1.0
+ * @content
+ * @date 2024-05-16 13:44
+ */
+public class GroovyUtil {
+ private static final Logger logger = LoggerFactory.getLogger(GroovyUtil.class);
+
+
+
+ public static Object execute(JSONObject reqData) {
+ JSONObject jsonObject = JSON.parseObject(reqData.getString("jsonStr"));
+ //JSON参数
+ String parameterJson = jsonObject.getString("parameterJson");
+ String methodStr = jsonObject.getString("methodStr");
+ //TODO 后续根据存储的数据库编码拼接生成
+ String className = jsonObject.getString("className");
+ //组装GroovyClassScript
+ StringBuffer stringBuffer = new StringBuffer();
+ stringBuffer.append(" class ");
+ stringBuffer.append(className);
+ stringBuffer.append(" {");
+ stringBuffer.append(" String execute (String jsonStr){");
+ stringBuffer.append(methodStr);
+ stringBuffer.append(" }");
+ stringBuffer.append(" }");
+ logger.info("Groovy Class 组装结果 "+ stringBuffer.toString());
+ // 创建GroovyClassLoader实例
+ GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
+
+ // 动态编译和加载Groovy脚本
+ Class> groovyClass = groovyClassLoader.parseClass(stringBuffer.toString());
+ // 创建Groovy类的实例
+ GroovyObject groovyObject = null;
+ try {
+ groovyObject = (GroovyObject) groovyClass.newInstance();
+
+ }catch (Exception e){
+ logger.info("创建newInstance失败:"+ e);
+ throw new BaseSystemException(e);
+ }
+ Object returnObj = groovyObject.invokeMethod("execute",parameterJson);
+ logger.info("执行脚本结束:"+returnObj);
+ return returnObj;
+ }
+}
diff --git a/core/pom.xml b/core/pom.xml
index bca91dfa..d3e40c3e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -26,6 +26,7 @@
none
execute
+ true
diff --git a/pom.xml b/pom.xml
index 82782720..20d6b5bb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,6 +62,8 @@
8.0.3
42.2.6
1.7.4
+
+
org.springframework.boot
@@ -334,7 +336,6 @@
spring-boot-starter-cache
-
org.jeecgframework.jimureport
@@ -356,6 +357,16 @@
runtime
+
+
+ org.apache.groovy
+ groovy-all
+ 4.0.21
+ pom
+
+
+
+
@@ -389,6 +400,7 @@
${project.artifactId}
none
execute
+ true
@@ -435,14 +447,14 @@
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/libs-milestone
-
- false
-
-
+
+
+
+
+
+
+
+
aliyun
diff --git a/service/pom.xml b/service/pom.xml
index 4f1692fd..f37ced1f 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -30,6 +30,7 @@
none
execute
+ true
diff --git a/service/src/main/java/com/hzya/frame/sysnew/grovy/service/IGroovyIntegrationService.java b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/IGroovyIntegrationService.java
new file mode 100644
index 00000000..c28bd496
--- /dev/null
+++ b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/IGroovyIntegrationService.java
@@ -0,0 +1,25 @@
+package com.hzya.frame.sysnew.grovy.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.hzya.frame.web.entity.JsonResultEntity;
+
+/**
+ * Groovy 脚本工具集成
+ * @author 👻👻👻👻👻👻👻👻👻👻 gjh
+ * @version 1.0
+ * @content
+ * @date 2024-05-15 13:47
+ */
+public interface IGroovyIntegrationService {
+
+
+ /****
+ * Groovy 脚本执行方法
+ * @content:
+ * @author 👻👻👻👻👻👻👻👻 gjh
+ * @date 2024-05-15 13:49
+ * @param jsonObject 请求参数对象
+ * @return com.hzya.frame.web.entity.JsonResultEntity
+ **/
+ JsonResultEntity groovyScriptExecution(JSONObject jsonObject);
+}
diff --git a/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java
new file mode 100644
index 00000000..580c718c
--- /dev/null
+++ b/service/src/main/java/com/hzya/frame/sysnew/grovy/service/impl/GroovyIntegrationServiceImpl.java
@@ -0,0 +1,51 @@
+package com.hzya.frame.sysnew.grovy.service.impl;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService;
+import com.hzya.frame.util.GroovyUtil;
+import com.hzya.frame.web.entity.BaseResult;
+import com.hzya.frame.web.entity.JsonResultEntity;
+import groovy.lang.GroovyClassLoader;
+import groovy.lang.GroovyObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * Groovy 脚本执行实现类
+ *
+ * @author 👻👻👻👻👻👻👻👻👻👻 gjh
+ * @version 1.0
+ * @content
+ * @date 2024-05-15 13:50
+ */
+@Service(value = "groovyIntegrationService")
+public class GroovyIntegrationServiceImpl implements IGroovyIntegrationService {
+ private static final Logger logger = LoggerFactory.getLogger(GroovyIntegrationServiceImpl.class);
+
+// public static void main(String[] args) {
+// HelloWorld helloWorld = new HelloWorld();
+// System.out.println(helloWorld.sayHello());
+// }
+
+ public static void main(String[] args) throws IllegalAccessException, InstantiationException {
+ GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
+
+ // 动态编译和加载Groovy脚本
+ Class> groovyClass = groovyClassLoader.parseClass("println(\"1231231\")");
+
+ // 创建Groovy类的实例
+ GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance();
+ // 执行Groovy脚本
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("name", "张三");
+ Object returnObj = groovyObject.invokeMethod("run", jsonObject.toJSONString());
+ }
+
+ @Override
+ public JsonResultEntity groovyScriptExecution(JSONObject jsonObject) {
+ Object object = GroovyUtil.execute(jsonObject);
+ return BaseResult.getSuccessMessageEntity(object);
+ }
+}