mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
feat: support @RouteInfo byFunc
This commit is contained in:
parent
fa729d80a0
commit
bac80bbf31
@ -1,5 +1,6 @@
|
||||
package org.bdware.sc;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
@ -846,6 +847,21 @@ public class ContractProcess {
|
||||
return logIndex.size();
|
||||
}
|
||||
|
||||
public String executeFunctionWithoutLimit(String arg) {
|
||||
try {
|
||||
JsonObject body = JsonUtil.parseString(arg).getAsJsonObject();
|
||||
String funcName = body.get("funcName").getAsString();
|
||||
JsonArray arr = body.getAsJsonArray("funcArgs");
|
||||
Object[] funcArgs = JsonUtil.fromJson(arr, Object[].class);
|
||||
Object result = engine.invokeFunction(funcName, funcArgs);
|
||||
return JsonUtil.toJson(result);
|
||||
} catch (Exception e) {
|
||||
ByteArrayOutputStream bo = new ByteArrayOutputStream();
|
||||
e.printStackTrace(new PrintStream(bo));
|
||||
return bo.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public String executeContract(String arg) {
|
||||
// TODO
|
||||
// eventCenter.pub(new EventMsg("executeContract", arg));
|
||||
|
@ -115,6 +115,11 @@ public class ContractHandler extends MsgHandler implements Runnable {
|
||||
cb.onResult(cs.executeContract(msg.arg));
|
||||
}
|
||||
|
||||
@Description(value = "invoke function without limit")
|
||||
public void invokeFunctionWithoutLimit(GetMessage msg, ResultCallback cb) {
|
||||
cb.onResult(cs.executeFunctionWithoutLimit(msg.arg));
|
||||
}
|
||||
|
||||
@Description("set DesktopPermission")
|
||||
public void setDesktopPermission(GetMessage msg, ResultCallback cb) {
|
||||
String result = cs.setDesktopPermission(msg.arg);
|
||||
|
Loading…
Reference in New Issue
Block a user