From 66b18fd63a7f5c5753a12c36bad43d7ac89898d0 Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Mon, 1 Nov 2021 17:31:35 +0800 Subject: [PATCH] prune: delete ResultBack --- .../org/bdware/server/action/CMActions.java | 18 +++-------------- .../server/action/UserManagerAction.java | 20 +++---------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/bdware/server/action/CMActions.java b/src/main/java/org/bdware/server/action/CMActions.java index a353ce6..7481798 100644 --- a/src/main/java/org/bdware/server/action/CMActions.java +++ b/src/main/java/org/bdware/server/action/CMActions.java @@ -15,7 +15,6 @@ import org.bdware.sc.util.JsonUtil; import org.bdware.server.GRPCPool; import org.bdware.server.GlobalConf; import org.bdware.server.action.p2p.MasterClientTCPAction; -import org.bdware.server.nodecenter.ResultBack; import org.bdware.server.trustedmodel.MasterProxy; import org.bdware.server.ws.ContractManagerFrameHandler; import org.bdware.units.NetworkManager; @@ -649,13 +648,8 @@ public class CMActions implements OnHashCallback { String contractName = json.get("contractName").getAsString(); String functionName = json.get("functionName").getAsString(); String args = json.get("args").getAsString(); - String test = manager.getGasEvaluates(contractName, functionName, args); - - ResultBack result = new ResultBack(); - result.action = "onEvaluates"; - result.data = "success"; - resultCallback.onResult(JsonUtil.toJson(result)); + ReplyUtil.simpleReply(resultCallback,"onEvaluates","success"); } @Action(userPermission = 1L << 16) @@ -1599,10 +1593,7 @@ public class CMActions implements OnHashCallback { closePermission = closePermission.replace(", ", ""); String resetPermission = manager.resetPermission(contractFileName, closePermission, isOpen); LOGGER.debug(resetPermission); - ResultBack result = new ResultBack(); - result.action = "onSetPermission"; - result.data = "success"; - resultCallback.onResult(JsonUtil.toJson(result)); + ReplyUtil.simpleReply(resultCallback,"onSetPermission","success"); } @Action(userPermission = 1L << 26, async = true, httpAccess = false) @@ -1610,10 +1601,7 @@ public class CMActions implements OnHashCallback { boolean flag = json.get("isDebug").getAsBoolean(); String contractID = json.get("contractID").getAsString(); String resetPermission = manager.resetDebugFlag(contractID, flag); - ResultBack result = new ResultBack(); - result.action = "onSetDebugFlag"; - result.data = resetPermission; - resultCallback.onResult(JsonUtil.toJson(result)); + ReplyUtil.simpleReply(resultCallback,"onSetDebugFlag",resetPermission); } @Override diff --git a/src/main/java/org/bdware/server/action/UserManagerAction.java b/src/main/java/org/bdware/server/action/UserManagerAction.java index b42ada7..719b8fa 100644 --- a/src/main/java/org/bdware/server/action/UserManagerAction.java +++ b/src/main/java/org/bdware/server/action/UserManagerAction.java @@ -10,7 +10,6 @@ import org.bdware.sc.db.CMTables; import org.bdware.sc.db.KeyValueDBUtil; import org.bdware.sc.util.JsonUtil; import org.bdware.server.GlobalConf; -import org.bdware.server.nodecenter.ResultBack; import org.bdware.server.permission.Role; import org.bdware.server.ws.ContractManagerFrameHandler; import org.zz.gmhelper.SM2Util; @@ -162,14 +161,9 @@ public class UserManagerAction { List time = KeyValueDBUtil.instance.getKeyValues(CMTables.ApplyTime.toString()); List kv = KeyValueDBUtil.instance.getKeyValues(CMTables.ApplyRole.toString()); Map ret = new HashMap<>(); - ret.put("kv", kv); ret.put("time", time); - ResultBack result = new ResultBack(); - result.action = "onListUnAuthRole"; - result.data = ret; - resultCallback.onResult(JsonUtil.toJson(result)); - // resultCallback.onResult("{\"action\":\"onListUnAuthRole\",\"data\":\"success\"}"); + ReplyUtil.simpleReply(resultCallback,"onListUnAuthRole",ret); } @Action(userPermission = 1 << 11) @@ -177,13 +171,9 @@ public class UserManagerAction { List kv = KeyValueDBUtil.instance.getKeyValues(CMTables.NodeRole.toString()); List time = KeyValueDBUtil.instance.getKeyValues(CMTables.NodeTime.toString()); Map ret = new HashMap<>(); - ret.put("kv", kv); ret.put("time", time); - ResultBack result = new ResultBack(); - result.action = "onListAllAuthRole"; - result.data = ret; - resultCallback.onResult(JsonUtil.toJson(result)); + ReplyUtil.simpleReply(resultCallback,"onListAllAuthRole",ret); } @Action(userPermission = 1L << 11) @@ -220,11 +210,7 @@ public class UserManagerAction { map.put("ContractProvider", cp); map.put("ContractInstanceManager", cm); map.put("ContractUser", cp); - ResultBack result = new ResultBack(); - result.action = "onCountRole"; - result.data = map; - result.status = true; - resultCallback.onResult(JsonUtil.toJson(result)); + ReplyUtil.simpleReply(resultCallback,"onCountRole",map); } @Action(userPermission = 1 << 10)