Files
rag/controller/document.go
qhd a05cac7591 feat: 新增关键词类型及优化查询逻辑
支持关键词类型区分,优化文件向量查询SQL及DAO更新逻辑,移除冗余配置和注释代码。
2026-04-11 18:24:37 +08:00

54 lines
1.4 KiB
Go

package controller
import (
"context"
"rag/model/dto"
"rag/service"
"gitea.com/red-future/common/beans"
"github.com/gogf/gf/v2/frame/g"
)
type document struct{}
var Document = new(document)
// Create 创建文件
func (c *document) Create(ctx context.Context, req *dto.CreateDocumentReq) (res *dto.CreateDocumentRes, err error) {
res, err = service.Document.Create(ctx, req)
return
}
// Update 更新文件
func (c *document) Update(ctx context.Context, req *dto.UpdateDocumentReq) (res *beans.ResponseEmpty, err error) {
err = service.Document.Update(ctx, req)
return
}
// Delete 删除文件
func (c *document) Delete(ctx context.Context, req *dto.DeleteDocumentReq) (res *beans.ResponseEmpty, err error) {
err = service.Document.Delete(ctx, req)
return
}
// Get 获取文件详情
func (c *document) Get(ctx context.Context, req *dto.GetDocumentReq) (res *dto.GetDocumentRes, err error) {
res, err = service.Document.Get(ctx, req)
return
}
// List 文件列表
func (c *document) List(ctx context.Context, req *dto.ListDocumentReq) (res *dto.ListDocumentRes, err error) {
if !g.IsEmpty(req.Page) {
req.Page = &beans.Page{PageNum: 1, PageSize: 20}
}
res, err = service.Document.List(ctx, req)
return
}
// DocumentVector 处理文件(向量化)
func (c *document) DocumentVector(ctx context.Context, req *dto.DocumentVectorReq) (res *beans.ResponseEmpty, err error) {
err = service.Document.Vector(ctx, req)
return
}