customer/internal/initialize/services.go

77 lines
2.6 KiB
Go
Raw Normal View History

2023-05-16 01:12:07 +00:00
package initialize
import (
2023-05-17 20:27:09 +00:00
"go.uber.org/zap"
2023-06-13 16:09:17 +00:00
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
2023-05-17 20:27:09 +00:00
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/account"
2023-06-13 19:20:11 +00:00
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/callback"
2023-05-19 07:21:45 +00:00
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/cart"
2023-05-19 04:50:40 +00:00
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/currency"
2023-05-23 15:33:23 +00:00
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/history"
2023-06-13 16:09:17 +00:00
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/payment"
2023-05-23 15:42:22 +00:00
"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/service/wallet"
2023-05-16 01:12:07 +00:00
)
type ServicesDeps struct {
2023-06-13 16:09:17 +00:00
Logger *zap.Logger
Repositories *Repositories
Clients *Clients
ConfigurationGRPC *models.ConfigurationGRPC
2023-05-16 01:12:07 +00:00
}
type Services struct {
2023-06-13 19:20:11 +00:00
AccountService *account.Service
CurrencyService *currency.Service
CartService *cart.Service
HistoryService *history.Service
WalletService *wallet.Service
PaymentService *payment.Service
PaymentCallbackService *callback.PaymentCallbackService
2023-05-16 01:12:07 +00:00
}
2023-06-13 22:51:34 +00:00
func NewServices(deps ServicesDeps) *Services {
walletService := wallet.New(wallet.Deps{
2023-05-30 11:33:57 +00:00
Logger: deps.Logger,
Repository: deps.Repositories.AccountRepository,
CurrencyClient: deps.Clients.CurrencyClient,
})
2023-06-13 19:20:11 +00:00
historyService := history.New(history.Deps{
Logger: deps.Logger,
Repository: deps.Repositories.HistoryRepository,
})
2023-05-17 20:27:09 +00:00
return &Services{
2023-06-13 19:20:11 +00:00
WalletService: walletService,
HistoryService: historyService,
2023-06-14 17:28:43 +00:00
AccountService: account.New(account.Deps{
2023-05-17 20:27:09 +00:00
Logger: deps.Logger,
Repository: deps.Repositories.AccountRepository,
AuthClient: deps.Clients.AuthClient,
2023-05-17 20:27:09 +00:00
}),
2023-06-14 17:28:43 +00:00
CurrencyService: currency.New(currency.Deps{
2023-05-19 04:50:40 +00:00
Logger: deps.Logger,
Repository: deps.Repositories.CurrencyRepository,
}),
2023-06-13 19:33:40 +00:00
CartService: cart.New(cart.Deps{
2023-05-19 09:08:15 +00:00
Logger: deps.Logger,
Repository: deps.Repositories.AccountRepository,
HubadminClient: deps.Clients.HubadminClient,
2023-05-30 11:33:57 +00:00
DiscountClient: deps.Clients.DiscountClient,
WalletService: walletService,
2023-05-19 07:21:45 +00:00
}),
2023-06-13 16:09:17 +00:00
PaymentService: payment.New(payment.Deps{
Logger: deps.Logger,
ConfigurationGRPC: deps.ConfigurationGRPC,
PaymentClient: deps.Clients.PaymentClient,
AuthClient: deps.Clients.AuthClient,
}),
2023-06-13 19:20:11 +00:00
PaymentCallbackService: callback.NewPaymentCallbackService(callback.PaymentCallbackServiceDeps{
Logger: deps.Logger,
AccountRepository: deps.Repositories.AccountRepository,
WalletService: walletService,
HistoryService: historyService,
}),
2023-05-17 20:27:09 +00:00
}
2023-05-16 01:12:07 +00:00
}