extract common create and updatelogic

This commit is contained in:
Michael McGuinness
2025-01-03 16:00:36 +00:00
parent 9f505dd94c
commit 0447ec4c4b
9 changed files with 24 additions and 72 deletions
+1 -12
View File
@@ -4,8 +4,6 @@ import (
"context"
"queryorchestration/internal/database/repository"
queryprocessor "queryorchestration/internal/queryProcessor"
"github.com/google/uuid"
)
type Creator struct {
@@ -18,15 +16,6 @@ func NewCreator(db *repository.Queries) Creator {
func (s Creator) Validate(ctx context.Context, entity *queryprocessor.Create) error {
// TODO
// Type, RequiredQueryIDs, Config
return nil
}
func (s Creator) Create(ctx context.Context, entity *queryprocessor.Create) (uuid.UUID, error) {
err := s.Validate(ctx, entity)
if err != nil {
return uuid.Nil, err
}
// TODO
return uuid.Nil, nil
}
+2 -11
View File
@@ -14,17 +14,8 @@ func NewUpdator(db *repository.Queries) Updator {
return Updator{db}
}
func (s Updator) Validate(ctx context.Context, entity *queryprocessor.Update) error {
// TODO
return nil
}
func (s Updator) Update(ctx context.Context, entity *queryprocessor.Update) error {
err := s.Validate(ctx, entity)
if err != nil {
return err
}
func (s Updator) Validate(ctx context.Context, current *queryprocessor.Query, entity *queryprocessor.Update) error {
// TODO
// Type, RequiredQueryIDs, Config
return nil
}