mirror of
https://gitee.com/BDWare/router-backend
synced 2025-01-26 09:44:04 +00:00
feat: add get&set ClusterName
This commit is contained in:
parent
50ae835148
commit
537ecbfc6c
@ -25,6 +25,7 @@ import java.util.*;
|
||||
public class NCManagerAction {
|
||||
// key为centerManager的数据表示平台管理员(中心管理员)
|
||||
public static final String centerManger = "__CenterManager__";
|
||||
public static final String clusterName = "__ClusterName__";
|
||||
static final String Licence = "__LICENCE___";
|
||||
static final ECPublicKeyParameters licencePub =
|
||||
BCECUtil.createECPublicKeyFromStrParameters(
|
||||
@ -49,12 +50,14 @@ public class NCManagerAction {
|
||||
&& !StringUtil.isNullOrEmpty(pubkey)
|
||||
&& pubkey.equals(ret);
|
||||
}
|
||||
|
||||
private void simpleReply(ResultCallback resultCallback, String action, String data) {
|
||||
JsonObject jsonResult = new JsonObject();
|
||||
jsonResult.addProperty("action", action);
|
||||
jsonResult.addProperty("data", data);
|
||||
resultCallback.onResult(jsonResult);
|
||||
}
|
||||
|
||||
@Action(userPermission = 0)
|
||||
public void getNodeSessionID(JsonObject json, ResultCallback resultCallback) {
|
||||
getSessionID(json, resultCallback);
|
||||
@ -83,6 +86,23 @@ public class NCManagerAction {
|
||||
simpleReply(resultCallback, "onGetManagerPubkey", ret);
|
||||
}
|
||||
|
||||
@Action(userPermission = 0)
|
||||
public void getClusterName(JsonObject json, ResultCallback resultCallback) {
|
||||
String ret = KeyValueDBUtil.instance.getValue(NCTables.ConfigDB.toString(), clusterName);
|
||||
simpleReply(resultCallback, "onGetClusterName", ret);
|
||||
}
|
||||
|
||||
@Action(userPermission = 0)
|
||||
public void setClusterName(JsonObject json, ResultCallback resultCallback) {
|
||||
if (json.has("name")) {
|
||||
KeyValueDBUtil.instance.setValue(
|
||||
NCTables.ConfigDB.toString(), clusterName, json.get("name").getAsString());
|
||||
simpleReply(resultCallback, "onSetClusterName", "success");
|
||||
} else {
|
||||
simpleReply(resultCallback, "onSetClusterName", "failed");
|
||||
}
|
||||
}
|
||||
|
||||
public void getRole(JsonObject json, ResultCallback resultCallback) {
|
||||
if (pubKey == null) {
|
||||
simpleReply(resultCallback, "onLogin", Role.Anonymous.name());
|
||||
@ -111,6 +131,8 @@ public class NCManagerAction {
|
||||
} else {
|
||||
KeyValueDBUtil.instance.setValue(
|
||||
NCTables.ConfigDB.toString(), centerManger, pubKey);
|
||||
KeyValueDBUtil.instance.setValue(
|
||||
NCTables.ConfigDB.toString(), clusterName, "clusterName_" + pubKey.substring(0, 5));
|
||||
handler.setPermission(0x30000ffL);
|
||||
simpleReply(resultCallback, "onLogin", "CenterManager");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user