2024-05-24 17:44:24 +00:00
|
|
|
package factory
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log/slog"
|
|
|
|
|
|
|
|
"github.com/emochka2007/block-accounting/internal/pkg/config"
|
2024-05-25 13:00:21 +00:00
|
|
|
"github.com/emochka2007/block-accounting/internal/usecase/interactors/chain"
|
2024-05-24 17:44:24 +00:00
|
|
|
"github.com/emochka2007/block-accounting/internal/usecase/interactors/jwt"
|
|
|
|
"github.com/emochka2007/block-accounting/internal/usecase/interactors/organizations"
|
|
|
|
"github.com/emochka2007/block-accounting/internal/usecase/interactors/transactions"
|
|
|
|
"github.com/emochka2007/block-accounting/internal/usecase/interactors/users"
|
|
|
|
"github.com/emochka2007/block-accounting/internal/usecase/repository/auth"
|
|
|
|
"github.com/emochka2007/block-accounting/internal/usecase/repository/cache"
|
|
|
|
orepo "github.com/emochka2007/block-accounting/internal/usecase/repository/organizations"
|
|
|
|
txRepo "github.com/emochka2007/block-accounting/internal/usecase/repository/transactions"
|
|
|
|
urepo "github.com/emochka2007/block-accounting/internal/usecase/repository/users"
|
|
|
|
)
|
|
|
|
|
|
|
|
func provideUsersInteractor(
|
|
|
|
log *slog.Logger,
|
|
|
|
usersRepo urepo.Repository,
|
2024-05-25 13:00:21 +00:00
|
|
|
chainInteractor chain.ChainInteractor,
|
2024-05-24 17:44:24 +00:00
|
|
|
) users.UsersInteractor {
|
2024-05-25 13:00:21 +00:00
|
|
|
return users.NewUsersInteractor(log.WithGroup("users-interactor"), usersRepo, chainInteractor)
|
2024-05-24 17:44:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func provideJWTInteractor(
|
|
|
|
c config.Config,
|
|
|
|
usersInteractor users.UsersInteractor,
|
|
|
|
authRepository auth.Repository,
|
|
|
|
) jwt.JWTInteractor {
|
|
|
|
return jwt.NewJWT(c.Common.JWTSecret, usersInteractor, authRepository)
|
|
|
|
}
|
|
|
|
|
|
|
|
func provideOrganizationsInteractor(
|
|
|
|
log *slog.Logger,
|
|
|
|
orgRepo orepo.Repository,
|
|
|
|
cache cache.Cache,
|
|
|
|
) organizations.OrganizationsInteractor {
|
|
|
|
return organizations.NewOrganizationsInteractor(log, orgRepo, cache)
|
|
|
|
}
|
|
|
|
|
|
|
|
func provideTxInteractor(
|
|
|
|
log *slog.Logger,
|
|
|
|
txRepo txRepo.Repository,
|
|
|
|
orgInteractor organizations.OrganizationsInteractor,
|
2024-05-27 21:29:05 +00:00
|
|
|
chainInteractor chain.ChainInteractor,
|
2024-05-24 17:44:24 +00:00
|
|
|
) transactions.TransactionsInteractor {
|
|
|
|
return transactions.NewTransactionsInteractor(
|
|
|
|
log.WithGroup("transaction-interactor"),
|
|
|
|
txRepo,
|
|
|
|
orgInteractor,
|
2024-05-27 21:29:05 +00:00
|
|
|
chainInteractor,
|
2024-05-24 17:44:24 +00:00
|
|
|
)
|
|
|
|
}
|
2024-05-25 13:00:21 +00:00
|
|
|
|
|
|
|
func provideChainInteractor(
|
|
|
|
log *slog.Logger,
|
|
|
|
config config.Config,
|
|
|
|
txRepository txRepo.Repository,
|
|
|
|
) chain.ChainInteractor {
|
|
|
|
return chain.NewChainInteractor(log, config, txRepository)
|
|
|
|
}
|