diff --git a/domain/redirectdefinition/repository/redirectdefinition.go b/domain/redirectdefinition/repository/redirectdefinition.go index a325109..aeacd16 100644 --- a/domain/redirectdefinition/repository/redirectdefinition.go +++ b/domain/redirectdefinition/repository/redirectdefinition.go @@ -2,6 +2,7 @@ package redirectrepository import ( "context" + redirectstore "github.com/foomo/redirects/domain/redirectdefinition/store" keelmongo "github.com/foomo/keel/persistence/mongo" @@ -15,7 +16,7 @@ type ( RSI interface { Find(ctx context.Context, id string) (*redirectstore.RedirectDefinition, error) } - BaseRedirectsDefinition struct { + RedirectsDefinitionRepository struct { l *zap.Logger collection *keelmongo.Collection } @@ -39,12 +40,11 @@ func NewRedirectsStore(l *zap.Logger, persistor *keelmongo.Persistor) (rs *Redir } return &RedirectsDefinitionRepository{ l: l, - persistor: persistor, collection: collection}, nil } -func (rs RedirectsDefinitionRepository) Find(ctx context.Context, id string) (*RedirectDefinition, error) { - var result RedirectDefinition +func (rs RedirectsDefinitionRepository) Find(ctx context.Context, id string) (*redirectstore.RedirectDefinition, error) { + var result redirectstore.RedirectDefinition findErr := rs.collection.FindOne(ctx, bson.M{"id": id}, &result) if findErr != nil { return nil, findErr @@ -52,12 +52,12 @@ func (rs RedirectsDefinitionRepository) Find(ctx context.Context, id string) (*R return &result, nil } -func (rs RedirectsDefinitionRepository) Insert(ctx context.Context, def *RedirectDefinition) error { +func (rs RedirectsDefinitionRepository) Insert(ctx context.Context, def *redirectstore.RedirectDefinition) error { _, err := rs.collection.Col().InsertOne(ctx, def) return err } -func (rs RedirectsDefinitionRepository) Update(ctx context.Context, def *RedirectDefinition) error { +func (rs RedirectsDefinitionRepository) Update(ctx context.Context, def *redirectstore.RedirectDefinition) error { filter := bson.D{{Key: "id", Value: def.ID}} update := bson.D{{Key: "$set", Value: def}} @@ -67,7 +67,7 @@ func (rs RedirectsDefinitionRepository) Update(ctx context.Context, def *Redirec } // maybe will be needed for migrating manual redirections? -func (rs RedirectsDefinitionRepository) UpsertMany(ctx context.Context, defs []*RedirectDefinition) error { +func (rs RedirectsDefinitionRepository) UpsertMany(ctx context.Context, defs []*redirectstore.RedirectDefinition) error { var operations []mongo.WriteModel diff --git a/domain/redirectdefinition/service.go b/domain/redirectdefinition/service.go index acfed6a..a1b736b 100644 --- a/domain/redirectdefinition/service.go +++ b/domain/redirectdefinition/service.go @@ -3,6 +3,7 @@ package redirectdefinition import ( "github.com/foomo/contentserver/content" keelmongo "github.com/foomo/keel/persistence/mongo" + redirectstore "github.com/foomo/redirects/domain/redirectdefinition/store" "go.uber.org/zap" ) @@ -22,12 +23,12 @@ func (rs *Service) CreateRedirectsFromContentserverexport(old, new map[string]*c return nil } -func (rs *Service) Search(dimension, id, path string) ([]*RedirectDefinition, error) { +func (rs *Service) Search(dimension, id, path string) ([]*redirectstore.RedirectDefinition, error) { // TODO: Implement return nil, nil } -func (rs *Service) Create(def *RedirectDefinition) error { +func (rs *Service) Create(def *redirectstore.RedirectDefinition) error { // TODO: Implement return nil } @@ -37,7 +38,7 @@ func (rs *Service) Delete(id string) error { return nil } -func (rs *Service) Update(def *RedirectDefinition) error { +func (rs *Service) Update(def *redirectstore.RedirectDefinition) error { // TODO: Implement return nil }