33 lines
721 B
Go
33 lines
721 B
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"rag-local/kb/model/dto"
|
|
"rag-local/kb/service"
|
|
)
|
|
|
|
type chunk struct{}
|
|
|
|
var Chunk = &chunk{}
|
|
|
|
func (c *chunk) List(ctx context.Context, req *dto.ListChunkReq) (*dto.ListChunkRes, error) {
|
|
list, total, err := service.ChunkService.List(ctx, req.DocumentId, req.Page, req.PageSize)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &dto.ListChunkRes{
|
|
List: list,
|
|
Total: total,
|
|
Page: req.Page,
|
|
PageSize: req.PageSize,
|
|
}, nil
|
|
}
|
|
|
|
func (c *chunk) Update(ctx context.Context, req *dto.UpdateChunkReq) (*dto.UpdateChunkRes, error) {
|
|
if err := service.ChunkService.Update(ctx, req.Id, req.Content); err != nil {
|
|
return nil, err
|
|
}
|
|
return &dto.UpdateChunkRes{}, nil
|
|
}
|