ControlProxy/backend/yjs/ShanxiGlobalRouter.yjs

260 lines
11 KiB
Plaintext
Raw Normal View History

2023-08-17 10:42:36 +00:00
module ShanxiGlobalRouter {
2023-07-11 16:55:14 +00:00
export function getRouterInfo(arg) {
2023-08-17 10:42:36 +00:00
if (! checkPermission(requester)) {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : "no permission", "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
2023-08-17 10:42:36 +00:00
var ret = executeContract(Global.router, "getRouterInfo", arg);
2023-07-11 14:57:57 +00:00
var obj = ret.result;
2023-08-17 10:42:36 +00:00
if (obj.result == "success") {
2023-07-11 16:55:14 +00:00
obj.result = undefined;
obj.code = 0;
2023-07-11 14:57:57 +00:00
} else {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : obj.data, "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
2023-07-11 16:55:14 +00:00
obj.data.status = "online";
obj.data.name = "山西广域数联网";
2023-07-11 14:57:57 +00:00
return obj;
}
2023-07-11 16:55:14 +00:00
export function listLRS(arg) {
2023-08-17 10:42:36 +00:00
if (! checkPermission(requester)) {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : "no permission", "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
2023-08-17 10:42:36 +00:00
var ret = executeContract(Global.router, "listLRS", "");
2023-07-11 14:57:57 +00:00
var obj = ret.result;
2023-08-17 10:42:36 +00:00
if (obj.result == "success" || obj.result == undefined) {
2023-07-11 16:55:14 +00:00
obj.result = undefined;
obj.code = 0;
2023-07-11 14:57:57 +00:00
} else {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : obj.data, "code" : 1
2023-07-11 16:55:14 +00:00
});
}
2023-08-17 10:42:36 +00:00
for (var i = 0; i < obj.data.length; i ++){
2023-07-11 16:55:14 +00:00
obj.data[i].status = "online";
2023-07-11 14:57:57 +00:00
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"oldName\": \"路由器\",\"oldDoId\": \"bdwaretest.loccall.next0\",\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"version\": \"2.1\",\"address\": \"127.0.0.1:2222\",\"status\": \"已审核\",\"protocol\": \"IRP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
2023-07-11 16:55:14 +00:00
@ArgSchema({
2023-08-17 10:42:36 +00:00
"!date" : "number", "!oldName" : "string", "!oldDoId" : "string", "!name" : "string", "!doId" : "string", "!version" : "string", "!address" : "string", "status" : "string", "!protocol" : "string", "!pubKey" : "string"
2023-07-11 16:55:14 +00:00
})
export function updateLRS(arg) {
2023-08-17 10:42:36 +00:00
if (! checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg" : "no permission", "code" : 1
});
}
var ret = executeContract(Global.router, "updateLRS", JSON.stringify(arg));
var obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "code" : 1
});
}
return obj;
}
export function createLRS(arg) {
if (! checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg" : "no permission", "code" : 1
});
}
var ret = executeContract(Global.router, "createLRS", arg);
var obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "code" : 1
});
}
return obj;
}
export function deleteLRS(arg) {
if (! checkPermission(requester)) {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : "no permission", "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
2023-08-17 10:42:36 +00:00
var ret = executeContract(Global.router, "deleteLRS", arg);
2023-07-11 14:57:57 +00:00
var obj = ret.result;
2023-08-17 10:42:36 +00:00
if (obj.result == "success" || obj.result == undefined) {
2023-07-11 16:55:14 +00:00
obj.result = undefined;
obj.code = 0;
2023-07-11 14:57:57 +00:00
} else {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : obj.data, "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
return obj;
}
2023-08-17 10:42:36 +00:00
export function listRepository(arg) {
if (! checkPermission(requester)) {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : "no permission", "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
2023-08-17 10:42:36 +00:00
var ret = executeContract(Global.router, "listRepo", "");
2023-07-11 14:57:57 +00:00
var obj = ret.result;
2023-08-17 10:42:36 +00:00
if (obj.result == "success" || obj.result == undefined) {
2023-07-11 16:55:14 +00:00
obj.result = undefined;
obj.code = 0;
2023-07-11 14:57:57 +00:00
} else {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : obj.data, "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\"\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
2023-07-11 16:55:14 +00:00
@ArgSchema({
2023-08-17 10:42:36 +00:00
"!date" : "number", "!name" : "string", "!doId" : "string", "!version" : "string", "!address" : "string", "status" : "string", "!protocol" : "string", "!pubKey" : "string"
2023-07-11 16:55:14 +00:00
})
2023-08-17 10:42:36 +00:00
export function createRepository(arg) {
if (! checkPermission(requester)) {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : "no permission", "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
2023-08-17 10:42:36 +00:00
var ret = executeContract(Global.router, "createRepo", JSON.stringify(arg));
2023-07-11 14:57:57 +00:00
var obj = ret.result;
2023-08-17 10:42:36 +00:00
if (obj.result == "success" || obj.result == undefined) {
2023-07-11 16:55:14 +00:00
obj.result = undefined;
obj.code = 0;
2023-07-11 14:57:57 +00:00
} else {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : obj.data, "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"oldName\": \"Repo0\",\"oldDoId\": \"bdwaretest.loccall/Repo0\",\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\"\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
2023-07-11 16:55:14 +00:00
@ArgSchema({
2023-08-17 10:42:36 +00:00
"!date" : "number", "!oldName" : "string", "!oldDoId" : "string", "!name" : "string", "!doId" : "string", "!version" : "string", "!address" : "string", "status" : "string", "!protocol" : "string", "!pubKey" : "string"
2023-07-11 16:55:14 +00:00
})
2023-08-17 10:42:36 +00:00
export function updateRepository(arg) {
if (! checkPermission(requester)) {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : "no permission", "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
2023-08-17 10:42:36 +00:00
var ret = executeContract(Global.router, "updateRepo", JSON.stringify(arg));
2023-07-11 14:57:57 +00:00
var obj = ret.result;
2023-08-17 10:42:36 +00:00
if (obj.result == "success" || obj.result == undefined) {
2023-07-11 16:55:14 +00:00
obj.result = undefined;
obj.code = 0;
2023-07-11 14:57:57 +00:00
} else {
2023-07-11 16:55:14 +00:00
YancloudUtil.exceptionReturn({
2023-08-17 10:42:36 +00:00
"msg" : obj.data, "code" : 1
});
}
return obj;
}
@Descripton("参数为,{\"date\": 1642467459759,\"oldName\": \"Repo0\",\"oldDoId\": \"bdwaretest.loccall/Repo0\",\"name\": \"Repo1\",\"doId\": \"bdwaretest.loccall/Repo1\",\"version\": \"2.1\"\"address\": \"tcp://127.0.0.1:21042\",\"status\": \"已审核\",\"protocol\": \"DOIP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}")
@ArgSchema({
"!name" : "string", "!doId" : "string", "!pubKey" : "string"
})
export function deleteRepository(arg) {
if (! checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg" : "no permission", "code" : 1
});
}
var ret = executeContract(Global.router, "deleteRepo", JSON.stringify(arg));
var obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "code" : 1
2023-07-11 16:55:14 +00:00
});
2023-07-11 14:57:57 +00:00
}
return obj;
}
export function getUpperRouterInfo() {
2023-08-17 10:42:36 +00:00
return executeContract(Global.router, "getUpperRouterInfo", arg).result;
}
@ArgSchema({
"!upperIP" : "string", "!upperPort" : "string", "!pubKey" : "string", "!name" : "string", "!signature" : "string"
})
//待测试
export function setUpperInfo(arg) {
if (! checkPermission(requester)) {
YancloudUtil.exceptionReturn({
"msg" : "no permission", "code" : 1
});
}
var ret = executeContract(Global.router, "setUpperIP", JSON.stringify(arg));
var obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setUpperIP", "code" : 1
});
}
ret = executeContract(Global.router, "setUpperPort", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setUpperPort", "code" : 1
});
}
ret = executeContract(Global.router, "setName", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setName", "code" : 1
});
}
ret = executeContract(Global.router, "setPubKey", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setPubKey", "code" : 1
});
}
ret = executeContract(Global.router, "setSignature", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in setSignature", "code" : 1
});
}
ret = executeContract(Global.router, "reInit", JSON.stringify(arg));
obj = ret.result;
if (obj.result == "success" || obj.result == undefined) {
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({
"msg" : obj.data, "extraMsg" : "error in reInit", "code" : 1
});
}
return obj;
2023-07-11 14:57:57 +00:00
}
}