From 0fecb4aed42de936dbab10025a94a8494c0d7f06 Mon Sep 17 00:00:00 2001
From: lorne <1991wangliang@gmail.com>
Date: Sat, 30 May 2026 10:55:27 +0800
Subject: [PATCH 1/2] update version
---
.../example-app-cmd-domain/pom.xml | 2 +-
.../example-app/example-app-cmd-meta/pom.xml | 2 +-
example/example-app/example-app-query/pom.xml | 2 +-
example/example-app/pom.xml | 2 +-
.../example-domain-leave/pom.xml | 2 +-
.../example-domain-user/pom.xml | 2 +-
example/example-domain/pom.xml | 2 +-
.../example-infra/example-infra-flow/pom.xml | 2 +-
.../example-infra/example-infra-jpa/pom.xml | 2 +-
.../example-infra-security/pom.xml | 2 +-
example/example-infra/pom.xml | 2 +-
example/example-interface/pom.xml | 2 +-
example/example-server/pom.xml | 2 +-
example/pom.xml | 2 +-
pom.xml | 2 +-
springboot-starter-data-authorization/pom.xml | 2 +-
springboot-starter-data-fast/pom.xml | 2 +-
springboot-starter-flow/pom.xml | 2 +-
springboot-starter-script/pom.xml | 2 +-
.../script/meta/GroovyMetadata.java | 9 ++
...GroovyMetadataGenerateStrategyContext.java | 2 +-
.../springboot/script/GroovyStrategyTest.java | 128 ++++++++++++++++++
springboot-starter-security/pom.xml | 2 +-
springboot-starter/pom.xml | 2 +-
24 files changed, 159 insertions(+), 22 deletions(-)
create mode 100644 springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyStrategyTest.java
diff --git a/example/example-app/example-app-cmd-domain/pom.xml b/example/example-app/example-app-cmd-domain/pom.xml
index dc21a083..96a74c89 100644
--- a/example/example-app/example-app-cmd-domain/pom.xml
+++ b/example/example-app/example-app-cmd-domain/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.52
+ 3.4.53
../pom.xml
diff --git a/example/example-app/example-app-cmd-meta/pom.xml b/example/example-app/example-app-cmd-meta/pom.xml
index 4b3c451e..1f30dec5 100644
--- a/example/example-app/example-app-cmd-meta/pom.xml
+++ b/example/example-app/example-app-cmd-meta/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.52
+ 3.4.53
../pom.xml
diff --git a/example/example-app/example-app-query/pom.xml b/example/example-app/example-app-query/pom.xml
index 7a30d037..691aa289 100644
--- a/example/example-app/example-app-query/pom.xml
+++ b/example/example-app/example-app-query/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-app
- 3.4.52
+ 3.4.53
../pom.xml
diff --git a/example/example-app/pom.xml b/example/example-app/pom.xml
index 11ff2892..5ec7d4ad 100644
--- a/example/example-app/pom.xml
+++ b/example/example-app/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.52
+ 3.4.53
../pom.xml
pom
diff --git a/example/example-domain/example-domain-leave/pom.xml b/example/example-domain/example-domain-leave/pom.xml
index c47521fb..57318f6b 100644
--- a/example/example-domain/example-domain-leave/pom.xml
+++ b/example/example-domain/example-domain-leave/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-domain
- 3.4.52
+ 3.4.53
../pom.xml
diff --git a/example/example-domain/example-domain-user/pom.xml b/example/example-domain/example-domain-user/pom.xml
index da464aa1..a9aeef7c 100644
--- a/example/example-domain/example-domain-user/pom.xml
+++ b/example/example-domain/example-domain-user/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-domain
- 3.4.52
+ 3.4.53
../pom.xml
diff --git a/example/example-domain/pom.xml b/example/example-domain/pom.xml
index a3519171..2d386fde 100644
--- a/example/example-domain/pom.xml
+++ b/example/example-domain/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
springboot-example
- 3.4.52
+ 3.4.53
../pom.xml
4.0.0
diff --git a/example/example-infra/example-infra-flow/pom.xml b/example/example-infra/example-infra-flow/pom.xml
index cf056317..6d07e454 100644
--- a/example/example-infra/example-infra-flow/pom.xml
+++ b/example/example-infra/example-infra-flow/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
example-infra
- 3.4.52
+ 3.4.53
../pom.xml
diff --git a/example/example-infra/example-infra-jpa/pom.xml b/example/example-infra/example-infra-jpa/pom.xml
index 70fc9050..f16541db 100644
--- a/example/example-infra/example-infra-jpa/pom.xml
+++ b/example/example-infra/example-infra-jpa/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
example-infra
- 3.4.52
+ 3.4.53
../pom.xml
diff --git a/example/example-infra/example-infra-security/pom.xml b/example/example-infra/example-infra-security/pom.xml
index d586c320..2bc94984 100644
--- a/example/example-infra/example-infra-security/pom.xml
+++ b/example/example-infra/example-infra-security/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
example-infra
- 3.4.52
+ 3.4.53
../pom.xml
diff --git a/example/example-infra/pom.xml b/example/example-infra/pom.xml
index 509b816a..09895679 100644
--- a/example/example-infra/pom.xml
+++ b/example/example-infra/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.52
+ 3.4.53
../pom.xml
pom
diff --git a/example/example-interface/pom.xml b/example/example-interface/pom.xml
index 255bfaba..7bf818fa 100644
--- a/example/example-interface/pom.xml
+++ b/example/example-interface/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-example
- 3.4.52
+ 3.4.53
example-interface
diff --git a/example/example-server/pom.xml b/example/example-server/pom.xml
index b1337149..8151e1b1 100644
--- a/example/example-server/pom.xml
+++ b/example/example-server/pom.xml
@@ -5,7 +5,7 @@
springboot-example
com.codingapi.springboot
- 3.4.52
+ 3.4.53
4.0.0
diff --git a/example/pom.xml b/example/pom.xml
index b170fa85..78cb5201 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -19,7 +19,7 @@
springboot-example
- 3.4.52
+ 3.4.53
springboot-example
springboot-example project for Spring Boot
diff --git a/pom.xml b/pom.xml
index d73c39d6..0b2203b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.52
+ 3.4.53
https://github.com/codingapi/springboot-framewrok
springboot-parent
diff --git a/springboot-starter-data-authorization/pom.xml b/springboot-starter-data-authorization/pom.xml
index c7b0ba46..09855ec5 100644
--- a/springboot-starter-data-authorization/pom.xml
+++ b/springboot-starter-data-authorization/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.52
+ 3.4.53
springboot-starter-data-authorization
diff --git a/springboot-starter-data-fast/pom.xml b/springboot-starter-data-fast/pom.xml
index 8ae5ffa6..cc7e535f 100644
--- a/springboot-starter-data-fast/pom.xml
+++ b/springboot-starter-data-fast/pom.xml
@@ -5,7 +5,7 @@
springboot-parent
com.codingapi.springboot
- 3.4.52
+ 3.4.53
4.0.0
diff --git a/springboot-starter-flow/pom.xml b/springboot-starter-flow/pom.xml
index 4395ea3d..c9508667 100644
--- a/springboot-starter-flow/pom.xml
+++ b/springboot-starter-flow/pom.xml
@@ -6,7 +6,7 @@
springboot-parent
com.codingapi.springboot
- 3.4.52
+ 3.4.53
springboot-starter-flow
diff --git a/springboot-starter-script/pom.xml b/springboot-starter-script/pom.xml
index a24b3eea..955c084d 100644
--- a/springboot-starter-script/pom.xml
+++ b/springboot-starter-script/pom.xml
@@ -6,7 +6,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.52
+ 3.4.53
springboot-starter-script
diff --git a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/meta/GroovyMetadata.java b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/meta/GroovyMetadata.java
index 5c8a45ce..ac62b99d 100644
--- a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/meta/GroovyMetadata.java
+++ b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/meta/GroovyMetadata.java
@@ -57,6 +57,15 @@ public GroovyMetadata(GroovyScript groovyScript) {
}
+ public GroovyMetadata(String mainMethod,String returnType, String description) {
+ this.returnType = returnType;
+ this.description = description;
+ this.mainMethod = mainMethod;
+ this.types = new HashMap<>();
+ this.requests = new ArrayList<>();
+ this.binds = new ArrayList<>();
+ }
+
/**
* 增加请求参数数据对象
*
diff --git a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyMetadataGenerateStrategyContext.java b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyMetadataGenerateStrategyContext.java
index 7b737d84..b2181284 100644
--- a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyMetadataGenerateStrategyContext.java
+++ b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyMetadataGenerateStrategyContext.java
@@ -21,7 +21,7 @@ private GroovyMetadataGenerateStrategyContext() {
this.strategies = new ArrayList<>();
}
- public void addLoadStrategy(GroovyMetadataGenerateStrategy strategy) {
+ public void addGenerateStrategy(GroovyMetadataGenerateStrategy strategy) {
this.strategies.add(strategy);
}
diff --git a/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyStrategyTest.java b/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyStrategyTest.java
new file mode 100644
index 00000000..d91b28da
--- /dev/null
+++ b/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyStrategyTest.java
@@ -0,0 +1,128 @@
+package com.codingapi.springboot.script;
+
+import com.alibaba.fastjson.JSON;
+import com.codingapi.springboot.script.meta.GroovyFunction;
+import com.codingapi.springboot.script.meta.GroovyMetadata;
+import com.codingapi.springboot.script.meta.GroovyType;
+import com.codingapi.springboot.script.request.MyScriptRequest;
+import com.codingapi.springboot.script.strategy.*;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class GroovyStrategyTest {
+
+
+ @Test
+ void test1(){
+ String script = """
+
+ def run(request){
+ return request.count;
+ }
+ """;
+
+ ScriptTypeMappingContext.getInstance().addMapping(new ScriptTypeMapping() {
+ @Override
+ public boolean support(Class> target) {
+ return Integer.class.equals(target);
+ }
+
+ @Override
+ public Class> mapping(Class> target) {
+ return int.class;
+ }
+ });
+
+
+ GroovyTypeFixStrategyContext.getInstance().addFixStrategy(new GroovyTypeFixStrategy() {
+ @Override
+ public boolean support(Class> clazz) {
+ return MyScriptRequest.class.equals(clazz);
+ }
+
+ @Override
+ public void fix(GroovyScript groovyScript, GroovyType groovyType) {
+ GroovyFunction groovyFunction = new GroovyFunction();
+ groovyFunction.setReturnType("int");
+ groovyFunction.setName("hi");
+ groovyFunction.setDescription("测试");
+ groovyType.addFunction(groovyFunction);
+ }
+ });
+
+
+ GroovyScript groovyScript =
+ GroovyScript.builder("metaTest")
+ .script(script)
+ .description("这是一个run函数,返回的格式为int类型。")
+ .method("run")
+ .tag("123")
+ .returnType(Integer.class)
+ .requests(Map.of("request", MyScriptRequest.class))
+ .build();
+
+ GroovyMetadata metadata = groovyScript.toMetadata();
+ System.out.println(JSON.toJSONString(metadata));
+ assertEquals(1, metadata.getRequests().size());
+ assertEquals("int",metadata.getReturnType());
+ assertEquals(3,metadata.getType("MyScriptRequest").getFunctions().size());
+
+ MyScriptRequest request = new MyScriptRequest(100);
+ long t1 = System.currentTimeMillis();
+ int result = groovyScript.invoke(request);
+ long t2 = System.currentTimeMillis();
+ System.out.println("groovy time:" + (t2 - t1));
+ assertEquals(100, result);
+ }
+
+
+
+ @Test
+ void test2(){
+ String script = """
+
+ def run(request){
+ return request.count;
+ }
+ """;
+
+ GroovyMetadataGenerateStrategyContext.getInstance().addGenerateStrategy(new GroovyMetadataGenerateStrategy() {
+ @Override
+ public boolean support(GroovyScript script) {
+ return true;
+ }
+
+ @Override
+ public GroovyMetadata generate(GroovyScript script) {
+ return new GroovyMetadata("hello","int","hello");
+ }
+ });
+
+
+ GroovyScript groovyScript =
+ GroovyScript.builder("metaTest")
+ .script(script)
+ .description("这是一个run函数,返回的格式为int类型。")
+ .method("run")
+ .tag("123")
+ .returnType(Integer.class)
+ .requests(Map.of("request", MyScriptRequest.class))
+ .build();
+
+ GroovyMetadata metadata = groovyScript.toMetadata();
+ System.out.println(JSON.toJSONString(metadata));
+ assertEquals("int",metadata.getReturnType());
+ assertEquals("hello",metadata.getDescription());
+ assertEquals("hello",metadata.getMainMethod());
+
+ MyScriptRequest request = new MyScriptRequest(100);
+ long t1 = System.currentTimeMillis();
+ int result = groovyScript.invoke(request);
+ long t2 = System.currentTimeMillis();
+ System.out.println("groovy time:" + (t2 - t1));
+ assertEquals(100, result);
+ }
+}
diff --git a/springboot-starter-security/pom.xml b/springboot-starter-security/pom.xml
index 0cab6581..80d66510 100644
--- a/springboot-starter-security/pom.xml
+++ b/springboot-starter-security/pom.xml
@@ -6,7 +6,7 @@
springboot-parent
com.codingapi.springboot
- 3.4.52
+ 3.4.53
springboot-starter-security
diff --git a/springboot-starter/pom.xml b/springboot-starter/pom.xml
index 177de4a2..5ec6cb03 100644
--- a/springboot-starter/pom.xml
+++ b/springboot-starter/pom.xml
@@ -5,7 +5,7 @@
com.codingapi.springboot
springboot-parent
- 3.4.52
+ 3.4.53
springboot-starter
From 6c70d5fcca36966800758daedd3e3d7161c71f74 Mon Sep 17 00:00:00 2001
From: lorne <1991wangliang@gmail.com>
Date: Sat, 30 May 2026 11:01:26 +0800
Subject: [PATCH 2/2] update version
---
.../GroovyMetadataGenerateStrategyContext.java | 6 ++++++
.../script/strategy/GroovyTypeFixStrategyContext.java | 6 ++++++
.../script/strategy/ScriptTypeMappingContext.java | 7 +++++++
.../script/GroovyScriptRuntimeContextTest.java | 11 +++++++++++
.../springboot/script/GroovyStrategyTest.java | 8 ++++++++
.../TransactionGroovyScriptRuntimeContextTest.java | 11 +++++++++++
6 files changed, 49 insertions(+)
diff --git a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyMetadataGenerateStrategyContext.java b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyMetadataGenerateStrategyContext.java
index b2181284..4143003b 100644
--- a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyMetadataGenerateStrategyContext.java
+++ b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyMetadataGenerateStrategyContext.java
@@ -25,6 +25,12 @@ public void addGenerateStrategy(GroovyMetadataGenerateStrategy strategy) {
this.strategies.add(strategy);
}
+ /**
+ * 清空策略
+ */
+ public void clear(){
+ this.strategies.clear();
+ }
public GroovyMetadata generate(GroovyScript groovyScript) {
for (GroovyMetadataGenerateStrategy strategy : this.strategies) {
diff --git a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyTypeFixStrategyContext.java b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyTypeFixStrategyContext.java
index e0708c12..e8ed6a8e 100644
--- a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyTypeFixStrategyContext.java
+++ b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/GroovyTypeFixStrategyContext.java
@@ -22,6 +22,12 @@ public void addFixStrategy(GroovyTypeFixStrategy gateway) {
this.strategies.add(gateway);
}
+ /**
+ * 清空策略
+ */
+ public void clear(){
+ this.strategies.clear();
+ }
public void fix(GroovyScript groovyScript, Class> clazz, GroovyType groovyType) {
for (GroovyTypeFixStrategy strategy : strategies) {
diff --git a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/ScriptTypeMappingContext.java b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/ScriptTypeMappingContext.java
index e4a53be7..c9e30e33 100644
--- a/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/ScriptTypeMappingContext.java
+++ b/springboot-starter-script/src/main/java/com/codingapi/springboot/script/strategy/ScriptTypeMappingContext.java
@@ -28,6 +28,13 @@ public void addMapping(ScriptTypeMapping mapping){
}
+ /**
+ * 清空策略
+ */
+ public void clear(){
+ this.mappings.clear();
+ }
+
/**
* 映射
diff --git a/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyScriptRuntimeContextTest.java b/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyScriptRuntimeContextTest.java
index 00f1baf6..b53359f5 100644
--- a/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyScriptRuntimeContextTest.java
+++ b/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyScriptRuntimeContextTest.java
@@ -3,6 +3,10 @@
import com.alibaba.fastjson.JSON;
import com.codingapi.springboot.script.meta.GroovyMetadata;
import com.codingapi.springboot.script.request.MyScriptRequest;
+import com.codingapi.springboot.script.strategy.GroovyMetadataGenerateStrategyContext;
+import com.codingapi.springboot.script.strategy.GroovyTypeFixStrategyContext;
+import com.codingapi.springboot.script.strategy.ScriptTypeMappingContext;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Map;
@@ -11,6 +15,13 @@
class GroovyScriptRuntimeContextTest {
+ @BeforeEach
+ void beforeRun(){
+ GroovyMetadataGenerateStrategyContext.getInstance().clear();
+ GroovyTypeFixStrategyContext.getInstance().clear();
+ ScriptTypeMappingContext.getInstance().clear();
+ }
+
@Test
void voidInvoke() {
diff --git a/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyStrategyTest.java b/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyStrategyTest.java
index d91b28da..8a50c254 100644
--- a/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyStrategyTest.java
+++ b/springboot-starter-script/src/test/java/com/codingapi/springboot/script/GroovyStrategyTest.java
@@ -6,6 +6,7 @@
import com.codingapi.springboot.script.meta.GroovyType;
import com.codingapi.springboot.script.request.MyScriptRequest;
import com.codingapi.springboot.script.strategy.*;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Map;
@@ -14,6 +15,13 @@
public class GroovyStrategyTest {
+ @BeforeEach
+ void beforeRun(){
+ GroovyMetadataGenerateStrategyContext.getInstance().clear();
+ GroovyTypeFixStrategyContext.getInstance().clear();
+ ScriptTypeMappingContext.getInstance().clear();
+ }
+
@Test
void test1(){
diff --git a/springboot-starter-script/src/test/java/com/codingapi/springboot/script/TransactionGroovyScriptRuntimeContextTest.java b/springboot-starter-script/src/test/java/com/codingapi/springboot/script/TransactionGroovyScriptRuntimeContextTest.java
index 96d5e2be..f3c20ed6 100644
--- a/springboot-starter-script/src/test/java/com/codingapi/springboot/script/TransactionGroovyScriptRuntimeContextTest.java
+++ b/springboot-starter-script/src/test/java/com/codingapi/springboot/script/TransactionGroovyScriptRuntimeContextTest.java
@@ -3,6 +3,10 @@
import com.codingapi.springboot.script.entity.MyTest;
import com.codingapi.springboot.script.repository.MyTestRepository;
import com.codingapi.springboot.script.request.MyScriptRequest;
+import com.codingapi.springboot.script.strategy.GroovyMetadataGenerateStrategyContext;
+import com.codingapi.springboot.script.strategy.GroovyTypeFixStrategyContext;
+import com.codingapi.springboot.script.strategy.ScriptTypeMappingContext;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -21,6 +25,13 @@ class TransactionGroovyScriptRuntimeContextTest {
@Autowired
private MyTestRepository myTestRepository;
+ @BeforeEach
+ void beforeRun(){
+ GroovyMetadataGenerateStrategyContext.getInstance().clear();
+ GroovyTypeFixStrategyContext.getInstance().clear();
+ ScriptTypeMappingContext.getInstance().clear();
+ }
+
@Test
void transactionCommitRun() {