Files
knowledge-graph-agent/backend/internal/model/response.go
T
2026-04-28 12:55:46 +08:00

54 lines
2.4 KiB
Go

package model
// ErrorResponse represents a standardized API error response.
type ErrorResponse struct {
Error string `json:"error" example:"bad_request"`
Message string `json:"message" example:"invalid request"`
}
// 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"`
}