feat: 增加对neo4j的增改查
This commit is contained in:
+320
-39
@@ -1,5 +1,83 @@
|
||||
basePath: /
|
||||
definitions:
|
||||
models.CreateEdgeRequest:
|
||||
properties:
|
||||
id:
|
||||
description: 边的唯一标识
|
||||
example: edge_123
|
||||
type: string
|
||||
label:
|
||||
description: 边的显示标签
|
||||
example: 包含
|
||||
type: string
|
||||
properties:
|
||||
additionalProperties: true
|
||||
description: 自定义属性
|
||||
type: object
|
||||
source:
|
||||
description: 源节点ID
|
||||
example: node_1
|
||||
type: string
|
||||
target:
|
||||
description: 目标节点ID
|
||||
example: node_2
|
||||
type: string
|
||||
type:
|
||||
description: 边的类型(可选,默认为关系类型)
|
||||
example: CONTAINS
|
||||
type: string
|
||||
required:
|
||||
- id
|
||||
- label
|
||||
- source
|
||||
- target
|
||||
type: object
|
||||
models.CreateNodeRequest:
|
||||
properties:
|
||||
id:
|
||||
description: 节点唯一标识
|
||||
example: node_123
|
||||
type: string
|
||||
label:
|
||||
description: 节点显示标签
|
||||
example: 人工智能
|
||||
type: string
|
||||
properties:
|
||||
additionalProperties: true
|
||||
description: 自定义属性
|
||||
type: object
|
||||
type:
|
||||
description: 节点类型
|
||||
example: 概念
|
||||
type: string
|
||||
x:
|
||||
description: X坐标(可选)
|
||||
example: 100
|
||||
type: number
|
||||
"y":
|
||||
description: Y坐标(可选)
|
||||
example: 200
|
||||
type: number
|
||||
required:
|
||||
- id
|
||||
- label
|
||||
- type
|
||||
type: object
|
||||
models.DeleteResponse:
|
||||
properties:
|
||||
id:
|
||||
description: 被删除的实体ID(可选)
|
||||
example: node_123
|
||||
type: string
|
||||
message:
|
||||
description: 消息
|
||||
example: 节点已成功删除
|
||||
type: string
|
||||
success:
|
||||
description: 是否成功
|
||||
example: true
|
||||
type: boolean
|
||||
type: object
|
||||
models.Edge:
|
||||
properties:
|
||||
id:
|
||||
@@ -19,6 +97,33 @@ definitions:
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
models.EdgeResponse:
|
||||
properties:
|
||||
id:
|
||||
description: 边的ID
|
||||
example: edge_123
|
||||
type: string
|
||||
label:
|
||||
description: 边的显示标签
|
||||
example: 包含
|
||||
type: string
|
||||
properties:
|
||||
additionalProperties: true
|
||||
description: 自定义属性
|
||||
type: object
|
||||
source:
|
||||
description: 源节点ID
|
||||
example: node_1
|
||||
type: string
|
||||
target:
|
||||
description: 目标节点ID
|
||||
example: node_2
|
||||
type: string
|
||||
type:
|
||||
description: 边的类型
|
||||
example: CONTAINS
|
||||
type: string
|
||||
type: object
|
||||
models.ErrorResponse:
|
||||
properties:
|
||||
error:
|
||||
@@ -30,22 +135,22 @@ definitions:
|
||||
properties:
|
||||
edges:
|
||||
items:
|
||||
$ref: "#/definitions/models.Edge"
|
||||
$ref: '#/definitions/models.Edge'
|
||||
type: array
|
||||
nodes:
|
||||
items:
|
||||
$ref: "#/definitions/models.Node"
|
||||
$ref: '#/definitions/models.Node'
|
||||
type: array
|
||||
type: object
|
||||
models.NeighborResponse:
|
||||
properties:
|
||||
edges:
|
||||
items:
|
||||
$ref: "#/definitions/models.Edge"
|
||||
$ref: '#/definitions/models.Edge'
|
||||
type: array
|
||||
nodes:
|
||||
items:
|
||||
$ref: "#/definitions/models.Node"
|
||||
$ref: '#/definitions/models.Node'
|
||||
type: array
|
||||
type: object
|
||||
models.Node:
|
||||
@@ -88,9 +193,32 @@ definitions:
|
||||
type: integer
|
||||
results:
|
||||
items:
|
||||
$ref: "#/definitions/models.Node"
|
||||
$ref: '#/definitions/models.Node'
|
||||
type: array
|
||||
type: object
|
||||
models.UpdateNodeRequest:
|
||||
properties:
|
||||
label:
|
||||
description: 节点显示标签
|
||||
example: 机器学习
|
||||
type: string
|
||||
properties:
|
||||
additionalProperties: true
|
||||
description: 自定义属性(更新)
|
||||
type: object
|
||||
type:
|
||||
description: 节点类型
|
||||
example: 工具
|
||||
type: string
|
||||
x:
|
||||
description: X坐标
|
||||
example: 150
|
||||
type: number
|
||||
"y":
|
||||
description: Y坐标
|
||||
example: 250
|
||||
type: number
|
||||
type: object
|
||||
host: localhost:3001
|
||||
info:
|
||||
contact: {}
|
||||
@@ -98,26 +226,87 @@ info:
|
||||
title: 知识图谱 API
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/api/edges:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 在知识图谱中创建一个新边(关系)
|
||||
parameters:
|
||||
- description: 边创建请求
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/models.CreateEdgeRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 创建成功
|
||||
schema:
|
||||
$ref: '#/definitions/models.EdgeResponse'
|
||||
"400":
|
||||
description: 请求错误
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"404":
|
||||
description: 源节点或目标节点未找到
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"409":
|
||||
description: 边已存在
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 创建边
|
||||
/api/edges/{id}:
|
||||
delete:
|
||||
description: 从知识图谱中删除指定的边
|
||||
parameters:
|
||||
- description: 边ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 删除成功
|
||||
schema:
|
||||
$ref: '#/definitions/models.DeleteResponse'
|
||||
"404":
|
||||
description: 边未找到
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 删除边
|
||||
/api/graph:
|
||||
get:
|
||||
description: 获取知识图谱的全部节点和边数据
|
||||
produces:
|
||||
- application/json
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 成功
|
||||
schema:
|
||||
$ref: "#/definitions/models.GraphData"
|
||||
$ref: '#/definitions/models.GraphData'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 获取图数据
|
||||
/api/graph/stats:
|
||||
get:
|
||||
description: 获取知识图谱的节点数、边数等统计信息
|
||||
produces:
|
||||
- application/json
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 成功
|
||||
@@ -127,89 +316,181 @@ paths:
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 获取图统计信息
|
||||
/api/nodes:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 在知识图谱中创建一个新节点
|
||||
parameters:
|
||||
- description: 节点创建请求
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/models.CreateNodeRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 创建成功
|
||||
schema:
|
||||
$ref: '#/definitions/models.Node'
|
||||
"400":
|
||||
description: 请求错误
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"409":
|
||||
description: 节点已存在
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 创建节点
|
||||
/api/nodes/{id}:
|
||||
delete:
|
||||
description: 从知识图谱中删除指定节点及其相关的所有边
|
||||
parameters:
|
||||
- description: 节点ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 删除成功
|
||||
schema:
|
||||
$ref: '#/definitions/models.DeleteResponse'
|
||||
"404":
|
||||
description: 节点未找到
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 删除节点
|
||||
get:
|
||||
description: 根据节点 ID 获取知识图谱中的节点详细信息
|
||||
parameters:
|
||||
- description: 节点 ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: 节点 ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 成功
|
||||
schema:
|
||||
$ref: "#/definitions/models.NodeResponse"
|
||||
$ref: '#/definitions/models.NodeResponse'
|
||||
"400":
|
||||
description: 请求错误
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"404":
|
||||
description: 节点未找到
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 获取节点详情
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 更新知识图谱中指定节点的信息
|
||||
parameters:
|
||||
- description: 节点ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: 节点更新请求
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/models.UpdateNodeRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 更新成功
|
||||
schema:
|
||||
$ref: '#/definitions/models.Node'
|
||||
"400":
|
||||
description: 请求错误
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"404":
|
||||
description: 节点未找到
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 更新节点
|
||||
/api/nodes/{id}/neighbors:
|
||||
get:
|
||||
description: 根据节点 ID 获取其所有邻居节点及关联边
|
||||
parameters:
|
||||
- description: 节点 ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: 节点 ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 成功
|
||||
schema:
|
||||
$ref: "#/definitions/models.NeighborResponse"
|
||||
$ref: '#/definitions/models.NeighborResponse'
|
||||
"400":
|
||||
description: 请求错误
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"404":
|
||||
description: 节点未找到
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 获取节点邻居
|
||||
/api/search:
|
||||
get:
|
||||
description: 根据关键词搜索知识图谱中的节点
|
||||
parameters:
|
||||
- description: 搜索关键词
|
||||
in: query
|
||||
name: q
|
||||
required: true
|
||||
type: string
|
||||
- description: 搜索关键词
|
||||
in: query
|
||||
name: q
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: 成功
|
||||
schema:
|
||||
$ref: "#/definitions/models.SearchResponse"
|
||||
$ref: '#/definitions/models.SearchResponse'
|
||||
"400":
|
||||
description: 请求错误
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
"500":
|
||||
description: 内部错误
|
||||
schema:
|
||||
$ref: "#/definitions/models.ErrorResponse"
|
||||
$ref: '#/definitions/models.ErrorResponse'
|
||||
summary: 搜索节点
|
||||
swagger: "2.0"
|
||||
|
||||
Reference in New Issue
Block a user