This commit is contained in:
Frank.R.Wu 2021-12-09 14:37:08 +08:00
parent ba32cc25e7
commit f71bfda28e

View File

@ -21,18 +21,20 @@ public class UnitActions {
public UnitActions(NCManagerAction managerAction) { public UnitActions(NCManagerAction managerAction) {
this.managerAction = managerAction; this.managerAction = managerAction;
} }
private void simpleReply(ResultCallback resultCallback, String action, Object data){
Map<String,Object> jsonResult = new HashMap<>();
jsonResult.put("action", action);
jsonResult.put("data", data);
resultCallback.onResult(jsonResult);
}
private static String convertContractName(String contractID) { private static String convertContractName(String contractID) {
ContractDesp desp = NodeCenterActions.getContractByName(contractID); ContractDesp desp = NodeCenterActions.getContractByName(contractID);
if (desp != null) return desp.contractID; if (desp != null) return desp.contractID;
return contractID; return contractID;
} }
private void simpleReply(ResultCallback resultCallback, String action, Object data) {
Map<String, Object> jsonResult = new HashMap<>();
jsonResult.put("action", action);
jsonResult.put("data", data);
resultCallback.onResult(jsonResult);
}
/** /**
* 显示当前用户可见的集群 * 显示当前用户可见的集群
* *
@ -48,7 +50,7 @@ public class UnitActions {
&& KeyValueDBUtil.instance && KeyValueDBUtil.instance
.getValue(NCTables.ConfigDB.toString(), "__CenterManager__") .getValue(NCTables.ConfigDB.toString(), "__CenterManager__")
.contains(pubKey)) { .contains(pubKey)) {
simpleReply(resultCallback,"onListTrustUnits",allunits); simpleReply(resultCallback, "onListTrustUnits", allunits);
LOGGER.debug("is center manager"); LOGGER.debug("is center manager");
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
LOGGER.debug("[listTrustUnits:time]" + (end - start)); LOGGER.debug("[listTrustUnits:time]" + (end - start));
@ -63,7 +65,7 @@ public class UnitActions {
ciunits.add(kv); ciunits.add(kv);
} }
} }
simpleReply(resultCallback,"onListTrustUnits",ciunits); simpleReply(resultCallback, "onListTrustUnits", ciunits);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
LOGGER.debug("[listTrustUnits:time]" + (end - start)); LOGGER.debug("[listTrustUnits:time]" + (end - start));
} }
@ -118,7 +120,7 @@ public class UnitActions {
nodeunits.add(kv); nodeunits.add(kv);
} }
} }
simpleReply(resultCallback,"onGetNodeTrustUnits",nodeunits); simpleReply(resultCallback, "onGetNodeTrustUnits", nodeunits);
} }
// @Action(async = true, userPermission = 0) // @Action(async = true, userPermission = 0)
@ -205,7 +207,7 @@ public class UnitActions {
ContractDesp desp = NodeCenterActions.getContractByID(key); ContractDesp desp = NodeCenterActions.getContractByID(key);
if (desp != null) info.add(desp); if (desp != null) info.add(desp);
} }
simpleReply(rc,"onListContractProcess",JsonUtil.toJson(info)); simpleReply(rc, "onListContractProcess", JsonUtil.toJson(info));
} }
@Action(userPermission = 1 << 6, async = true) @Action(userPermission = 1 << 6, async = true)
@ -221,7 +223,7 @@ public class UnitActions {
ContractDesp desp = NodeCenterActions.getContractByID(key); ContractDesp desp = NodeCenterActions.getContractByID(key);
if (desp != null) info.add(desp); if (desp != null) info.add(desp);
} }
simpleReply(resultCallback,"onListMultiPointContractProcess",JsonUtil.toJson(info)); simpleReply(resultCallback, "onListMultiPointContractProcess", JsonUtil.toJson(info));
} }
@Action(userPermission = 1 << 6, async = true) @Action(userPermission = 1 << 6, async = true)