- Start neo4j(need java11+)
cd [neo4j installation directory]\bin
./neo4j.bat console
- Start flask
cd [project directory]
set FLASK_APP=app.py
flask run
cd [porject directory]/client
npm run serve
仿照Neo4j Bloom设计一个能进行可视化展示和查询的界面,同时添加可视化编辑功能。
/graph
HTTP GET
先鉴权,通过后返回所有节点和关系信息,并单独给出节点名和关系名列表
{
"code": 200,
"msg": {
"node_name_list": [node name],
"edge_name_list": [relationship name],
"nodes":[
{
"<id>": node's identity,
"attribute": node's attribute dict,
"label": node label
}
],
"edges":[
{
"<id>": edge's identity,
"attribute": edge's attribute dict,
"source": source node id,
"target": target node id,
"type": edge type
}
]
}
返回信息包含数据库中的节点和关系名,用于可视化检索。
/graph
HTTP POST
对数据库进行查询,返回查询json结果。
{
"Cypher-Statement": Cypher statement,
"Return-Type": Py2Neo object type list in Cypher statement by order
}
Explanation:"Return-Type"字段以列表的形式按顺序列出Cypher查询中RETURN子句的返回值类型
返回值类型对应字段如下
type | keyword |
---|---|
node | N |
relationship | R |
*For example:*有如下Cypher语句:MATCH (n)-[r]-(m) RETURN n,r,m
,
则Return-Type字段为["N", "R", "N]
{
"code": 200,
"msg": {
"edges":[
{
"<id>": edge's identity
"attribute": edge's attribute dict,
"source": source node id,
"target": target node id,
"type": edge type
}
],
"nodes":[
{
"<id>": node's identity,
"attribute": node's attribute dict,
"label": node label
}
]
}
}
/session
HTTP POST/DELETE
用户登录操作,POST用于提交登录信息,DELETE用于登出用户。
{
"username": user name,
"password": password
}
- success
{
"code": 200,
"msg": "Validation Completed"
}
- failure
{
"code": 401,
"msg": "Validation fails"
}
- token invalid
{
"code": 500,
"msg": "token invalid!"
}
```json
{
"code": 501,
"msg": "Insufficient Permissions"
}
## 4.用户注册
### 1) address
/user
### 2) type
HTTP POST
### 3) description
用户注册操作,POST用于提交注册信息
### 4) request body format(post)
```json
{
"username": user name,
"password": password,
"email": e-mail,
"type": User's role in system,
"code": Invitation code for expert role certification
}
Explanation: role type:
- common:Can only browse KG
- specialist: Can also edit KG
- administrator: Can manage KG by log
- success
{
"code": 200,
"msg": "Registration Completed"
}
- failure
{
"code": 401,
"msg": "Duplicate Username"
}
{
"code": 402,
"msg": "Repeat email"
}
{
"code": 403,
"msg": "Incorrect Password Format"
}
{
"code": 404,
"msg" : "Invalid Invitation Code!"
}
/graph/node
HTTP POST/PUT/DELETE
对节点进行增加(POST)、删除(DELETE)以及对节点属性进行修改(PUT) 需要鉴权
- POST
{
"Node-Type": Node type, which will be the label of node,
"Node-Attribute": Dict of node attributes
}
- PUT
{
"Node-Id" : Node ID,
"Node-Attribute": Dict of node attributes
}
- DELETE
{
"Node-Id" : Node ID,
}
Notation: 对节点属性进行修改必须把节点所有的属性(包括已存在的和新增的)传入。
- success
{
"code": 200,
"msg":{
"number": Number of changed nodes
}
}
- failure
{
"code": 411,
"msg": "Can't find node by this ID!"
}
/graph/edge
HTTP POST/PUT/DELETE
对关系进行增加(POST)、删除(DELETE)以及对关系属性进行修改(PUT)。 需要鉴权
- POST
{
"Edge-Type": Node type, which will be the label of node,
"Edge-Attribute": Dict of Relationship attributes,
"Source-Node": ID of source node,
"Target-Node": ID of target node
}
- PUT
{
"Edge-Id" : Relationship ID,
"Edge-Attribute": Dict of relationship attributes
}
- DELETE
{
"Edge-Id" : Relationship ID,
}
Notation: 对关系属性进行修改必须把节点所有的属性(包括已存在的和新增的)传入。
- success
{
"code": 200,
"msg":{
"number": Number of changed relationships
}
}
- failure
{
"code": 410,
"msg": "Can't find relationship by this ID!"
}
字段 | 数据类型 | 描述 |
---|---|---|
uername | TEXT | 用户名 |
password | TEXT | 密码,密文储存 |
TEXT | 用户电子邮件 | |
type | INTEGER | 用户类别 |