+address book service
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
This commit is contained in:
20
api/pkg/db/internal/mongo/paymethoddb/archived.go
Normal file
20
api/pkg/db/internal/mongo/paymethoddb/archived.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package paymethoddb
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/tech/sendico/pkg/mutil/mzap"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (db *PaymentMethodsDB) SetArchived(ctx context.Context, accountRef, organizationRef, objectRef primitive.ObjectID, isArchived, cascade bool) error {
|
||||
// Use the ArchivableDB for the main archiving logic
|
||||
if err := db.ArchivableDB.SetArchived(ctx, accountRef, objectRef, isArchived); err != nil {
|
||||
db.DBImp.Logger.Warn("Failed to chnage object archive status", zap.Error(err),
|
||||
mzap.ObjRef("account_ref", accountRef), mzap.ObjRef("organization_ref", organizationRef),
|
||||
mzap.ObjRef("object_ref", objectRef), zap.Bool("archived", isArchived), zap.Bool("cascade", cascade))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
49
api/pkg/db/internal/mongo/paymethoddb/db.go
Normal file
49
api/pkg/db/internal/mongo/paymethoddb/db.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package paymethoddb
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/tech/sendico/pkg/auth"
|
||||
"github.com/tech/sendico/pkg/db/policy"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"github.com/tech/sendico/pkg/mservice"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
type PaymentMethodsDB struct {
|
||||
auth.ProtectedDBImp[*model.PaymentMethod]
|
||||
auth.ArchivableDB[*model.PaymentMethod]
|
||||
}
|
||||
|
||||
func Create(ctx context.Context,
|
||||
logger mlogger.Logger,
|
||||
enforcer auth.Enforcer,
|
||||
pdb policy.DB,
|
||||
db *mongo.Database,
|
||||
) (*PaymentMethodsDB, error) {
|
||||
p, err := auth.CreateDBImp[*model.PaymentMethod](ctx, logger, pdb, enforcer, mservice.PaymentMethods, db)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
createEmpty := func() *model.PaymentMethod {
|
||||
return &model.PaymentMethod{}
|
||||
}
|
||||
|
||||
getArchivable := func(c *model.PaymentMethod) model.Archivable {
|
||||
return &c.ArchivableBase
|
||||
}
|
||||
|
||||
res := &PaymentMethodsDB{
|
||||
ProtectedDBImp: *p,
|
||||
ArchivableDB: auth.NewArchivableDB(
|
||||
p.DBImp,
|
||||
logger,
|
||||
p.Enforcer,
|
||||
createEmpty,
|
||||
getArchivable,
|
||||
),
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
28
api/pkg/db/internal/mongo/paymethoddb/list.go
Normal file
28
api/pkg/db/internal/mongo/paymethoddb/list.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package paymethoddb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/tech/sendico/pkg/db/repository"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
mauth "github.com/tech/sendico/pkg/mutil/db/auth"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
func (db *PaymentMethodsDB) List(ctx context.Context, accountRef, organizationRef, recipientRef primitive.ObjectID, cursor *model.ViewCursor) ([]model.PaymentMethod, error) {
|
||||
res, err := mauth.GetProtectedObjects[model.PaymentMethod](
|
||||
ctx,
|
||||
db.DBImp.Logger,
|
||||
accountRef, organizationRef, model.ActionRead,
|
||||
repository.OrgFilter(organizationRef).And(repository.Filter("recipientRef", recipientRef)),
|
||||
cursor,
|
||||
db.Enforcer,
|
||||
db.DBImp.Repository,
|
||||
)
|
||||
if errors.Is(err, merrors.ErrNoData) {
|
||||
return []model.PaymentMethod{}, nil
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
Reference in New Issue
Block a user