From c29538179fef42f70fefe39fac30f695f8878126 Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Tue, 19 Apr 2022 09:26:59 +0800 Subject: [PATCH] intial commit --- backend/build.gradle | 19 +- .../org/bdware/sc/contractexample/Hello.java | 26 - .../bdware/sc/controlproxy/Hello/Hello.java | 74 ++ backend/yjs/ControlProxy.yjs | 140 +++ backend/yjs/ControlProxy接口.md | 1048 +++++++++++++++++ backend/yjs/DAC.yjs | 49 + backend/yjs/README.md | 86 ++ backend/yjs/assets/logo.png | Bin 0 -> 352 bytes backend/yjs/audit.yjs | 13 + backend/yjs/manifest.json | 12 +- backend/yjs/networking.yjs | 307 +++++ backend/yjs/repodetail.yjs | 135 +++ backend/yjs/search.yjs | 140 +++ build.gradle | 8 +- settings.gradle | 2 +- 15 files changed, 2011 insertions(+), 48 deletions(-) delete mode 100644 backend/src/main/java/org/bdware/sc/contractexample/Hello.java create mode 100644 backend/src/main/java/org/bdware/sc/controlproxy/Hello/Hello.java create mode 100755 backend/yjs/ControlProxy.yjs create mode 100755 backend/yjs/ControlProxy接口.md create mode 100755 backend/yjs/DAC.yjs create mode 100755 backend/yjs/README.md create mode 100755 backend/yjs/assets/logo.png create mode 100755 backend/yjs/audit.yjs mode change 100644 => 100755 backend/yjs/manifest.json create mode 100755 backend/yjs/networking.yjs create mode 100755 backend/yjs/repodetail.yjs create mode 100755 backend/yjs/search.yjs diff --git a/backend/build.gradle b/backend/build.gradle index ac97704..15f65c7 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -1,6 +1,6 @@ buildscript { dependencies { - classpath files("buildlibs/simpleypkpacker.jar") + classpath files("buildlibs/simple-ypk-packer-0.1.0.jar") } } @@ -36,8 +36,11 @@ sourceSets { dependencies { api 'org.apache.logging.log4j:log4j-core:2.14.1' api 'org.apache.logging.log4j:log4j-api:2.14.1' + api 'com.google.code.gson:gson:2.8.8' + implementation fileTree(dir: 'cplibs', include: '*.jar') implementation fileTree(dir: 'cplibs/lib/', include: '*.jar') + implementation 'org.bdware.doip:doip-audit-tool:0.9.0' testImplementation 'junit:junit:4.13.2' } @@ -59,15 +62,7 @@ task copyAssets(type: Copy) { from "../front" into "./build/output/assets/" } -task mergeJar(dependsOn: ["sourcesJar", "jar"]) { - doLast { - org.bdware.datanet.YPKPacker.mergeJar("./backend/build/libs/$project.name-${project.version}.jar", - "./backend/build/libs/$project.name-${project.version}-sources.jar", - "./backend/build/libs/$project.name-${project.version}-all.jar") - } -} - -task copyJar(type: Copy, dependsOn: ["mergeJar", ":backend:copyLibs"]) { +task copyJar(type: Copy, dependsOn: [":backend:jar", ":backend:copyLibs"]) { from "./build/libs/$project.name-${project.version}-all.jar" into "./build/output" rename { String fileName -> "sc-example.jar" } @@ -79,12 +74,12 @@ task copyJar(type: Copy, dependsOn: ["mergeJar", ":backend:copyLibs"]) { task buildZip(type: Zip, dependsOn: ["copyAssets", "copyJar", "copyYJS"]) { from './build/output/' duplicatesStrategy = DuplicatesStrategy.INCLUDE - archiveFileName = 'contractexample.zip' + archiveFileName = 'ControlProxy.zip' destinationDirectory = file('build/') } task buildYPK(dependsOn: ["buildZip"]) { doLast { - org.bdware.datanet.YPKPacker.staticPack("./backend/build/contractexample.zip", "./backend/build/contractexample.ypk") + org.bdware.datanet.YPKPacker.staticPack("./backend/build/ControlProxy.zip", "./backend/build/ControlProxy-${project.version}.ypk") } } diff --git a/backend/src/main/java/org/bdware/sc/contractexample/Hello.java b/backend/src/main/java/org/bdware/sc/contractexample/Hello.java deleted file mode 100644 index eca9a29..0000000 --- a/backend/src/main/java/org/bdware/sc/contractexample/Hello.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.bdware.sc.contractexample; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.bdware.sc.ContractProcess; -import org.bdware.sc.boundry.JavaScriptEntry; - -public class Hello { - private static final Logger LOGGER = LogManager.getLogger(Hello.class); - - public static void main(String[] args) { - LOGGER.info("abc"); - } - - public static String call() { - return "hello..dafdskf"; - } - - public static String callYJSInSameCP() { - return ContractProcess.instance.executeContract("{\"action\":\"getOwner\"\",\"arg\":\"\"}"); - } - - public static Object callYJSInOtherCP() { - return JavaScriptEntry.executeContract("cid", "action", "arg"); - } -} \ No newline at end of file diff --git a/backend/src/main/java/org/bdware/sc/controlproxy/Hello/Hello.java b/backend/src/main/java/org/bdware/sc/controlproxy/Hello/Hello.java new file mode 100644 index 0000000..006cb9b --- /dev/null +++ b/backend/src/main/java/org/bdware/sc/controlproxy/Hello/Hello.java @@ -0,0 +1,74 @@ +package org.bdware.sc.controlproxy.Hello; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.bdware.doip.audit.EndpointConfig; +import org.bdware.doip.audit.client.AuditDoipClient; +import org.bdware.doip.audit.client.AuditIrpClient; +import org.bdware.doip.audit.config.TempConfigStorage; +import org.bdware.doip.audit.writer.AuditConfig; +import org.bdware.doip.audit.writer.AuditType; +import org.bdware.doip.auditrepo.AutoAuditDO; +import org.bdware.doip.codec.doipMessage.DoipMessage; +import org.bdware.doip.endpoint.client.ClientConfig; +import org.bdware.irp.exception.IrpClientException; +import org.bdware.irp.stateinfo.StateInfoBase; +import org.bdware.sc.engine.JSONTool; + + +public class Hello { + private static final Logger LOGGER = LogManager.getLogger(Hello.class); + + public static void main(String[] args) { + LOGGER.info("abc"); + } + + static EndpointConfig endpointConfig; + + public static void init(Object obj) { + String defaultConfg= "{\"routerURI\":\"127.0.0.1:2041\"}"; + if (obj==null){ + return; + } + + if (obj instanceof String) { + if (!((String) obj).startsWith("{")){ + + } + TempConfigStorage storage = new TempConfigStorage((String) obj); + endpointConfig = storage.loadAsEndpointConfig(); + } else { + JsonElement je = JSONTool.convertMirrorToJson(obj); + TempConfigStorage storage = new TempConfigStorage(je.toString()); + endpointConfig = storage.loadAsEndpointConfig(); + } + } + + public static String getConfig() { + return new Gson().toJson(endpointConfig); + } + + public static String call() { + return "hello..dafdskf"; + } + + public static String getAuditType(String doid) { + AuditIrpClient irpClient = new AuditIrpClient(endpointConfig); + AuditConfig auditConfig = irpClient.getAuditConfig(); + AuditDoipClient client = new AuditDoipClient(auditConfig); + ClientConfig config = null; + try { + StateInfoBase result = irpClient.resolve(doid); + config = new ClientConfig(result.getValues("address")); + } catch (IrpClientException e) { + e.printStackTrace(); + } + client.connect(config); + DoipMessage msg = client.sendMessageSync(AutoAuditDO.getRepoAuditType(doid)); + AuditType type = AutoAuditDO.getAuditTypeFromRespMessage(msg); + LOGGER.info(type); + return type.toString(); + } +} \ No newline at end of file diff --git a/backend/yjs/ControlProxy.yjs b/backend/yjs/ControlProxy.yjs new file mode 100755 index 0000000..45afca3 --- /dev/null +++ b/backend/yjs/ControlProxy.yjs @@ -0,0 +1,140 @@ +import "repodetail.yjs" +import "search.yjs" +import "audit.yjs" +import "networking.yjs" +import "DAC.yjs" +//网关为Gateway +//路由器改名为Resolver,中文名为标识解析系统 +//搜索引擎改名为为Registry,中文名为注册表系统 +//本文接口由李智负责对接。 +contract ControlProxy{ + + function convertArgToJson(arg){ + if (typeof(arg)=='string' && !arg.startsWith("{")) return arg; + if (typeof(arg)=='string') return JSON.parse(arg); + return arg; + } + + export 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.controlyproxy.Hello.init(arg); + + } + + function isString(arg){ + return typeof(arg)=='string'; + } + + export function isOwner(){ + return checkPermission(requester); + } + @Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}") + 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}; + } + //网关需新增的接口 + @Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}") + export function pingRepo(arg){ + arg = convertArgToJson(arg); + if (arg.doId ==undefined ){ + return { + "msg":"missing arguments repoId ","code":1}; + } + 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}; + } + + //网关的接口 + export function getCCCCCCCCCCCCConfInfo(){ + + return Global; + } + @Descripton("无参数") + export function getRepoList(arg){ + //use configed arg.routerId; + //TODO!! + ret = executeContract(Global.router,"listRepo",""); + //ret=executeContract("Gateway","listLocalRepo",""); + //var list = ret.result + return ret.result; + } + //网关的接口 + @Descripton("参数为 {\"doId\":\"bdware.ss/Repox\"}") + 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}; + } + //网关的接口 需新增 + @Descripton("参数为 [{\"doId\":\"bdware.ss/Repox\"},{\"doId\":\"bdware.ss/Repoy\"}]") + export function deleteRepoList(arg){ + arg = convertArgToJson(arg); + var ret = []; + for (var i=0;i **基本要求:** +> +> 1.返回结果的result 不应该是jsonstr格式,当它可以是json对象时,需要以json对象返回。 +> 2.异常处理,约定异常格式。提供工具类返回异常格式的消息。 +> +> 3.输入参数都以json格式,如参数为doId: +> +> ```json +> { +> "doId":"xx.yy/zz" +> } +> ``` +> +> 4.正常返回:(只返回状态的接口) +> +> ```json +> { +> "msg":"success", +> "code":0, +> } +> ``` +> +> 5.正常返回:(返回一共数组) +> +> ```json +> { +> "msg":"success", +> "code":0, +> "data":{}//要返回的数据 +> } +> ``` +> +> 6.异常返回: +> +> ```json +> { +> "msg":"missing argument", +> "code":1 +> } +> +> { +> "msg":"request to much", +> "code":2 +> } +> ... +> ``` +> +> 7.若返回一个列表的部分的接口,需要给定总数字段:(这样的接口参数需要提供count和offset) +> +> ```json +> //搜索接口返回 +> //这个例子表示符合条件的一共有9999条数据,只返回count和offset限定的3条数据 +> { +> "data":[ +> {}, +> {}, +> {} +> ], +> "total":9999 +> } +> ``` +> +> +> +> ## Repo元数据 +> +> | 字段 | 值 | 说明 | 示例 | +> | ----------- | ------ | --------------------------- | ---------------------------- | +> | doId | string | Repo的Id | "bdware.txte/Repo" | +> | name | string | Repo名称 | "xx数字对象仓库" | +> | owner | string | 所有者 | "xx局" | +> | contractID | string | 合约名称或者合约ID | "DBRepo" | +> | type | string | Repo类型(待扩展) | "Table"/"Http" | +> | description | string | 说明 | "这是一段关于该repo的说明" | +> | enableIndex | bool | 是否索引 | true | +> | createTime | long | 创建时间 | 1641364002477 | +> | status | string | 状态(在线/离线) | "online"或者"offline" | +> | check | string | 审核情况(提交/通过/不通过) | "submit"或"success"或"faild" | +> | operator | string | 操作员 | "张三" | +> | manager | array | 管理员 | ["xx局","yy局","zz部门"] | +> +> ### DO元数据 +> +> | 字段 | 值 | 说明 | 示例 | +> | ----------- | ------ | ------------------ | -------------------------------------- | +> | doId | string | do的Id | "bdware.txte/Repo/do.dbname.tablename" | +> | name | string | do的名称 | "xx表格" | +> | type | string | Repo类型(待扩展) | "SQL"或者"CSV" | +> | description | string | 说明 | "这是一段关于该DO的说明" | +> | schema | string | 数据格式描述(DOd?) | "" | +> | createTime | long | 创建时间 | 1641364002477 | +> +> ### Repo元数据示例 +> +> ```json +> { +> "doId":"bdware.txte/Repo", +> "name":"xx部门数据仓库", +> "type":"?", +> "description":"这是一个repo", +> +> "owner":"xx省yy市zz部门", +> "contractID":"DBRepo", +> "enableIndex":true, +> "createTime":1641364002477, +> "status":"online", +> "check":"submit", +> "operator":"张三", +> "manager":["xx局","yy局","zz部门"] +> } +> ``` +> +> +> +> ## 示例说明:getDoCount +> +> - 说明:调用搜索引擎的统计接口,返回对应repo的doId当中含有输入参数的repo的do数量 +> +> - 参数:一个字符串,用于doId的模糊匹配 +> +> ```json +> { +> "key":"bdware.txte/Repo" +> } +> ``` +> +> - 正常返回:result的值是json对象而不是字符串 +> +> ```json +> //空: +> { +> "data":[] +> } +> //非空: +> { +> "data":[ +> {"doId":"bdware.txte/Repo1","count":10}, +> {"doId":"bdware.txte/Repo2","count":12} +> ], +> "total":9999 +> } +> //调用返回的全部内容,是正常还是异常看status字段 +> {"needSeq":false,"seq":0,"status":"Success","result":{"data":[{"doId":"bdware.txte/Repo1","count":10},{"doId":"bdware.txte/Repo2","count":12}]},"isInsnLimit":false,"totalGas":0,"executionGas":0,"extraGas":0,"size":0,"eventRelated":false,"responseID":"1645085355104_1279","action":"onExecuteResult","executeTime":"9"} +> +> ``` +> +> - 异常返回:抛出异常,result的内容是个字符串表示异常内容或者异常的信息 +> +> ```json +> //异常返回方式 +> YancloudUtil.exceptionReturn({"msg":"missing arguments repoId ","code":1}); +> +> //结果 +> {"needSeq":false,"seq":0,"status":"Exception","result":{"msg":"xxx","code":1},"isInsnLimit":false,"totalGas":0,"executionGas":0,"extraGas":0,"size":0,"eventRelated":false,"responseID":"1645085126815_8926","action":"onExecuteResult","executeTime":"17"} +> ``` +> + +## 一、ControlProxy.yjs @李智 + +### 1.addRepo + +- 说明:调用Gateway的addLocalRepo,由GateWay检查参数等,正确返回代码为0,错误返回提供具体错误代码及原因 + +- 参数 + + ```json + { + "doId":"bdware.txte/Repo", + "name":"xx部门数据仓库", + "type":"?", + "description":"这是一个repo", + + "owner":"xx省yy市zz部门", + "contractID":"DBRepo", + "enableIndex":true, + "createTime":1641364002477, + "status":"online", + "check":"submit", + "operator":"张三", + "manager":["xx局","yy局","zz部门"] + } + ``` + + + +- 正常返回 + + ```json + { + "msg":"success", + "rrt":"110ms", + "code":0 + } + ``` + +- 异常返回:msg:错误信息,code:错误代码 + + ```json + { + "msg":"missing arguments repoId ", + "code":1 + } + ``` + + + +### 2.pingRepo + +- 说明 + +- 参数 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + +- 正常返回 + + ```json + { + "msg":"success", + "rrt":"110ms", + "code":0, + "repoInfo": + { + "doId":"bdware.txte/Repo", + "name":"xx部门数据仓库", + "type":"?", + "description":"这是一个repo", + + "owner":"xx省yy市zz部门", + "contractID":"DBRepo", + "enableIndex":true, + "createTime":1641364002477, + "status":"online", + "check":"submit", + "operator":"张三", + "manager":["xx局","yy局","zz部门"] + }//repo元数据 + } + ``` + +- 异常返回 + + ```json + { + "msg":"repo is unconnected", + "code":1 + } + ``` + + +### 3.getRepoList + +- 说明 + +- 参数:无 + +- 正常返回 + + ```json + { + "data":[ + {},//repo元数据 + {},//repo元数据 + {}//repo元数据 + ], + "total":9999 + } + ``` + +- 异常返回 + + + + ```json + { + "msg":"repo is unconnected", + "code":1 + } + ``` + + + +### 4.deleteRepo + +- 说明 + +- 参数 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + +- 正常返回 + + ```json + { + "msg":"success", + "code":0 + } + ``` + +- 异常返回:msg:错误信息,code:错误代码 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + +### 5.deleteRepoList(4和5是同一个) + +- 说明 + +- 参数 + + ```json + [ + {"doId":"bdware.ss/Repox"}, + {"doId":"bdware.ss/Repoy"} + ] + ``` + +- 正常返回 + + ```json + { + [{ + "msg":"success", + "code":0 + }, + { + "msg":"success", + "code":0 + }, + { + "msg":"success", + "code":0 + }] + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + +### 6.updateRepo + +- 说明 + +- 参数:全部元数据 + + ```json + { + "doId":"bdware.txte/Repo", + "name":"xx部门数据仓库", + "type":"?", + "description":"这是一个repo", + + "owner":"xx省yy市zz部门", + "contractID":"DBRepo", + "enableIndex":true, + "createTime":1641364002477, + "status":"online", + "check":"submit", + "operator":"张三", + "manager":["xx局","yy局","zz部门"] + } + ``` + + - 正常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + +## 二、networking.yjs @范博 + +### 1.getRouterInfo + +- 说明 + +- 参数:无 + +- 正常返回 + + ```json + { + "date": 1642467459759, + "name": "next路由器", + "doId": "bdwaretest.loccall.next1", + "version": "2.1", + "address": "127.0.0.1:2222", + "status": "已审核", + "protocol": "IRP", + "pubKey":"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd" + } + ``` + +- 异常返回 + + ```json { + { + "msg":"can not found repo", + "code":1 + } + ``` + + + +### 2.listLRS + +- 说明 + +- 参数:无 + +- 说明:该接口暂时不会有太多数据,因此没有提供total字段和count,offset方式 + +- 正常返回 + + ```json + { + //"result":"success", + "data":[ + { + "protocol":"DO-IRP协议","name":"ee","pubKey":"046c31d1e4f0056325c352a6c9934c1d15a51ef4b5bc552387a1c43188b2317a1863a9072cf612c2c15e5353083cf47e2024b49e416e8f6f8d4b0db496b67336f5","version":"2.0","address":"1.1.1.1:333","doId":"bdtest5.r1.121111111444","date":1643340044943 + }, + {"protocol":"DO-IRP协议","name":"aaa","pubKey":"04bb83950bf8f0b02cc9c95eb25a30950958e2c271c423c28a3612f5bc199a94c55c637d15876e442c265e1b3f970fb167ba59a489157f279955d69a12359501df","version":"2.0","address":"1.1.1.1:44","doId":"bdtest5.r1.ss","date":1645510310038},{"protocol":"DO-IRP协议","name":"test2","pubKey":"04bb83950bf8f0b02cc9c95eb25a30950958e2c271c423c28a3612f5bc199a94c55c637d15876e442c265e1b3f970fb167ba59a489157f279955d69a12359501df","version":"2.0","address":"1.1.1.1:44","doId":"bdtest5.r1.test2","date":1645510310038}, + {"protocol":"DO-IRP协议","name":"test","pubKey":"04982fc8507302c57a0389de1f6fc8a72c70577dff15fb0f23d3898742ac7684ace75c3b12dec94b8866ffcea9ef4795c09074327e4f1822b546cc6f783931da94","version":"2.0","address":"1.1.1.1:55","doId":"bdtest5.r1.tttTest","date":1643338165008 + } + ], + "count":4 + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + +### 3.updateLRS + +- 说明 + +- 参数 + + ```json + { + "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" + } + ``` + +- 正常返回:新的doid + + ```json + { + "data":"xxx.xx/aa"; + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + +### 4.createLRS(除了oldname和olddoid,其他和undate一样) + +- 说明 + +- 参数 + + ```json + { + "date": 1642467459759, + "name": "next路由器", + "doId": "bdwaretest.loccall.next1", + "version": "2.1", + "address": "127.0.0.1:2222", + "status": "已审核", + "protocol": "IRP", + "pubKey":"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd" + } + ``` + +- 正常返回 + + ```json + { + "data":"bdware.ss/Repox" + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + +### 5.deleteLRS + +- 说明 + +- 参数 + + ```json + { + "name": "Repo1", + "doId": "bdwaretest.loccall/Repo1", + "pubKey":"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd" + } + ``` + +- 正常返回 + + ```json + { + "data":"bdware.ss/Repox" + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + +### 6.listRepo(同listLRS) + +- 说明 + +- 参数 + + ```json + { + "doId":"...", + "address":"...", + "owner":"...", + "...":"..." + } + ``` + +- 正常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + +- 异常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + + + +### 7.updateRepo(同updateLRS) + +- 说明 + +- 参数 + + ```json + { + "doId":"...", + "address":"...", + "owner":"...", + "...":"..." + } + ``` + +- 正常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + +- 异常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + + + +### 8.createRepo(同createLRS) + +- 说明 + +- 参数 + + ```json + { + "date": 1642467459759, + "name": "Repo1", + "doId": "bdwaretest.loccall/Repo1", + "version": "2.1", + "address": "tcp://127.0.0.1:21042", + "status": "已审核", + "protocol": "DOIP", + "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd" + } + ``` + +- 正常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + +- 异常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + + + +### 9.deleteRepo(同deleteLRS) + +- 说明 + +- 参数 + + ```json + { + "name": "next路由器", + "doId": "bdwaretest.loccall.next1", + "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd" + } + ``` + +- 正常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + +- 异常返回 + + ```json + { + "doId":"bdware.ss/Repox" + } + ``` + + + +### 10.setRootRouterInfo(和Create一样) + +- 说明 + +- 参数 + + ```json + { + "date": 1642467459759, + "name": "Repo1", + "doId": "bdwaretest.loccall/Repo1", + "version": "2.1", + "address": "tcp://127.0.0.1:21042", + "status": "已审核", + "protocol": "DOIP", + "pubKey": "04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd" + } + ``` + +- 正常返回 + + ```json + { + "data":"bdware.ss/Repox" + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + +### 11.reInit + +- 说明 + +- 参数:无 + +- 正常返回 + + ```json + { + "data":"verify and start server success" + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + + + +## 三、repodetail.yjs + +### 1.getDoList @张宏伟 + +- 说明:如果指定repo,那么就是指定repo的dolist,否则是全部的 + +- 参数 + + ```json + {"doId":"xxx"} + //或者 + {} + ``` + +- 正常返回 + + ```json + { + "data":[{},{},{}], + "total":9999 + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + +### 2.getRepoTopology + +- 说明 + +- 参数 + + ```json + { + "doId":"..." + } + ``` + +- 正常返回 + + ```json + { + "data":[ + {"name":"小店区仓库","doId":"bdware.ss.ab/Repo1","previousNode":["bdware.ss/Gateway1","bdware.ss/Gateway2"]}, + {"name":"小店区仓库","doId":"bdware.ss.ab/Repo1","previousNode":["bdware.ss/Gateway1","bdware.ss/Gateway2"]}, + {"name":"小店区仓库","doId":"bdware.ss.ab/Repo1","previousNode":["bdware.ss/Gateway1","bdware.ss/Gateway2"]}, + {"name":"小店区仓库","doId":"bdware.ss.ab/Repo1","previousNode":["bdware.ss/Gateway1","bdware.ss/Gateway2"]} + ], + "total":9999 + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + + + +### 3.getStaticIndex(先不管) + +- 说明 + +- + + + + +### 4.fakeList(略 + +- 说明 + +- + + + + +## 四、search.yjs + +### 1.getDoCount @张宏伟 + +- 说明:调用搜索引擎的统计接口,返回对应repo的doId当中含有输入参数的repo的do数量 + +- 参数:一个字符串,用于doId的模糊匹配 + + ```json + bdware.txte/Repo + ``` + +- 正常返回:result的值是json对象而不是字符串 + + ```json + //空: + { + "data":[], + "total":0 + } + //非空: + { + "data":[ + {"doId":"bdware.txte/Repo1","count":10}, + {"doId":"bdware.txte/Repo2","count":12} + ], + "total":2 + } + //调用返回的全部内容,是正常还是异常看status字段 + {"needSeq":false,"seq":0,"status":"Success","result":{"data":[{"doId":"bdware.txte/Repo1","count":10},{"doId":"bdware.txte/Repo2","count":12}]},"isInsnLimit":false,"totalGas":0,"executionGas":0,"extraGas":0,"size":0,"eventRelated":false,"responseID":"1645085355104_1279","action":"onExecuteResult","executeTime":"9"} + ``` + +- 异常返回:抛出异常,result的内容是个字符串表示异常内容 + + ```json + {"needSeq":false,"seq":0,"status":"Exception","result":{"msg":"xxx","code":1},"isInsnLimit":false,"totalGas":0,"executionGas":0,"extraGas":0,"size":0,"eventRelated":false,"responseID":"1645085126815_8926","action":"onExecuteResult","executeTime":"17"} + ``` + + + +### 2.countRecordByDate @董瑞 + +- 说明: + + > //=====全域监管:数字对象溯源 针对单个DO的,通过SQL查询来实现。 + > //根据 doId --> 找到“数字对象世系” + > //86.500.1/Repo.1/Doab + > //根据 doId+时间范围+interval+protocol --> 不同operation的统计数据 (AuditProxy) + > //countDORecordByDate() + > //{"doId":xxxx,"startTime","endTime","interval","eventPrefix":["doip_create","doip_update"]} + > //{"eventxxx":[1,2,3],"event2":[1,2,3]} + > + > //根据 doId +查找条件(时间范围 protocol operation user?) +offset/count -->总数+指定条数的数组(AuditProxy) + > // queryDoRecordByDate + > //{"doId":xxxx,"startTime","endTime","eventPrefix":["doip_create","doip_update"]} + > //{"count":xx, "data":[{doip_request的某一行。},]} + > // queryDoRecordByOffset + > //{"doId":xxxx,"offset","count","eventPrefix":["doip_create","doip_update"]} + > //{"total":xx,"count":xx, "data":[{doip_request的某一行。},]} + > //============== + +- 参数:下面的内容表示owner字段当中包含"xxx"且doid当中包含"aibd"的结果 + + ```json + { + "startTime":1641454745128, + "endTime":1641494745128, + "interval":5000, + "eventPrefix":["abc"] + } + ``` + +- 正常返回:repo元数据的数组,每一个{}表示一个元数据 + + ```json + { + "doip_search":[1,2,3,4], + "doip_create":[5,6,7,8] + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + + + + + +### 3.getDoFilter @张宏伟 + +- 说明:按照某一字段值的范围查询 + +- 参数:下面是按照字段createTime的时间来查询,count和offset可缺省 + + ```json + { + "type":"creatTime", + "count":10, + "offset":0, + "from":"1141363811328", + "to":"1941363811328" + } + ``` + + + +- 正常返回:repo元数据的数组,每一个{}表示一个元数据 + + ```json + { + "data":[ + {},{},{} + ], + "total":3 + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + +### 4.search + +- 说明:支持多个字段的搜索 + +- 参数:下面的内容表示owner字段当中包含"xxx"且doid当中包含"aibd"的结果 + + ```json + { + "params":[ + {"type":"owner","keyword":"xxx"}, + {"type":"doid","keyword":"aibd"} + ], + "count":10, + "offset":0 + } + ``` + +- 正常返回:repo元数据的数组,每一个{}表示一个元数据 + + ```json + { + "data":[ + {},{},{} + ], + "total":3 + } + ``` + +- 异常返回 + + ```json + { + "msg":"can not found repo", + "code":1 + } + ``` + + + + + diff --git a/backend/yjs/DAC.yjs b/backend/yjs/DAC.yjs new file mode 100755 index 0000000..de2a839 --- /dev/null +++ b/backend/yjs/DAC.yjs @@ -0,0 +1,49 @@ +module NaiveDAC{ + function initDAC(req){ + // Global.acceptList = { + // }; + // Global.applyList = { + // }; + Global.owner = req; + } + function checkPermission(req){ + return (req==Global.owner); + } + // export function hasPermission(arg){ + // return (Global.acceptList[requester]!=undefined); + // } + // export function accept(req){ + // if (requester==Global.owner){ + // Global.acceptList[req] = Global.applyList[req]; + // if (Global.applyList[req] != undefined) + // Global.applyList[req] = undefined; + // return true; + // } + // return false; + // } + // export function cancel(req){ + // if (requester==Global.owner){ + // Global.applyList[req] = Global.acceptList[req]; + // if (Global.acceptList[req] != undefined) + // Global.acceptList[req] = undefined; + // return true; + // } + // return false; + // } + // export function apply(remark){ + // if (remark != undefined && requester !=undefined){ + // Global.applyList[requester] = remark; + // return "success"; + // } + // return "failed" + // } + // export function isOwner(arg){ + // return Global.owner==requester; + // } + // export function getApplyList(arg){ + // return JSON.stringify(Global.applyList); + // } + // export function getAcceptList(arg){ + // return JSON.stringify(Global.acceptList); + // } +} diff --git a/backend/yjs/README.md b/backend/yjs/README.md new file mode 100755 index 0000000..4e63038 --- /dev/null +++ b/backend/yjs/README.md @@ -0,0 +1,86 @@ +# 函数名addRepo +## 参数 +可接收JSON或是JSON字符串,格式如下: +``` +{"doId":"bdware.ss/Repox"} +``` +## 返回结果 +code为0表示成功,为1表示失败。msg为失败原因。 +``` +{"msg":"success","rrt":"110ms","code":0} +``` + +# 函数名pingRepo +## 参数 +可接收JSON或是JSON字符串,格式如下: +``` +{"doId":"bdware.ss/Repox"} +``` +## 返回结果 +code为0表示成功,为1表示失败。msg为失败原因。 +成功的时候会返回rrt,表示ping所花的时间。 +``` +{"msg":"success","rrt":"110ms","code":0} +``` +# 函数名getRepoList +## 参数 +``` +无参数 +``` +## 返回结果 +``` +[ + { + "doId":"bdware.ss/Repo13", + "address":"tcp://127.0.0.1:20513", + "owner":"user13", + "version":"2.1", + "descritpion":"这是bdware.ss的第13号数字对象仓库", + "createDate":"2022-01-03" + }, + { + "doId":"bdware.ss/Repo14", + "address":"tcp://127.0.0.1:20514", + "owner":"user14", + "version":"2.1", + "descritpion":"这是bdware.ss的第14号数字对象仓库", + "createDate":"2022-01-03" + }] + +``` + +# 函数名deleteRepo +## 参数 +``` +{"doId":"bdware.ss/Repox"} +``` +## 返回结果 +``` +{"msg":"success","code":0} +``` + +# 函数名deleteRepoList +## 参数 +``` +[{"doId":"bdware.ss/Repox"},{"doId":"bdware.ss/Repoy"}] +``` +## 返回结果 +``` +{"msg":"success","code":0} +``` + +# 函数名updateRepo +## 参数 +``` + { + "doId":"bdware.ss/Repo14", + "address":"tcp://127.0.0.1:20514", + "owner":"user14", + "version":"2.1", + "descritpion":"这是bdware.ss的第14号数字对象仓库", + } +``` +## 返回结果 +``` +{"msg":"success","code":0} +``` diff --git a/backend/yjs/assets/logo.png b/backend/yjs/assets/logo.png new file mode 100755 index 0000000000000000000000000000000000000000..24905d5c47123df94e3825ecf48b8f76fd6c6bc5 GIT binary patch literal 352 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1SE5RJ;-NZU{v>XaSW-r_4bZ6-ys7YhJbhV zoMuNpS}<9AtjPM?d3dvxnb((TH~ePb_Wsi&&E(+daQ^q>$3N?SpRj)JrfY4j;LyOp zD8*Is#B%$Q;_h>^Wd%SYZ`ng4h4rAax7alD5BGT)EplUIV&M>25a}@W?B!EW9z3dI z00~?;=CJpqW87jfsLmN{ z@jIEo2C^);S~sn`i_yFg!cWa(ewVwmZ_P7CkO2Xn?jQM?1r}s~WV1=;W72&8buBRD O7(8A5T-G@yGywnuV|>a0 literal 0 HcmV?d00001 diff --git a/backend/yjs/audit.yjs b/backend/yjs/audit.yjs new file mode 100755 index 0000000..d26e01d --- /dev/null +++ b/backend/yjs/audit.yjs @@ -0,0 +1,13 @@ +module Audit{ + export function getDoipAction(){ + return [ + { value: 2048, name: 'Search Engine' }, + { value: 735, name: 'Direct' }, + { value: 380, name: 'Email' }, + { value: 484, name: 'Union Ads' }, + { value: 100, name: 'Video Ads' }, + ] + } + + +} \ No newline at end of file diff --git a/backend/yjs/manifest.json b/backend/yjs/manifest.json old mode 100644 new mode 100755 index b42373a..9864a82 --- a/backend/yjs/manifest.json +++ b/backend/yjs/manifest.json @@ -1,9 +1,9 @@ { - "main": "main.yjs", - "memory": "kill,init", - "doi": "Contract_1172400934", + "main": "ControlProxy.yjs", + "doi": "Contract_245931211", "insnLimit": 0, - "buildTime": 1635385270646, - "builder": "ContractEngine", - "startAtUnpack": true + "buildTime": 1650245588814, + "builder": "04da01345770b7e09d4774bf6c0395399b18814aa0b7b158f64b634b8f3d628d9964af6523835225af11e467271f4969d67bf90b32eaa09f517c79b2d1f9b8a926", + "startAtUnpack": true, + "sourcePath": "04da01345770b7e09d4774bf6c0395399b18814aa0b7b158f64b634b8f3d628d9964af6523835225af11e467271f4969d67bf90b32eaa09f517c79b2d1f9b8a926/ControlProxy" } \ No newline at end of file diff --git a/backend/yjs/networking.yjs b/backend/yjs/networking.yjs new file mode 100755 index 0000000..03ba352 --- /dev/null +++ b/backend/yjs/networking.yjs @@ -0,0 +1,307 @@ +//@范博 +//以下接口都要给出示例参数 +//类似于 @Descripton("参数为,{\"doId\":\"bdware.ss/Repox\"}") +module networking{ + //前缀管理用到的接口 listLRS updateLRS createLRS deleteLRS + export function getRouterInfo(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"getRouterInfo",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 listLRS(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"listLRS",""); + 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; + } + + @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){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"updateLRS",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; + } + + @Descripton("参数为,{\"date\": 1642467459759,\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"version\": \"2.1\",\"address\": \"127.0.0.1:2222\",\"status\": \"已审核\",\"protocol\": \"IRP\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}") + @ArgSchema({"!date": "number","!name": "string","!doId": "string","!version":"string","!address": "string","status": "string","!protocol": "string","!pubKey": "string"}) + 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; + } + + @Descripton("参数为,{\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}") + @ArgSchema({"!name": "string","!doId": "string","!pubKey": "string"}) + export function deleteLRS(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"deleteLRS",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 listReposi(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"listRepo",""); + 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; + } + + @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"}) + export function updateReposi(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"updateRepo",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; + } + + @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"}) + export function createReposi(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"createRepo",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; + } + + @Descripton("参数为,{\"name\": \"next路由器\",\"doId\": \"bdwaretest.loccall.next1\",\"pubKey\": \"04d1924329f72ced148f6f333fb985ccbaa31b1e3aacf10be5f43d4a4ff5ad88899a005e79e37fc06993e1d66ada8cf8b711cb36f59538bb7d3e39e70fa9360ddd\"}") + @ArgSchema({"!name": "string","!doId": "string","!pubKey": "string"}) + export function deleteReposi(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"deleteRepo",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; + } + + @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"}) + export function setRootRouterInfo(arg) { + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + //if (Global.router == "Router") { + // return "failed"; + //} + var ret=executeContract(Global.router,"setRootRouterInfo",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; + //return "success"; + } + + export function reInit(arg) { + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + if (Global.router == "GlobalRouter") { + return "failed"; + } + var ret=executeContract(Global.router,"reInit",""); + var obj = ret.result; + if (obj.result=="verify and start server success" || obj.result == undefined) { + obj.code=0; + } else { + YancloudUtil.exceptionReturn({"msg":obj.result,"code":1}); + } + return obj; + } + @ArgSchema({"!pubKey": "string"}) + export function setPubKey(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"setPubKey",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; + } + @ArgSchema({"!upperIP": "string"}) + export function setUpperIP(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"setUpperIP",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; + } + @ArgSchema({"!upperPort": "string"}) + export function setUpperPort(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"setUpperPort",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 getUpperIP(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"getUpperIP",""); + 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 getUpperPort(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"getUpperPort",""); + return ret.result; + } + @ArgSchema({"!signature": "string"}) + export function setSignature(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + var ret=executeContract(Global.router,"setSignature",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; + } + @ArgSchema({"!name": "string"}) + export function setName(arg){ + if (!checkPermission(requester)) { + YancloudUtil.exceptionReturn({"msg":"no permission","code":1}); + } + + var ret=executeContract(Global.router,"setName",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; + } + @ArgSchema({"!doId": "string","!address":"string"}) + export function resolveDoId(arg){ + var ret=executeContract(Global.router,"resolveDoId",arg); + var obj = ret.result; + var obj1 = obj.data; + var obj2 = JSON.parse(obj1); + if (obj.result=="success" || obj.result == undefined) { + if (obj2.name != "NotFound") { + obj.result=undefined; + obj.code=0; + } else { + YancloudUtil.exceptionReturn({"msg":obj.data,"code":1}); + } + } else { + YancloudUtil.exceptionReturn({"msg":obj.data,"code":1}); + } + return obj; + } + +} diff --git a/backend/yjs/repodetail.yjs b/backend/yjs/repodetail.yjs new file mode 100755 index 0000000..8b8b54a --- /dev/null +++ b/backend/yjs/repodetail.yjs @@ -0,0 +1,135 @@ +module RepoDetail{ + + + export function getControlProxyConfig(){ + return org.bdware.sc.controlyproxy.Hello.getConfig(); + + } + //@wyq 通过DOIP请求 + export function getAuditRule(arg){ + // {"repoId":"xxx"} + var ret = []; + ret.push({"displayName":"原始数据存证","desc":"原始数据存证到指定数据库,哈希数据存证","type":2}); + ret.push({"displayName":"哈希数据存证","desc":"仅哈希数据存证","type":1}); + ret.push({"displayName":"不存证","desc":"不存证","type":0 }); + return ret; + } + //@wyq TODO TODO + // 这个通过DOIPUtil,去调用 + // DOIP的接口。 + export function getDoAuditRule(arg){ + //repo的doId + //arg={"doId":"xxx","offset":xx,"count":xx} + arg = convertArgToJson(arg); + if(arg.count==undefined) arg.count=10; + if(arg.offset==undefined) arg.offset=0; + + var ret = {"data":[{"doId":"abc.124/Repo","auditRule":{"type":0}}, + {"doId":"abc.125/Repo","auditRule":{"type":1}}, + {"doId":"abc.128/Repo","auditRule":{"type":1}}], + total:3}; + + return ret; + //abc.124/Repo/67899-6789789dafd-8909 + } + //@wyq + export function setDoAuditRule(arg){ + ///arg={"doIdList":["dd","ddd.xx/xxx",...],"type":1} + arg = convertArgToJson(arg); + if(arg.count==undefined) arg.count=10; + if(arg.offset==undefined) arg.offset=0; + return {"msg":"success","code":0}; + } + //宏伟 + //如果有指定repo,那就是指定repo的DOlist。 + //如果没指定repo,那就是全部的。 + //这是search engine的接口,为什么还没接上?? + //TODO TODO + export function getDoList(arg){ + arg = convertArgToJson(arg); + //if (arg.doId == null) + // return { + // "msg":"missing arguments doId", "code":1, params: arg + // }; + //if (arg.count>1000) + // return { + // "msg":"request to much!", "code":1 + // }; + var ret = []; + if(arg.count==undefined) arg.count=10; + if(arg.offset==undefined) arg.offset=0; + for (var i=arg.offset; i总体情况概览 里面的“仓库数量”,“DO数量” ,“DO分布情况”三项。 + //可以增加一个参数用于过滤返回结果?比如模糊匹配上的就加到返回列表里。 + //str.contains(arg..) + //输入参数,doId,如bdware.txte/Repo + //返回结果:一个数组,里面是doId"contains"这个参数的列表。 + + export function getAllRepoCount() { + return executeContract("SearchEngine","getAllRepoCount",arg).result; + //return Global.allRepoCount; + } + export function getAllUserCount() { + return executeContract("SearchEngine","getAllUserCount",arg).result; + //return Global.allRepoCount; + } + export function getAllSearchCount() { + return executeContract("SearchEngine","getAllSearchCount",arg).result; + //return Global.allRepoCount; + } + export function getAllUpdateCount() { + return executeContract("SearchEngine","getAllUpdateCount",arg).result; + //return Global.allRepoCount; + } + export function getAllDoCount() { + return executeContract("SearchEngine","getAllDoCount",arg).result; + //return Global.allRepoCount; + } + //不确定 + //{"open":51,"close":49} + export function getAllIndexCount() { + return executeContract("SearchEngine","getAllIndexCount",arg).result; + //return Global.allRepoCount; + } + export function getDoCount(arg){ + return executeContract("SearchEngine","getDoCount",arg); + //return { + //"data":[{ + // "doId":"bdware.txte/Repo1","count":10} + // ,{ + // "doId":"bdware.txte/Repo2","count":12} + // ]}; + } + //通过AuditProxy实现 @董瑞 需实现支持多标签索引的put接口。 + //======在全领监管->总体情况概览 + //使用以下参数获取DO数量变化趋势 + // interval=1周/1月/1年。。 eventPrefix的数组里为"irp_register" + //使用以下参数获取操作数量统计 + // interavl= endTime-startTime, eventPrefix的数组里为"" + // 使用以下参数数字对象操作统计 + //eventPrefix为["doip","irp"] 已完成√ + // 使用以下参数获取doip操作统计 + //exentPrefix为["doip_create","doip_update","doip_delete","doip_retrieve","doip_hello","doip_list_operations","doip_search"] 已完成√ + // 使用以下参数获取irp操作统计 + //exentPrefix为["irp_create","irp_delete","irp_update","irp_batch_create","irp_resolution"] 已完成√ + // 使用以下参数获取doip、irp的成功率 + //exentPrefix为["irp_op_success","irp_op_failed"] + //exentPrefix为["doip_op_success","doip_op_failed"] + //======在全领监管->总体情况概览 + @Description("{\"doId\":\"86.20.100/repo4/bcrs\",\"startTime\":1644390000000, \"endTime\":1644404400000,\"interval\":3600000, \"eventPrefix\":[\"doip_retrieve\", \"doip_update\", \"doip_search\", \"doip_delete\"]}") + export function countRecordByDate(arg){ + arg=convertArgToJson(arg); + return executeContract("AutoAudit","countRecordByDate",arg).result; + } + + export function testCount(arg){ + return {"data":"key"}; + } + + //=====全域监管:数字对象溯源 针对单个DO的,通过SQL查询来实现。 + //根据 doId --> 找到“数字对象世系” + //86.500.1/Repo.1/Doab + //根据 doId+时间范围+interval+protocol --> 不同operation的统计数据 (AuditProxy) + //countDORecordByDate() + //{"doId":xxxx,"startTime","endTime","interval","eventPrefix":["doip_create","doip_update"]} + //{"eventxxx":[1,2,3],"event2":[1,2,3]} + + //根据 doId +查找条件(时间范围 protocol operation user?) +offset/count -->总数+指定条数的数组(AuditProxy) + // queryDoRecordByDate + //{"doId":xxxx,"startTime","endTime","eventPrefix":["doip_create","doip_update"]} + //{"count":xx, "data":[{doip_request的某一行。},]} + // queryDoRecordByOffset + //{"doId":xxxx,"offset","count","eventPrefix":["doip_create","doip_update"]} + //{"total":xx,"count":xx, "data":[{doip_request的某一行。},]} + //============== + + + + //DO的元数据 + //{ + // "date": "...", + // "owner": "...", + // "type": "...", + // "description": "...", + // "schema": "...", + //} + //做成可以根据创建时间范围;标识模糊 + //{"type":"creatTime","count":10,"offset":"0","from":"1141363811328","to":"1941363811328"} + export function getDoFilter(arg){ + var res=executeContract("SearchEngine","searchByRange",arg); + return res.result; + } + //支持模糊查询、按创建时间查询。 + //输入参数: + //type:要查询的字段 + //keyword:要查询的关键字 + //count:(可选项,缺省为20) + //offset:(可选项,缺省为0) + ////{"params":[{"type":"owner","keyword":"说明"},{"type":"doid","keyword":"aibd"}],"count":"10","offset":"0"} + //返回:{"data":[{},{},{}],"count":3} + @ArgSchema({"!params":[{"!type":"string","!keyword":"integer"}],"count":"integer","offset":"integer"}) + export function search(arg){ + arg = convertArgToJson(arg); + var res=executeContract("SearchEngine","searchByMultiTag",arg); + return res.result; + //ret=[]; + + //ret.push({ + // "doId":"bdware.ss/Repo1/Do.a","name":"数字对象a","meta":{},"owner":"zzz","createTime":1641885492715} + // ); + //ret.push({ + // "doId":"bdware.ss/Repo1/Do.b","name":"数字对象b","meta":{},"owner":"zzz","createTime":1641885322715} + // ); + //ret.push({ + // "doId":"bdware.ss/Repo1/Do.c","name":"数字对象c","meta":{},"owner":"zzz","createTime":1641875492715} + // ); + //return {"data":ret,"total":3}; + } + export function queryByHash(arg){ + arg=convertArgToJson(arg); + return executeContract("AutoAudit","queryByHash",arg.hash).result; + } + + export function queryByHashOriginal(arg){ + arg=convertArgToJson(arg); + return executeContract("AutoAudit","queryByHashOriginal",arg.hash).result; + } + +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 66ac7ba..6ef60f7 100644 --- a/build.gradle +++ b/build.gradle @@ -2,8 +2,8 @@ plugins { id 'java' id 'idea' } -def currVersion = "1.0.0" -ext.projectIds = ['group': 'org.bdware.sc.contractexample', 'version': currVersion] +def currVersion = "0.8.2" +ext.projectIds = ['group': 'org.bdware.sc.controlproxy', 'version': currVersion] tasks.withType(JavaCompile) { options.compilerArgs << '-Xlint:none' @@ -12,11 +12,13 @@ tasks.withType(JavaCompile) { repositories { mavenCentral() + } project(':backend') { - group = "org.bdware.sc.example" + group = "org.bdware.sc.controlproxy" version = projectIds.version repositories { maven { url 'https://maven.aliyun.com/repository/public' } + mavenLocal() } } diff --git a/settings.gradle b/settings.gradle index 0f086ab..03b5fb8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -rootProject.name = 'ContractJavaExample' +rootProject.name = 'ControlProxy' include 'backend'