feat: 知识图谱测试api
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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"],
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user