Remove platform tenancy from SXCHNGE customer BFF (#34)

This commit is contained in:
Stephan D committed 2026-09-12 14:00:14 +02:00
1 parent 7062672a87
commit 981e84a4b4
244 files changed
+651 -17130

No files matched your search

@@ -10,7 +10,6 @@ import (
"git.sendico.io/tech/sxchnge/bff/pkg/db/storable"
"git.sendico.io/tech/sxchnge/bff/pkg/db/transaction"
"git.sendico.io/tech/sxchnge/bff/pkg/merrors"
"git.sendico.io/tech/sxchnge/bff/pkg/model"
"go.mongodb.org/mongo-driver/v2/bson"
"go.mongodb.org/mongo-driver/v2/mongo"
"go.mongodb.org/mongo-driver/v2/mongo/options"
@@ -227,57 +226,6 @@ func (r *MongoRepository) ListIDs(ctx context.Context, query builder.Query) ([]b
return ids, nil
}
func (r *MongoRepository) ListPermissionBound(ctx context.Context, query builder.Query) ([]model.PermissionBoundStorable, error) {
return listProjectedStorables(ctx, r.collection, query, bson.M{
storable.IDField: 1,
storable.PermissionRefField: 1,
storable.OrganizationRefField: 1,
}, func(doc *model.PermissionBound) model.PermissionBoundStorable {
return doc
})
}
func (r *MongoRepository) ListAccountBound(ctx context.Context, query builder.Query) ([]model.AccountBoundStorable, error) {
return listProjectedStorables(ctx, r.collection, query, bson.M{
storable.IDField: 1,
model.AccountRefField: 1,
model.OrganizationRefField: 1,
}, func(doc *model.AccountBoundBase) model.AccountBoundStorable {
return doc
})
}
func listProjectedStorables[T any, R any](
ctx context.Context,
collection *mongo.Collection,
query builder.Query,
projection bson.M,
wrap func(*T) R,
) ([]R, error) {
filter := query.BuildQuery()
cursor, err := collection.Find(ctx, filter, options.Find().SetProjection(projection))
if err != nil {
return nil, err
}
defer func() {
_ = cursor.Close(ctx)
}()
result := make([]R, 0)
for cursor.Next(ctx) {
doc := new(T)
if err := cursor.Decode(doc); err != nil {
return nil, err
}
result = append(result, wrap(doc))
}
if err := cursor.Err(); err != nil {
return nil, err
}
return result, nil
}
func (r *MongoRepository) Delete(ctx context.Context, id bson.ObjectID) error {
_, err := r.collection.DeleteOne(ctx, idFilter(id))
return err