fix: 优化后端各模块 handler
- database_handler, knowledge_handler, model_handler - neo4j_handler, sub_table_handler - system_handler, upload_handler - knowledge_service, upload_service Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,16 @@ func NewDatabaseHandler(svc *service.DatabaseService) *DatabaseHandler {
|
||||
return &DatabaseHandler{service: svc}
|
||||
}
|
||||
|
||||
// Check 检查数据库连接
|
||||
// @Summary 检查数据库连接
|
||||
// @Description 测试数据库连接是否正常
|
||||
// @Tags 数据库管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body model.CheckRequest true "数据库连接信息"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /database/check [post]
|
||||
func (h *DatabaseHandler) Check(c *gin.Context) {
|
||||
var req model.CheckRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -34,7 +43,16 @@ func (h *DatabaseHandler) Check(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// Create 创建数据库信息
|
||||
// @Summary 创建数据库
|
||||
// @Description 添加新的数据库连接信息
|
||||
// @Tags 数据库管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body model.CreateDatabaseRequest true "数据库信息"
|
||||
// @Success 201 {object} model.DatabaseInfo
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /database/add [post]
|
||||
func (h *DatabaseHandler) Create(c *gin.Context) {
|
||||
var req model.CreateDatabaseRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -51,7 +69,15 @@ func (h *DatabaseHandler) Create(c *gin.Context) {
|
||||
c.JSON(http.StatusCreated, info)
|
||||
}
|
||||
|
||||
// GetByID 获取详情
|
||||
// @Summary 获取数据库详情
|
||||
// @Description 根据ID获取数据库详细信息
|
||||
// @Tags 数据库管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "数据库ID"
|
||||
// @Success 200 {object} model.DatabaseInfo
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Router /database/{id} [get]
|
||||
func (h *DatabaseHandler) GetByID(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
|
||||
@@ -64,7 +90,14 @@ func (h *DatabaseHandler) GetByID(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, info)
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
// @Summary 获取数据库列表
|
||||
// @Description 获取所有已添加的数据库列表
|
||||
// @Tags 数据库管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /database/list [get]
|
||||
func (h *DatabaseHandler) List(c *gin.Context) {
|
||||
list, err := h.service.List()
|
||||
if err != nil {
|
||||
@@ -79,7 +112,17 @@ func (h *DatabaseHandler) List(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"list": list})
|
||||
}
|
||||
|
||||
// Update 更新
|
||||
// @Summary 更新数据库信息
|
||||
// @Description 更新指定数据库的信息
|
||||
// @Tags 数据库管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "数据库ID"
|
||||
// @Param request body model.UpdateDatabaseRequest true "更新信息"
|
||||
// @Success 200 {object} model.DatabaseInfo
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Router /database/{id} [put]
|
||||
func (h *DatabaseHandler) Update(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
|
||||
@@ -98,7 +141,16 @@ func (h *DatabaseHandler) Update(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, info)
|
||||
}
|
||||
|
||||
// SaveGraph 保存图谱信息
|
||||
// @Summary 保存图谱信息
|
||||
// @Description 保存数据库的图谱结构信息
|
||||
// @Tags 数据库管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body model.SaveGraphRequest true "图谱信息"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /database/graph/save [post]
|
||||
func (h *DatabaseHandler) SaveGraph(c *gin.Context) {
|
||||
var req model.SaveGraphRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -115,7 +167,15 @@ func (h *DatabaseHandler) SaveGraph(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
// @Summary 删除数据库
|
||||
// @Description 删除指定的数据库连接
|
||||
// @Tags 数据库管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "数据库ID"
|
||||
// @Success 200 {object} map[string]string
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Router /database/{id} [delete]
|
||||
func (h *DatabaseHandler) Delete(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user