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,14 @@ func NewModelHandler(svc *service.ModelService) *ModelHandler {
|
||||
return &ModelHandler{service: svc}
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
// @Summary 获取模型列表
|
||||
// @Description 获取所有已添加的AI模型列表
|
||||
// @Tags 模型管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /model/list [get]
|
||||
func (h *ModelHandler) List(c *gin.Context) {
|
||||
list, err := h.service.List()
|
||||
if err != nil {
|
||||
@@ -32,7 +39,15 @@ func (h *ModelHandler) List(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"list": list})
|
||||
}
|
||||
|
||||
// GetByID 获取详情
|
||||
// @Summary 获取模型详情
|
||||
// @Description 根据ID获取模型详细信息
|
||||
// @Tags 模型管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "模型ID"
|
||||
// @Success 200 {object} model.ModelInfo
|
||||
// @Failure 404 {object} map[string]string
|
||||
// @Router /model/{id} [get]
|
||||
func (h *ModelHandler) GetByID(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
model, err := h.service.GetByID(id)
|
||||
@@ -43,7 +58,16 @@ func (h *ModelHandler) GetByID(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, model)
|
||||
}
|
||||
|
||||
// Create 创建
|
||||
// @Summary 添加模型
|
||||
// @Description 添加新的AI模型配置
|
||||
// @Tags 模型管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body model.CreateModelRequest true "模型信息"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /model/add [post]
|
||||
func (h *ModelHandler) Create(c *gin.Context) {
|
||||
var req model.CreateModelRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
@@ -60,7 +84,17 @@ func (h *ModelHandler) Create(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// Update 更新
|
||||
// @Summary 更新模型
|
||||
// @Description 更新指定模型的信息
|
||||
// @Tags 模型管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "模型ID"
|
||||
// @Param request body model.UpdateModelRequest true "更新信息"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /model/{id} [put]
|
||||
func (h *ModelHandler) Update(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
var req model.UpdateModelRequest
|
||||
@@ -78,7 +112,15 @@ func (h *ModelHandler) Update(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
// @Summary 删除模型
|
||||
// @Description 删除指定的AI模型
|
||||
// @Tags 模型管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "模型ID"
|
||||
// @Success 200 {object} map[string]bool
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /model/{id} [delete]
|
||||
func (h *ModelHandler) Delete(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
err := h.service.Delete(id)
|
||||
@@ -90,7 +132,16 @@ func (h *ModelHandler) Delete(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true})
|
||||
}
|
||||
|
||||
// Test 测试连接
|
||||
// @Summary 测试模型连接
|
||||
// @Description 测试AI模型连接是否正常
|
||||
// @Tags 模型管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body model.TestModelRequest true "模型测试请求"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /model/test [post]
|
||||
func (h *ModelHandler) Test(c *gin.Context) {
|
||||
var req model.TestModelRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user