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:
@@ -20,7 +20,16 @@ func NewUploadHandler(uploadService *service.UploadService, knowledgeRepo *repos
|
||||
return &UploadHandler{uploadService: uploadService, knowledgeRepo: knowledgeRepo}
|
||||
}
|
||||
|
||||
// Upload 上传文件
|
||||
// @Summary 上传文件
|
||||
// @Description 上传文件到服务器(本地存储或MinIO)
|
||||
// @Tags 文件上传
|
||||
// @Accept multipart/form-data
|
||||
// @Produce json
|
||||
// @Param file formData file true "要上传的文件"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /api/file_upload [post]
|
||||
func (h *UploadHandler) Upload(c *gin.Context) {
|
||||
file, err := c.FormFile("file")
|
||||
if err != nil {
|
||||
@@ -48,7 +57,16 @@ func (h *UploadHandler) Upload(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
// Delete 删除文件
|
||||
// @Summary 删除文件
|
||||
// @Description 删除指定文件
|
||||
// @Tags 文件上传
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filename path string true "文件名"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /api/file_upload/{filename} [delete]
|
||||
func (h *UploadHandler) Delete(c *gin.Context) {
|
||||
filename := c.Param("filename")
|
||||
if filename == "" {
|
||||
@@ -64,7 +82,17 @@ func (h *UploadHandler) Delete(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": "File deleted"})
|
||||
}
|
||||
|
||||
// ProxyFile 代理文件访问(解决 MinIO 内网地址和 HTTPS 问题)
|
||||
// @Summary 代理文件访问
|
||||
// @Description 代理访问文件,解决 MinIO 内网和 HTTPS 问题
|
||||
// @Tags 文件上传
|
||||
// @Accept json
|
||||
// @Produce octet-stream
|
||||
// @Param key query string true "文件Key"
|
||||
// @Param kb_id query string false "知识库ID"
|
||||
// @Success 200 {file} binary
|
||||
// @Failure 400 {object} map[string]string
|
||||
// @Failure 500 {object} map[string]string
|
||||
// @Router /api/file_proxy [get]
|
||||
func (h *UploadHandler) ProxyFile(c *gin.Context) {
|
||||
fileKey := c.Query("key")
|
||||
kbID := c.Query("kb_id")
|
||||
|
||||
Reference in New Issue
Block a user