mirror of
https://gitee.com/BDWare/router-backend
synced 2025-01-27 02:04:05 +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 {
|
public class NCManagerAction {
|
||||||
// key为centerManager的数据表示平台管理员(中心管理员)
|
// key为centerManager的数据表示平台管理员(中心管理员)
|
||||||
public static final String centerManger = "__CenterManager__";
|
public static final String centerManger = "__CenterManager__";
|
||||||
|
public static final String clusterName = "__ClusterName__";
|
||||||
static final String Licence = "__LICENCE___";
|
static final String Licence = "__LICENCE___";
|
||||||
static final ECPublicKeyParameters licencePub =
|
static final ECPublicKeyParameters licencePub =
|
||||||
BCECUtil.createECPublicKeyFromStrParameters(
|
BCECUtil.createECPublicKeyFromStrParameters(
|
||||||
@ -49,12 +50,14 @@ public class NCManagerAction {
|
|||||||
&& !StringUtil.isNullOrEmpty(pubkey)
|
&& !StringUtil.isNullOrEmpty(pubkey)
|
||||||
&& pubkey.equals(ret);
|
&& pubkey.equals(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void simpleReply(ResultCallback resultCallback, String action, String data) {
|
private void simpleReply(ResultCallback resultCallback, String action, String data) {
|
||||||
JsonObject jsonResult = new JsonObject();
|
JsonObject jsonResult = new JsonObject();
|
||||||
jsonResult.addProperty("action", action);
|
jsonResult.addProperty("action", action);
|
||||||
jsonResult.addProperty("data", data);
|
jsonResult.addProperty("data", data);
|
||||||
resultCallback.onResult(jsonResult);
|
resultCallback.onResult(jsonResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Action(userPermission = 0)
|
@Action(userPermission = 0)
|
||||||
public void getNodeSessionID(JsonObject json, ResultCallback resultCallback) {
|
public void getNodeSessionID(JsonObject json, ResultCallback resultCallback) {
|
||||||
getSessionID(json, resultCallback);
|
getSessionID(json, resultCallback);
|
||||||
@ -83,6 +86,23 @@ public class NCManagerAction {
|
|||||||
simpleReply(resultCallback, "onGetManagerPubkey", ret);
|
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) {
|
public void getRole(JsonObject json, ResultCallback resultCallback) {
|
||||||
if (pubKey == null) {
|
if (pubKey == null) {
|
||||||
simpleReply(resultCallback, "onLogin", Role.Anonymous.name());
|
simpleReply(resultCallback, "onLogin", Role.Anonymous.name());
|
||||||
@ -111,6 +131,8 @@ public class NCManagerAction {
|
|||||||
} else {
|
} else {
|
||||||
KeyValueDBUtil.instance.setValue(
|
KeyValueDBUtil.instance.setValue(
|
||||||
NCTables.ConfigDB.toString(), centerManger, pubKey);
|
NCTables.ConfigDB.toString(), centerManger, pubKey);
|
||||||
|
KeyValueDBUtil.instance.setValue(
|
||||||
|
NCTables.ConfigDB.toString(), clusterName, "clusterName_" + pubKey.substring(0, 5));
|
||||||
handler.setPermission(0x30000ffL);
|
handler.setPermission(0x30000ffL);
|
||||||
simpleReply(resultCallback, "onLogin", "CenterManager");
|
simpleReply(resultCallback, "onLogin", "CenterManager");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user