ControlProxy/backend/yjs/ControlProxy.yjs

210 lines
7.1 KiB
Plaintext
Raw Normal View History

2022-06-25 03:11:03 +00:00
import "DAC.yjs";
import "union.yjs";
2023-07-11 14:57:57 +00:00
import "ShanxiAuditPRoxy.yjs";
import "ShanxiDataRepo.yjs";
import "ShanxiGlobalRouter.yjs";
2023-07-26 03:39:08 +00:00
import "ShanxiRegistry.yjs";
2022-04-19 01:26:59 +00:00
//网关为Gateway
//路由器改名为Resolver中文名为标识解析系统
//搜索引擎改名为为Registry中文名为注册表系统
//本文接口由李智负责对接。
2023-07-26 03:39:08 +00:00
contract ShanxiControlProxy {
2022-06-25 03:11:03 +00:00
function convertArgToJson(arg) {
if (typeof(arg)=='string' && !arg.startsWith("{")) return arg;
if (typeof(arg)=='string') return JSON.parse(arg);
return arg;
}
2022-04-19 01:26:59 +00:00
2022-06-25 03:11:03 +00:00
function onCreate(arg) {
if (arg==null|| typeof(arg)=='string'){
arg = {
"prefix":"test.ab.cd", "router":"GlobalRouter"
};
}
arg = convertArgToJson(arg);
Global.router = "GlobalRouter";
Global.prefix = arg.prefix;
Global.router = arg.router;
initDAC(requester);
org.bdware.sc.controlproxy.RepoProxy.init(arg);
2022-04-19 01:26:59 +00:00
}
2022-06-25 03:11:03 +00:00
function isString(arg) {
return typeof(arg)=='string';
}
2022-04-19 01:26:59 +00:00
2022-06-25 03:11:03 +00:00
export function getControlProxyConfig() {
return org.bdware.sc.controlproxy.RepoProxy.getConfig();
}
2022-04-19 01:26:59 +00:00
2022-06-25 03:11:03 +00:00
export function isOwner() {
return checkPermission(requester);
}
@Description("参数为,{\"doId\":\"bdware.ss/Repox\"}")
2022-06-25 03:11:03 +00:00
export function addRepo(arg) {
arg = convertArgToJson(arg);
if (arg.doId ==undefined ){
return {
"msg":"missing arguments repoId ", "code":1
};
}
executeContract("Gateway", "addLocalRepo", arg);
return {
"msg":"success", "rrt":"110ms", "code":0
};
2022-04-19 01:26:59 +00:00
}
2022-06-25 03:11:03 +00:00
//网关需新增的接口
2023-07-11 14:57:57 +00:00
//@Description("参数为,{\"doId\":\"bdware.ss/Repox\"}")
//export function pingRepo(arg) {
//arg = convertArgToJson(arg);
//if (arg.doId ==undefined ){
// return {
// "msg":"missing arguments repoId ", "code":1
// };
//}
2022-06-30 16:46:10 +00:00
// var ret = executeContract("Gateway", "pingRepo", arg.doId);
// ret = ret.result;
// if (ret.rrt > 0)
// return {
// "msg":"success", "rrt":ret.rrt, "code":0, "repoInfo":JSON.parse(ret.repoInfo)
// }; else return {
// "msg":"repo is unconnected", "code":1
// };
2023-07-11 14:57:57 +00:00
//return org.bdware.sc.controlproxy.RepoProxy.pingRepo(arg.doId);
//}
2022-06-30 16:46:10 +00:00
@Description("shanxi/TestLocal shanxi/Repository")
export function testPingRepo(arg) {
return org.bdware.sc.controlproxy.RepoProxy.pingRepo(arg);
}
2022-04-19 01:26:59 +00:00
@Description("shanxi/TestLocal shanxi/Repository")
export function testRepoStatistics(arg) {
return org.bdware.sc.controlproxy.RepoProxy.getRepoStatistics(arg);
}
2022-06-25 03:11:03 +00:00
//网关的接口
2023-07-11 14:57:57 +00:00
//@Description("无参数")
//export function getRepoList(arg) {
2022-04-19 01:26:59 +00:00
//use configed arg.routerId;
2023-07-11 14:57:57 +00:00
// ret = executeContract(Global.router, "listRepo", "");
2022-06-25 03:11:03 +00:00
//ret=executeContract("Gateway","listLocalRepo","");
//var list = ret.result
2023-07-11 14:57:57 +00:00
// return ret.result;
//}
2022-06-25 03:11:03 +00:00
//网关的接口
@Description("参数为 {\"doId\":\"bdware.ss/Repox\"}")
2022-06-25 03:11:03 +00:00
export function deleteRepo(arg) {
arg = convertArgToJson(arg);
if (arg.doId != null && arg.doId.indexOf(Global.prefix) != -1){
executeContract("Gateway", "deleteLocalRepo", arg.doId);
return {
"status":"success", "code":0
};
}
return {
"msg":"can not found repo", "code":1
};
2022-04-19 01:26:59 +00:00
}
2022-06-25 03:11:03 +00:00
//网关的接口 需新增
2023-07-11 14:57:57 +00:00
//@Description("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]")
//export function deleteRepoList(arg) {
// arg = convertArgToJson(arg);
// var ret = [];
// for (var i = 0;
// i<arg.length;
// i++){
// ret.push(deleteRepo(arg[i]));
// }
// return ret;
//}
2022-06-25 03:11:03 +00:00
//网关的接口
@Description("参数为 {\"doId\":..., \"address\":..., \"owner\":..., }")
2022-06-25 03:11:03 +00:00
export function updateRepo(arg) {
arg = convertArgToJson(arg);
if (arg.doId!=null){
executeContract("Gateway", "addLocalRepo", arg);
return {
"msg":"success", "code":0
};
}
return {
"msg":"missing arguments", "code":1
};
}
export function getLevelTopology(arg) {
return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg/1.0);
}
2023-07-11 14:57:57 +00:00
//export function getAllTopology(arg) {
// if (arg==null|| arg.length==0) {
// return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(2);
// } else return org.bdware.sc.controlproxy.TopologyCollector.getLevelTopology(arg/1.0);
//}
2022-06-25 03:11:03 +00:00
//总体拓扑图
//@范博
2023-02-15 16:17:58 +00:00
export function setTopologyLevel(arg) {
Global.level = arg/1.0;
return Global;
}
2022-06-25 03:11:03 +00:00
export function getAllTopology2() {
2023-02-15 16:17:58 +00:00
if (Global.level==null)
Global.level = 0;
return getAllTopology(Global.level);
// var nodeList = [];
// nodeList.push({
// "name":"小店区仓库", "doId":"bdware.ss.ab/Repo1", "type":"Repo", "previousNode":["bdware.ss/Gateway1", "bdware.ss/Gateway2", "bdware.ss.ab/Repo2", "bdware.ss.zz/SearchEngine"]
// }
// );
// nodeList.push({
// "name":"小山区仓库", "doId":"bdware.ss.ab/Repo2", "type":"Repo", "previousNode":["bdware.ss/Gateway1", "bdware.ss/Gateway2", "bdware.ss.ab/SearchEngine"]
// }
// );
// nodeList.push({
// "name":"太原内部共享网关", "doId":"bdware.ss/Gateway1", "type":"Gateway", "previousNode":["bdware/Gateway1", "bdware/Gateway2"]
// }
// );
// nodeList.push({
// "name":"太原对外开放网关", "doId":"bdware.ss/Gateway2", "type":"Gateway", "previousNode":["bdware/Gateway1"]
// }
// );
// nodeList.push({
// "name":"山西内部共享网关", "doId":"bdware/Gateway1", "type":"Gateway"
// }
// );
// nodeList.push({
// "name":"山西内部共享网关2", "doId":"bdware/Gateway2", "type":"Gateway"
// }
// );
// nodeList.push({
// "name":"xxx搜索引擎", "doId":"bdware.ss/SearchEngine", "type":"SearchEngine", "previousNode":["bdware.ss.cc/SearchEngine"]
// }
// );
// nodeList.push({
// "name":"山西内部共享搜索引擎2", "doId":"bdware.ss.ab/SearchEngine", "type":"SearchEngine", "previousNode":["bdware.ss/SearchEngine"]
// }
// );
// nodeList.push({
// "name":"yyy搜索引擎", "doId":"bdware.ss.cc/SearchEngine", "type":"SearchEngine"
// }
// );
// nodeList.push({
// "name":"zzz搜索引擎", "doId":"bdware.ss.zz/SearchEngine", "type":"SearchEngine", "previousNode":["bdware.ss.cc/SearchEngine"]
// }
// );
// nodeList.push({
// "name":"贵州省域路由器", "doId":"bdware.ss.ab", "type":"Router", "previousNode":["bdware"]
// }
// );
// nodeList.push({
// "name":"山西省域路由器", "doId":"bdware.ss", "type":"Router", "previousNode":["bdware"]
// }
// );
// nodeList.push({
// "name":"数瑞测试网", "doId":"bdware", "type":"Router"
// }
// );
// return nodeList;
2022-04-19 01:26:59 +00:00
}
}