refactor: 按go modules规范重构
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
package model
|
||||
|
||||
// Node represents a graph node
|
||||
type Node struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Type string `json:"type,omitempty"`
|
||||
X float64 `json:"x,omitempty"`
|
||||
Y float64 `json:"y,omitempty"`
|
||||
Style map[string]interface{} `json:"style,omitempty"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// Edge represents a graph edge
|
||||
type Edge struct {
|
||||
ID string `json:"id"`
|
||||
Source string `json:"source"`
|
||||
Target string `json:"target"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Style map[string]interface{} `json:"style,omitempty"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// GraphData represents the complete graph structure
|
||||
type GraphData struct {
|
||||
Nodes []Node `json:"nodes"`
|
||||
Edges []Edge `json:"edges"`
|
||||
}
|
||||
|
||||
// SimpleNode 简化版节点结构,仅保留核心信息,适合 LLM 处理
|
||||
type SimpleNode struct {
|
||||
ID string `json:"id" example:"1"`
|
||||
Label string `json:"label" example:"人工智能"`
|
||||
Type string `json:"type,omitempty" example:"概念"`
|
||||
}
|
||||
|
||||
// SimpleEdge 简化版边结构,仅保留核心信息,适合 LLM 处理
|
||||
type SimpleEdge struct {
|
||||
Source string `json:"source" example:"1"`
|
||||
Target string `json:"target" example:"2"`
|
||||
Type string `json:"type,omitempty" example:"CONTAINS"`
|
||||
Label string `json:"label,omitempty" example:"包含"`
|
||||
}
|
||||
|
||||
// SimpleGraphData 简化版图数据,适合 LLM 处理
|
||||
type SimpleGraphData struct {
|
||||
Nodes []SimpleNode `json:"nodes"`
|
||||
Edges []SimpleEdge `json:"edges"`
|
||||
}
|
||||
|
||||
// StatsResponse represents graph statistics
|
||||
type StatsResponse struct {
|
||||
TotalNodes int `json:"totalNodes"`
|
||||
TotalEdges int `json:"totalEdges"`
|
||||
ConceptNodes int `json:"conceptNodes,omitempty"`
|
||||
ToolNodes int `json:"toolNodes,omitempty"`
|
||||
ApplicationNodes int `json:"applicationNodes,omitempty"`
|
||||
}
|
||||
|
||||
// NeighborResponse represents a node's neighbors and related edges
|
||||
type NeighborResponse struct {
|
||||
Nodes []Node `json:"nodes"`
|
||||
Edges []Edge `json:"edges"`
|
||||
}
|
||||
|
||||
// NodeResponse represents a node detail response
|
||||
type NodeResponse struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Type string `json:"type,omitempty"`
|
||||
X float64 `json:"x,omitempty"`
|
||||
Y float64 `json:"y,omitempty"`
|
||||
Style map[string]interface{} `json:"style,omitempty"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
Neighbors []Node `json:"neighbors,omitempty"`
|
||||
}
|
||||
|
||||
// SearchResponse represents search results
|
||||
type SearchResponse struct {
|
||||
Count int `json:"count"`
|
||||
Query string `json:"query"`
|
||||
Nodes []Node `json:"nodes"`
|
||||
}
|
||||
|
||||
// ErrorResponse represents an error response
|
||||
type ErrorResponse struct {
|
||||
Error string `json:"error"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
// NodeInfo represents detailed node information
|
||||
type NodeInfo struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Type string `json:"type"`
|
||||
X float64 `json:"x,omitempty"`
|
||||
Y float64 `json:"y,omitempty"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
Neighbors []Node `json:"neighbors,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
// CreateNodeRequest creates a new node
|
||||
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"`
|
||||
Y float64 `json:"y" example:"200"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateNodeRequest updates an existing node
|
||||
type UpdateNodeRequest struct {
|
||||
Label string `json:"label,omitempty" example:"机器学习"`
|
||||
Type string `json:"type,omitempty" example:"工具"`
|
||||
X *float64 `json:"x,omitempty" example:"150"`
|
||||
Y *float64 `json:"y,omitempty" example:"250"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// DeleteResponse represents a delete operation response
|
||||
type DeleteResponse struct {
|
||||
Success bool `json:"success" example:"true"`
|
||||
Message string `json:"message" example:"节点已成功删除"`
|
||||
ID string `json:"id,omitempty" example:"node_123"`
|
||||
}
|
||||
|
||||
// CreateEdgeRequest creates a new edge
|
||||
type CreateEdgeRequest struct {
|
||||
ID string `json:"id" binding:"required" example:"edge_123"`
|
||||
Source string `json:"source" binding:"required" example:"node_1"`
|
||||
Target string `json:"target" binding:"required" example:"node_2"`
|
||||
Label string `json:"label" binding:"required" example:"包含"`
|
||||
Type string `json:"type" example:"CONTAINS"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// EdgeResponse represents an edge response
|
||||
type EdgeResponse struct {
|
||||
ID string `json:"id" example:"edge_123"`
|
||||
Source string `json:"source" example:"node_1"`
|
||||
Target string `json:"target" example:"node_2"`
|
||||
Label string `json:"label" example:"包含"`
|
||||
Type string `json:"type" example:"CONTAINS"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user