feat(ECR-027): AICoreConfig KnowledgeChunk 只读并 Closed

KnowledgeChunk catalog (000028) · Loop continuous.
This commit is contained in:
jackyu66git
2026-08-08 03:14:17 +08:00
parent 78857d5510
commit c1a8a58488
26 changed files with 565 additions and 1 deletions
@@ -0,0 +1,34 @@
package admin
import (
"context"
"errors"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
)
var ErrKnowledgeChunkNotFound = errString("knowledge chunk not found")
// ListKnowledgeChunks returns catalog.
func (s *Service) ListKnowledgeChunks(ctx context.Context) ([]repository.KnowledgeChunkRow, error) {
items, err := s.Repo.ListKnowledgeChunks(ctx)
if err != nil {
return nil, err
}
if items == nil {
items = []repository.KnowledgeChunkRow{}
}
return items, nil
}
// GetKnowledgeChunk loads one.
func (s *Service) GetKnowledgeChunk(ctx context.Context, id uuid.UUID) (*repository.KnowledgeChunkRow, error) {
row, err := s.Repo.GetKnowledgeChunk(ctx, id)
if errors.Is(err, pgx.ErrNoRows) {
return nil, ErrKnowledgeChunkNotFound
}
return row, err
}