Skip to content

Commit 49e890f

Browse files
committed
fix GroovyScriptRuntime
1 parent 4ca6af8 commit 49e890f

1 file changed

Lines changed: 49 additions & 2 deletions

File tree

‎springboot-starter-script/src/main/java/com/codingapi/springboot/script/GroovyScriptRuntime.java‎

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,41 @@ public void compile(String script) {
9292
* @param args 函数参数
9393
* @return 返回数据
9494
*/
95+
public <T> T invoke(String method,
96+
String script,
97+
Class<T> returnType,
98+
List<ObjectBinder> binds,
99+
Object... args) {
100+
return this.invoke(method, script, returnType, TransactionMode.DEFAULT, binds, args);
101+
}
102+
103+
/**
104+
* 执行函数脚本
105+
*
106+
* @param method 函数名称
107+
* @param script 脚本内容
108+
* @param returnType 返回类型
109+
* @param args 函数参数
110+
* @return 返回数据
111+
*/
112+
public <T> T invoke(String method,
113+
String script,
114+
Class<T> returnType,
115+
Object... args) {
116+
return this.invoke(method, script, returnType, TransactionMode.DEFAULT, null, args);
117+
}
118+
119+
/**
120+
* 执行函数脚本
121+
*
122+
* @param method 函数名称
123+
* @param script 脚本内容
124+
* @param returnType 返回类型
125+
* @param transactionMode 事务模式
126+
* @param binds 绑定数据对象
127+
* @param args 函数参数
128+
* @return 返回数据
129+
*/
95130
public <T> T invoke(String method,
96131
String script,
97132
Class<T> returnType,
@@ -132,7 +167,6 @@ public <T> T invoke(String method,
132167
return (T) runtime.invokeMethod(method, args);
133168
}
134169

135-
136170
/**
137171
* 执行脚本
138172
*
@@ -141,7 +175,20 @@ public <T> T invoke(String method,
141175
* @param binds 绑定对象
142176
* @return 返回数据
143177
*/
144-
public <T> T run(String script, Class<T> returnType,TransactionMode transactionMode, List<ObjectBinder> binds) {
178+
public <T> T run(String script, Class<T> returnType, List<ObjectBinder> binds) {
179+
return this.run(script, returnType, TransactionMode.DEFAULT, binds);
180+
}
181+
182+
/**
183+
* 执行脚本
184+
*
185+
* @param script 脚本
186+
* @param returnType 返回数据类型
187+
* @param transactionMode 事务模式
188+
* @param binds 绑定对象
189+
* @return 返回数据
190+
*/
191+
public <T> T run(String script, Class<T> returnType, TransactionMode transactionMode, List<ObjectBinder> binds) {
145192
String key = SHA256.sha256(script);
146193
Script runtime = this.cache.get(key);
147194
if (runtime == null) {

0 commit comments

Comments
 (0)