Files
X-Agents/teams/web/neo4j-api-requirement.md
2026-03-11 14:26:47 +08:00

111 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Neo4j 接口后端需求
## 需求说明
前端 Neo4j 图谱功能已完成,后端接口需要匹配前端调用。
---
## 1. 新增 `/neo4j/graphs` 接口
### 接口地址
```
POST /neo4j/graphs
```
### 请求参数
```json
{
"uri": "bolt://localhost:7687",
"username": "neo4j",
"password": "password",
"database": "neo4j"
}
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| uri | string | 是 | Neo4j 连接地址,如 bolt://localhost:7687 |
| username | string | 是 | 用户名 |
| password | string | 是 | 密码 |
| database | string | 否 | 数据库名(默认 neo4j |
### 返回参数
```json
{
"success": true,
"graphs": {
"labels": [
{"name": "User", "count": 1523},
{"name": "Order", "count": 856}
],
"relationshipTypes": [
{"name": "KNOWS", "count": 2341},
{"name": "BOUGHT", "count": 5678}
]
}
}
```
---
## 2. 修改路由路径
### 当前状态
- `/database/neo4j/nodes` → 需要改为 → `/neo4j/nodes`
- `/database/neo4j/relationships` → 需要改为 → `/neo4j/relationships`
---
## 总结
后端需要修改以下内容:
1. **新增** `/neo4j/graphs` 接口
2. **修改** `/database/neo4j/nodes``/neo4j/nodes`
3. **修改** `/database/neo4j/relationships``/neo4j/relationships`
---
## 附:前端 API 调用示例
```javascript
// 获取图谱概览
fetch('/neo4j/graphs', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
uri: 'bolt://10.10.10.189:7687',
username: 'neo4j',
password: 'neo4j',
database: 'neo4j'
})
})
// 获取节点详情
fetch('/neo4j/nodes', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
uri: 'bolt://10.10.10.189:7687',
username: 'neo4j',
password: 'neo4j',
label: 'User',
limit: 10
})
})
// 获取关系详情
fetch('/neo4j/relationships', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
uri: 'bolt://10.10.10.189:7687',
username: 'neo4j',
password: 'neo4j',
relationship_type: 'KNOWS',
limit: 10
})
})
```