Files
knowledge-graph-agent/backend/handlers/graph_handler.go
T
2026-04-05 15:04:26 +08:00

35 lines
667 B
Go

package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
"knowledge-graph-backend/services"
)
type GraphHandler struct {
dataService *services.DataService
}
func NewGraphHandler(dataService *services.DataService) *GraphHandler {
return &GraphHandler{
dataService: dataService,
}
}
func (h *GraphHandler) GetGraphData(c *gin.Context) {
data := h.dataService.GetGraphData()
c.JSON(http.StatusOK, data)
}
func (h *GraphHandler) GetStats(c *gin.Context) {
stats := h.dataService.GetStats()
c.JSON(http.StatusOK, gin.H{
"stats": stats,
"timestamp": gin.H{
"totalNodes": stats["totalNodes"],
"totalEdges": stats["totalEdges"],
},
})
}