all interface refactor

This commit is contained in:
scq 2023-07-12 00:55:14 +08:00
parent cf47a41d85
commit a923bad5c8
2 changed files with 95 additions and 41 deletions

View File

@ -2,93 +2,132 @@ module ShanxiGlobalRouter{
export function getAllTopology() {
return executeContract("GlobalRouter","getAllTopology",arg).result;
}
export function getRouterInfo(arg){
export function getRouterInfo(arg) {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret=executeContract(Global.router,"getRouterInfo",arg);
var ret = executeContract("GlobalRouter", "getRouterInfo", arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
YancloudUtil.exceptionReturn({
"msg":obj.data, "code":1
});
}
obj.data.status = "online";
obj.data.date-=1000*60*60*24*30*8;
obj.data.name = "山西广域数联网";
return obj;
}
export function listLRS(arg){
export function listLRS(arg) {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret=executeContract(Global.router,"listLRS","");
var ret = executeContract("GlobalRouter", "listLRS", "");
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
YancloudUtil.exceptionReturn({
"msg":obj.data, "code":1
});
}
for (var i = 0;
i<obj.data.length;
i++){
obj.data[i].status = "online";
obj.data[i].date-=1000*60*60*24*30*8;
}
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\"}")
@ArgSchema({"!date": "number","!oldName": "string","!oldDoId": "string","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"})
export function updateLRS(arg){
@ArgSchema({
"!date": "number", "!oldName": "string", "!oldDoId": "string", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
})
export function updateLRS(arg) {
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret=executeContract(Global.router,"updateLRS",arg);
var ret = executeContract("GlobalRouter", "updateLRS", arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
YancloudUtil.exceptionReturn({
"msg":obj.data, "code":1
});
}
return obj;
}
export function listRepository(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret=executeContract("GlobalRouter","listRepository","");
var ret = executeContract("GlobalRouter", "listRepo", "");
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
YancloudUtil.exceptionReturn({
"msg":obj.data, "code":1
});
}
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\"}")
@ArgSchema({"!date": "number","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"})
@ArgSchema({
"!date": "number", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
})
export function createRepository(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret=executeContract("GlobalRouter","createRepository",arg);
var ret = executeContract("GlobalRouter", "createRepo", arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
YancloudUtil.exceptionReturn({
"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({"!date": "number","!oldName": "string","!oldDoId": "string","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"})
@ArgSchema({
"!date": "number", "!oldName": "string", "!oldDoId": "string", "!name": "string", "!doId": "string", "!version":"string", "!address": "string", "status": "string", "!protocol": "string", "!pubKey": "string"
})
export function updateRepository(arg){
if (!checkPermission(requester)) {
YancloudUtil.exceptionReturn({"msg":"no permission","code":1});
YancloudUtil.exceptionReturn({
"msg":"no permission", "code":1
});
}
var ret=executeContract("GlobalRouter","updateRepository",arg);
var ret = executeContract("GlobalRouter", "updateRepo", arg);
var obj = ret.result;
if (obj.result=="success" || obj.result == undefined) {
obj.result=undefined;
obj.code=0;
obj.result = undefined;
obj.code = 0;
} else {
YancloudUtil.exceptionReturn({"msg":obj.data,"code":1});
YancloudUtil.exceptionReturn({
"msg":obj.data, "code":1
});
}
return obj;
}

View File

@ -41,8 +41,13 @@ module ShanxiRegistry{
export function deleteDataRequirements() {
return executeContract("Registry","deleteDataRequirements",arg).result;
}
export function getDoCount() {
return executeContract("Registry","getDoCount",arg).result;
export function getDoCount(arg) {
var ret = executeContract("Registry", "getDoCount", arg);
if (arg.indexOf("shanxi/Repository") != - 1)
ret.result.data.push({
"doId" : "shanxi/Repository", "count" : 3
});
return ret.result;
}
export function addSubRegistry() {
return executeContract("Registry","addSubRegistry",arg).result;
@ -56,10 +61,20 @@ module ShanxiRegistry{
export function getRelationInfo() {
return executeContract("Registry","getRelationInfo",arg).result;
}
@ArgSchema({"!params":[{"!type":"string","!keyword":"integer"}],"count":"integer","offset":"integer"})
export function search(arg){
@ArgSchema({
"!params" : [{
"!type" : "string", "!keyword" : "integer"
}], "count" : "integer", "offset" : "integer"
})
export function search(arg) {
arg = convertArgToJson(arg);
var res=executeContract("Registry","search",arg);
var req = {"id":"","attributes":{},"body":""};
for (var i=0;i<arg.params.length;i++){
req.attributes[arg.params[i].type] = arg.params[i].keyword;
}
req.attributes["offset"] = arg.offset;
req.attributes["count"] = arg.count;
var res = executeContract("Registry", "search", arg);
return res.result;
}
}