Files
knowledge-graph-agent/backend/models/requests.go
T

48 lines
3.1 KiB
Go

package models
// CreateNodeRequest 创建节点的请求结构
type CreateNodeRequest struct {
ID string `json:"id" binding:"required" example:"node_123"` // 节点唯一标识
Label string `json:"label" binding:"required" example:"人工智能"` // 节点显示标签
Type string `json:"type" binding:"required" example:"概念"` // 节点类型
X float64 `json:"x" example:"100"` // X坐标(可选)
Y float64 `json:"y" example:"200"` // Y坐标(可选)
Properties map[string]interface{} `json:"properties,omitempty"` // 自定义属性
}
// UpdateNodeRequest 更新节点的请求结构
type UpdateNodeRequest struct {
Label string `json:"label,omitempty" example:"机器学习"` // 节点显示标签
Type string `json:"type,omitempty" example:"工具"` // 节点类型
X *float64 `json:"x,omitempty" example:"150"` // X坐标
Y *float64 `json:"y,omitempty" example:"250"` // Y坐标
Properties map[string]interface{} `json:"properties,omitempty"` // 自定义属性(更新)
}
// DeleteResponse 删除操作的响应结构
type DeleteResponse struct {
Success bool `json:"success" example:"true"` // 是否成功
Message string `json:"message" example:"节点已成功删除"` // 消息
ID string `json:"id,omitempty" example:"node_123"` // 被删除的实体ID(可选)
}
// CreateEdgeRequest 创建边的请求结构
type CreateEdgeRequest struct {
ID string `json:"id" binding:"required" example:"edge_123"` // 边的唯一标识
Source string `json:"source" binding:"required" example:"node_1"` // 源节点ID
Target string `json:"target" binding:"required" example:"node_2"` // 目标节点ID
Label string `json:"label" binding:"required" example:"包含"` // 边的显示标签
Type string `json:"type" example:"CONTAINS"` // 边的类型(可选,默认为关系类型)
Properties map[string]interface{} `json:"properties,omitempty"` // 自定义属性
}
// EdgeResponse 边的响应结构
type EdgeResponse struct {
ID string `json:"id" example:"edge_123"` // 边的ID
Source string `json:"source" example:"node_1"` // 源节点ID
Target string `json:"target" example:"node_2"` // 目标节点ID
Label string `json:"label" example:"包含"` // 边的显示标签
Type string `json:"type" example:"CONTAINS"` // 边的类型
Properties map[string]interface{} `json:"properties,omitempty"` // 自定义属性
}