2025-01-24 16:12:25 +00:00
|
|
|
package document
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"queryorchestration/internal/database"
|
|
|
|
|
"queryorchestration/internal/database/repository"
|
|
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Location = string
|
|
|
|
|
|
|
|
|
|
type Create struct {
|
|
|
|
|
JobID uuid.UUID
|
|
|
|
|
Location Location
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Service) Create(ctx context.Context, doc *Create) (uuid.UUID, error) {
|
|
|
|
|
hash, err := s.getHash()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return uuid.Nil, err
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 13:43:55 +00:00
|
|
|
dbid, err := s.cfg.GetDBQueries().CreateDocument(ctx, &repository.CreateDocumentParams{
|
2025-01-24 16:12:25 +00:00
|
|
|
Jobid: database.MustToDBUUID(doc.JobID),
|
|
|
|
|
Hash: hash,
|
|
|
|
|
Location: doc.Location,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return uuid.Nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
id := database.MustToUUID(dbid)
|
|
|
|
|
|
|
|
|
|
return id, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Service) getHash() (string, error) {
|
|
|
|
|
// TODO
|
|
|
|
|
return "example_hash", nil
|
|
|
|
|
}
|