2025-02-21 17:05:37 +00:00
|
|
|
package document
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-03-05 12:05:46 +00:00
|
|
|
|
2025-02-21 17:05:37 +00:00
|
|
|
"queryorchestration/internal/database"
|
|
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type DocumentInList struct {
|
|
|
|
|
ID uuid.UUID
|
|
|
|
|
Bucket string
|
|
|
|
|
Key string
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-10 11:03:00 +00:00
|
|
|
func (s *Service) ListByClientId(ctx context.Context, id uuid.UUID) ([]*DocumentInList, error) {
|
|
|
|
|
documents, err := s.cfg.GetDBQueries().ListDocumentsByClientId(ctx, database.MustToDBUUID(id))
|
2025-02-21 17:05:37 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
docs := make([]*DocumentInList, len(documents))
|
|
|
|
|
for i, doc := range documents {
|
|
|
|
|
docs[i] = &DocumentInList{
|
|
|
|
|
ID: database.MustToUUID(doc.ID),
|
|
|
|
|
Bucket: doc.Bucket,
|
|
|
|
|
Key: doc.Key,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return docs, nil
|
|
|
|
|
}
|