generated from PenaSide/GolangTemplate
work with cfg
This commit is contained in:
parent
4533cd318b
commit
9e3136bd41
@ -29,13 +29,13 @@ services:
|
|||||||
- KAFKA_BROKERS=10.8.0.6:9092
|
- KAFKA_BROKERS=10.8.0.6:9092
|
||||||
- KAFKA_TOPIC_TARIFF=tariffs
|
- KAFKA_TOPIC_TARIFF=tariffs
|
||||||
|
|
||||||
- AUTH_MICROSERVICE_USER_URL=http://10.8.0.6:59300/user
|
- AUTH_MICROSERVICE_URL=http://10.8.0.6:59300
|
||||||
- HUBADMIN_MICROSERVICE_TARIFF_URL=http://10.8.0.6:59303/tariff
|
- HUBADMIN_MICROSERVICE_URL=http://10.8.0.6:59303
|
||||||
- CURRENCY_MICROSERVICE_TRANSLATE_URL=http://10.8.0.6:3131/change
|
- CURRENCY_MICROSERVICE_URL=http://10.8.0.6:3131
|
||||||
- DISCOUNT_MICROSERVICE_GRPC_HOST=10.8.0.6:9001
|
- DISCOUNT_MICROSERVICE_GRPC_HOST=10.8.0.6:9001
|
||||||
- PAYMENT_MICROSERVICE_GRPC_HOST=10.8.0.6:9085
|
- PAYMENT_MICROSERVICE_GRPC_HOST=10.8.0.6:9085
|
||||||
- VERIFICATION_MICROSERVICE_USER_URL=http://10.8.0.6:7036/verification
|
- VERIFICATION_MICROSERVICE_URL=http://10.8.0.6:7036
|
||||||
- TEMPLATEGEN_MICROSERVICE_URL=http://10.6.0.17/generator/service
|
- TEMPLATEGEN_MICROSERVICE_URL=http://10.6.0.17
|
||||||
- API_URL=https://api.smtp.bz/v1/smtp/send
|
- API_URL=https://api.smtp.bz/v1/smtp/send
|
||||||
- CODEWORD_MICROSERVICE_GRPC_HOST=10.8.0.6:59665
|
- CODEWORD_MICROSERVICE_GRPC_HOST=10.8.0.6:59665
|
||||||
- MAIL_SENDER=noreply@mailing.pena.digital
|
- MAIL_SENDER=noreply@mailing.pena.digital
|
||||||
|
@ -48,7 +48,7 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
clickHouseLogger, err := zaptrashlog.NewCore(ctx, zap.InfoLevel, config.Service.TrashLogHost, build.Version, build.Commit, build.BuildTime)
|
clickHouseLogger, err := zaptrashlog.NewCore(ctx, zap.InfoLevel, config.TrashLogHost, build.Version, build.Commit, build.BuildTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -57,12 +57,12 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
return zapcore.NewTee(core, clickHouseLogger)
|
return zapcore.NewTee(core, clickHouseLogger)
|
||||||
}), zap.AddCallerSkip(2))
|
}), zap.AddCallerSkip(2))
|
||||||
|
|
||||||
loggerHlog := hlog.New(loggerForHlog).Module(config.Service.ModuleLogger)
|
loggerHlog := hlog.New(loggerForHlog).Module(config.ModuleLogger)
|
||||||
loggerHlog.With(models.AllFields{})
|
loggerHlog.With(models.AllFields{})
|
||||||
loggerHlog.Emit(app.InfoSvcStarted{})
|
loggerHlog.Emit(app.InfoSvcStarted{})
|
||||||
|
|
||||||
if err = kafka.Initialize(ctx, config.Service.Kafka.Brokers, []string{
|
if err = kafka.Initialize(ctx, config.KafkaBrokers, []string{
|
||||||
config.Service.Kafka.Tariff.Topic,
|
config.KafkaTopic,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return fmt.Errorf("failed initialize kafka: %w", err)
|
return fmt.Errorf("failed initialize kafka: %w", err)
|
||||||
}
|
}
|
||||||
@ -76,10 +76,10 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
kafkaTariffClient, err := kgo.NewClient(
|
kafkaTariffClient, err := kgo.NewClient(
|
||||||
kgo.SeedBrokers(config.Service.Kafka.Brokers...),
|
kgo.SeedBrokers(config.KafkaBrokers...),
|
||||||
kgo.ConsumeResetOffset(kgo.NewOffset().AtStart()),
|
kgo.ConsumeResetOffset(kgo.NewOffset().AtStart()),
|
||||||
kgo.DefaultProduceTopic(config.Service.Kafka.Tariff.Topic),
|
kgo.DefaultProduceTopic(config.KafkaTopic),
|
||||||
kgo.ConsumeTopics(config.Service.Kafka.Tariff.Topic),
|
kgo.ConsumeTopics(config.KafkaTopic),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -96,7 +96,7 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
notificationBot, err := tb.NewBot(tb.Settings{
|
notificationBot, err := tb.NewBot(tb.Settings{
|
||||||
Token: config.Service.NotificationBotToken,
|
Token: config.NotificationBotToken,
|
||||||
Verbose: false,
|
Verbose: false,
|
||||||
ParseMode: tb.ModeHTML,
|
ParseMode: tb.ModeHTML,
|
||||||
Poller: &tb.LongPoller{
|
Poller: &tb.LongPoller{
|
||||||
@ -109,18 +109,18 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
clients := initialize.NewClients(initialize.ClientsDeps{
|
clients := initialize.NewClients(initialize.ClientsDeps{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
AuthURL: &config.Service.AuthMicroservice.URL,
|
AuthURL: config.AuthMicroservice,
|
||||||
HubadminURL: &config.Service.HubadminMicroservice.URL,
|
HubadminURL: config.HubadminMicroservice,
|
||||||
CurrencyURL: &config.Service.CurrencyMicroservice.URL,
|
CurrencyURL: config.CurrencyMicroservice,
|
||||||
DiscountServiceConfiguration: &config.Service.DiscountMicroservice,
|
DiscountServiceURL: config.DiscountMicroservice,
|
||||||
PaymentServiceConfiguration: &config.Service.PaymentMicroservice,
|
PaymentServiceURL: config.PaymentMicroservice,
|
||||||
VerificationURL: &config.Service.VerificationMicroservice.URL,
|
VerificationURL: config.VerificationMicroservice,
|
||||||
TemplategenURL: &config.Service.TemplategenMicroserviceURL.URL,
|
TemplategenURL: config.TemplategenMicroserviceURL,
|
||||||
MailClient: &config.Service.Mail,
|
MailClient: config.MailClientCfg,
|
||||||
CodewordServiceHost: &config.Service.CodewordMicroservice,
|
CodewordServiceHost: config.CodewordMicroservice,
|
||||||
Notifier: notificationBot,
|
Notifier: notificationBot,
|
||||||
NotificationRsPayChannel: config.Service.NotificationRsPayChannel,
|
NotificationRsPayChannel: config.NotificationRsPayChannel,
|
||||||
})
|
})
|
||||||
|
|
||||||
repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
|
repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
|
||||||
@ -132,11 +132,10 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
Logger: logger,
|
Logger: logger,
|
||||||
Repositories: repositories,
|
Repositories: repositories,
|
||||||
Clients: clients,
|
Clients: clients,
|
||||||
ConfigurationGRPC: &config.GRPC,
|
|
||||||
Brokers: brokers,
|
Brokers: brokers,
|
||||||
Notifier: notificationBot,
|
Notifier: notificationBot,
|
||||||
NotificationChannel: config.Service.NotificationChannel,
|
NotificationChannel: config.NotificationChannel,
|
||||||
AdminURL: config.Service.AdminURL,
|
AdminURL: config.AdminURL,
|
||||||
})
|
})
|
||||||
|
|
||||||
rpcControllers := initialize.NewRpcControllers(initialize.RpcControllersDeps{
|
rpcControllers := initialize.NewRpcControllers(initialize.RpcControllersDeps{
|
||||||
@ -153,7 +152,7 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
Logger: logger,
|
Logger: logger,
|
||||||
Encrypt: encrypt,
|
Encrypt: encrypt,
|
||||||
Producer: brokers.TariffProducer,
|
Producer: brokers.TariffProducer,
|
||||||
GRPC: &config.GRPC,
|
GRPCDomain: config.GrpcDomen,
|
||||||
Repositories: repositories,
|
Repositories: repositories,
|
||||||
Clients: clients,
|
Clients: clients,
|
||||||
MiddleWare: middleWare,
|
MiddleWare: middleWare,
|
||||||
@ -163,14 +162,14 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
Logger: logger,
|
Logger: logger,
|
||||||
Hlog: loggerHlog,
|
Hlog: loggerHlog,
|
||||||
Controllers: []server.Controller{httpControllers.CurrencyClientController, httpControllers.HistoryClientController, httpControllers.CartClientController, httpControllers.WalletClientController, httpControllers.AccountClientController},
|
Controllers: []server.Controller{httpControllers.CurrencyClientController, httpControllers.HistoryClientController, httpControllers.CartClientController, httpControllers.WalletClientController, httpControllers.AccountClientController},
|
||||||
JWTConfig: &config.Service.JWT,
|
JWTConfig: &config.JwtCfg,
|
||||||
})
|
})
|
||||||
|
|
||||||
serverAdminHTTP := server.NewServer(server.ServerConfig{
|
serverAdminHTTP := server.NewServer(server.ServerConfig{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
Hlog: loggerHlog,
|
Hlog: loggerHlog,
|
||||||
Controllers: []server.Controller{httpControllers.AccountAdminController, httpControllers.CurrencyAdminController, httpControllers.HistoryAdminController},
|
Controllers: []server.Controller{httpControllers.AccountAdminController, httpControllers.CurrencyAdminController, httpControllers.HistoryAdminController},
|
||||||
JWTConfig: &config.Service.JWT,
|
JWTConfig: &config.JwtCfg,
|
||||||
})
|
})
|
||||||
|
|
||||||
serverClientHTTP.ListRoutes()
|
serverClientHTTP.ListRoutes()
|
||||||
@ -184,20 +183,20 @@ func Run(config *models.Config, logger *zap.Logger, build Build) (appErr error)
|
|||||||
serverGRPC.Register(rpcControllers)
|
serverGRPC.Register(rpcControllers)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := serverClientHTTP.Start(config.HTTP.ClientHost + ":" + config.HTTP.ClientPort); err != nil {
|
if err := serverClientHTTP.Start(config.ClientHttpHost + ":" + config.ClientHttpPort); err != nil {
|
||||||
logger.Error("Server external startup error", zap.Error(err))
|
logger.Error("Server external startup error", zap.Error(err))
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := serverAdminHTTP.Start(config.HTTP.AdminHost + ":" + config.HTTP.AdminPort); err != nil {
|
if err := serverAdminHTTP.Start(config.AdminHttpHost + ":" + config.AdminHttpPort); err != nil {
|
||||||
logger.Error("Server internal startup error", zap.Error(err))
|
logger.Error("Server internal startup error", zap.Error(err))
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go serverGRPC.Run(&config.GRPC)
|
go serverGRPC.Run(config.GrpcHost, config.GrpcPort)
|
||||||
|
|
||||||
closer.Add(mongoDB.Client().Disconnect)
|
closer.Add(mongoDB.Client().Disconnect)
|
||||||
closer.Add(serverClientHTTP.Shutdown)
|
closer.Add(serverClientHTTP.Shutdown)
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
package initialize
|
package initialize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"gopkg.in/tucnak/telebot.v2"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/client"
|
"gitea.pena/PenaSide/customer/internal/interface/client"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
"gopkg.in/tucnak/telebot.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClientsDeps struct {
|
type ClientsDeps struct {
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
AuthURL *models.AuthMicroserviceURL
|
AuthURL string
|
||||||
HubadminURL *models.HubadminMicroserviceURL
|
HubadminURL string
|
||||||
CurrencyURL *models.CurrencyMicroserviceURL
|
CurrencyURL string
|
||||||
DiscountServiceConfiguration *models.DiscountMicroserviceConfiguration
|
DiscountServiceURL string
|
||||||
PaymentServiceConfiguration *models.PaymentMicroserviceConfiguration
|
PaymentServiceURL string
|
||||||
VerificationURL *models.VerificationMicroserviceURL
|
VerificationURL string
|
||||||
TemplategenURL *models.TemplategenMicroserviceURL
|
TemplategenURL string
|
||||||
MailClient *models.MailConfiguration
|
MailClient models.MailClientCfg
|
||||||
CodewordServiceHost *models.CodewordMicroserviceConfiguration
|
CodewordServiceHost string
|
||||||
NotificationRsPayChannel int64
|
NotificationRsPayChannel int64
|
||||||
Notifier *telebot.Bot
|
Notifier *telebot.Bot
|
||||||
}
|
}
|
||||||
|
|
||||||
type Clients struct {
|
type Clients struct {
|
||||||
@ -40,48 +39,36 @@ func NewClients(deps ClientsDeps) *Clients {
|
|||||||
return &Clients{
|
return &Clients{
|
||||||
AuthClient: client.NewAuthClient(client.AuthClientDeps{
|
AuthClient: client.NewAuthClient(client.AuthClientDeps{
|
||||||
Logger: deps.Logger,
|
Logger: deps.Logger,
|
||||||
URLs: deps.AuthURL,
|
URL: deps.AuthURL,
|
||||||
}),
|
}),
|
||||||
HubadminClient: client.NewHubadminClient(client.HubadminClientDeps{
|
HubadminClient: client.NewHubadminClient(client.HubadminClientDeps{
|
||||||
Logger: deps.Logger,
|
Logger: deps.Logger,
|
||||||
URLs: deps.HubadminURL,
|
URL: deps.HubadminURL,
|
||||||
}),
|
}),
|
||||||
CurrencyClient: client.NewCurrencyClient(client.CurrencyClientDeps{
|
CurrencyClient: client.NewCurrencyClient(client.CurrencyClientDeps{
|
||||||
Logger: deps.Logger,
|
Logger: deps.Logger,
|
||||||
URLs: deps.CurrencyURL,
|
URL: deps.CurrencyURL,
|
||||||
}),
|
}),
|
||||||
DiscountClient: client.NewDiscountClient(client.DiscountClientDeps{
|
DiscountClient: client.NewDiscountClient(client.DiscountClientDeps{
|
||||||
Logger: deps.Logger,
|
Logger: deps.Logger,
|
||||||
DiscountServiceHost: deps.DiscountServiceConfiguration.HostGRPC,
|
DiscountServiceHost: deps.DiscountServiceURL,
|
||||||
}),
|
}),
|
||||||
PaymentClient: client.NewPaymentClient(client.PaymentClientDeps{
|
PaymentClient: client.NewPaymentClient(client.PaymentClientDeps{
|
||||||
Logger: deps.Logger,
|
Logger: deps.Logger,
|
||||||
PaymentServiceHost: deps.PaymentServiceConfiguration.HostGRPC,
|
PaymentServiceHost: deps.PaymentServiceURL,
|
||||||
}),
|
}),
|
||||||
VerificationClient: client.NewVerificationClient(client.VerificationClientDeps{
|
VerificationClient: client.NewVerificationClient(client.VerificationClientDeps{
|
||||||
Logger: deps.Logger,
|
Logger: deps.Logger,
|
||||||
URLs: deps.VerificationURL,
|
URL: deps.VerificationURL,
|
||||||
}),
|
}),
|
||||||
TemplateClient: client.NewTemplateClient(client.TemplateClientDeps{
|
TemplateClient: client.NewTemplateClient(client.TemplateClientDeps{
|
||||||
Logger: deps.Logger,
|
Logger: deps.Logger,
|
||||||
URLs: deps.TemplategenURL,
|
URL: deps.TemplategenURL,
|
||||||
}),
|
|
||||||
MailClient: client.NewMailClient(client.MailClientDeps{
|
|
||||||
Logger: deps.Logger,
|
|
||||||
ApiUrl: deps.MailClient.ApiUrl,
|
|
||||||
Sender: deps.MailClient.Sender,
|
|
||||||
Auth: &models.PlainAuth{
|
|
||||||
Identity: deps.MailClient.Auth.Identity,
|
|
||||||
Username: deps.MailClient.Auth.Username,
|
|
||||||
Password: deps.MailClient.Auth.Password,
|
|
||||||
},
|
|
||||||
ApiKey: deps.MailClient.ApiKey,
|
|
||||||
FiberClient: fiber.AcquireClient(),
|
|
||||||
MailAddress: deps.MailClient.MailAddress,
|
|
||||||
}),
|
}),
|
||||||
|
MailClient: client.NewMailClient(deps.MailClient, deps.Logger),
|
||||||
CodewordClient: client.NewCodewordClient(client.CodewordClientDeps{
|
CodewordClient: client.NewCodewordClient(client.CodewordClientDeps{
|
||||||
Logger: deps.Logger,
|
Logger: deps.Logger,
|
||||||
CodewordServiceHost: deps.CodewordServiceHost.HostGRPC,
|
CodewordServiceHost: deps.CodewordServiceHost,
|
||||||
}),
|
}),
|
||||||
TelegramClient: client.NewTelegramClient(client.TelegramClientDeps{
|
TelegramClient: client.NewTelegramClient(client.TelegramClientDeps{
|
||||||
Notifier: deps.Notifier,
|
Notifier: deps.Notifier,
|
||||||
|
@ -3,10 +3,9 @@ package initialize_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"gitea.pena/PenaSide/customer/internal/initialize"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"gitea.pena/PenaSide/customer/internal/initialize"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewClients(t *testing.T) {
|
func TestNewClients(t *testing.T) {
|
||||||
@ -15,14 +14,14 @@ func TestNewClients(t *testing.T) {
|
|||||||
|
|
||||||
assert.NotPanics(t, func() {
|
assert.NotPanics(t, func() {
|
||||||
clients := initialize.NewClients(initialize.ClientsDeps{
|
clients := initialize.NewClients(initialize.ClientsDeps{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
AuthURL: &models.AuthMicroserviceURL{},
|
AuthURL: "",
|
||||||
HubadminURL: &models.HubadminMicroserviceURL{},
|
HubadminURL: "",
|
||||||
CurrencyURL: &models.CurrencyMicroserviceURL{},
|
CurrencyURL: "",
|
||||||
DiscountServiceConfiguration: &models.DiscountMicroserviceConfiguration{HostGRPC: "host"},
|
DiscountServiceURL: "",
|
||||||
PaymentServiceConfiguration: &models.PaymentMicroserviceConfiguration{HostGRPC: "host"},
|
PaymentServiceURL: "",
|
||||||
VerificationURL: &models.VerificationMicroserviceURL{Verification: ""},
|
VerificationURL: "",
|
||||||
TemplategenURL: &models.TemplategenMicroserviceURL{Templategen: ""},
|
TemplategenURL: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.NotNil(t, clients)
|
assert.NotNil(t, clients)
|
||||||
|
@ -3,10 +3,9 @@ package initialize
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang-jwt/jwt/v5"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"gitea.pena/PenaSide/customer/internal/utils"
|
|
||||||
"gitea.pena/PenaSide/customer/pkg/env"
|
"gitea.pena/PenaSide/customer/pkg/env"
|
||||||
|
"github.com/golang-jwt/jwt/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: обработать возможность читать конфиги ещё по json
|
// TODO: обработать возможность читать конфиги ещё по json
|
||||||
@ -17,11 +16,11 @@ func Configuration(path string) (*models.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.ValidateConfigurationURLs(&config.Service); err != nil {
|
//if err := utils.ValidateConfigurationURLs(&config.Service); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
//}
|
||||||
|
|
||||||
iniJWTConfiguration(&config.Service.JWT)
|
iniJWTConfiguration(&config.JwtCfg)
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gitea.pena/PenaSide/customer/internal/initialize"
|
||||||
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo"
|
"penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo"
|
||||||
"gitea.pena/PenaSide/customer/internal/initialize"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConfiguration(t *testing.T) {
|
func TestConfiguration(t *testing.T) {
|
||||||
@ -48,68 +48,36 @@ func TestConfiguration(t *testing.T) {
|
|||||||
func setDefaultTestingENV(t *testing.T) *models.Config {
|
func setDefaultTestingENV(t *testing.T) *models.Config {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
defaultAuthURL := models.AuthMicroserviceURL{
|
defaultAuthURL := "http://www.auth.ru/user"
|
||||||
User: "http://www.auth.ru/user",
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultHubAdminURL := models.HubadminMicroserviceURL{
|
defaultHubAdminURL := "http://www.hubadmin.ru/tariff"
|
||||||
Tariff: "http://www.hubadmin.ru/tariff",
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultCurrencyURL := models.CurrencyMicroserviceURL{
|
defaultCurrencyURL := "http://www.currency.ru/change"
|
||||||
Translate: "http://www.currency.ru/change",
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultConfiguration := models.Config{
|
defaultConfiguration := models.Config{
|
||||||
HTTP: models.ConfigurationHTTP{
|
ClientHttpHost: "localhost",
|
||||||
ClientHost: "localhost",
|
ClientHttpPort: "8080",
|
||||||
ClientPort: "8080",
|
AdminHttpHost: "localhost",
|
||||||
AdminHost: "localhost",
|
AdminHttpPort: "8081",
|
||||||
AdminPort: "8081",
|
GrpcHost: "localhost",
|
||||||
},
|
GrpcPort: "8081",
|
||||||
GRPC: models.ConfigurationGRPC{
|
GrpcDomen: "domen",
|
||||||
Host: "localhost",
|
AuthMicroservice: defaultAuthURL,
|
||||||
Port: "8081",
|
KafkaTopic: "topic",
|
||||||
Domen: "domen",
|
KafkaBrokers: []string{"localhost:8080", "localhost:8081"},
|
||||||
},
|
HubadminMicroservice: defaultHubAdminURL,
|
||||||
Service: models.ServiceConfiguration{
|
CurrencyMicroservice: defaultCurrencyURL,
|
||||||
AuthMicroservice: models.AuthMicroserviceConfiguration{
|
DiscountMicroservice: "domen",
|
||||||
URL: defaultAuthURL,
|
PaymentMicroservice: "domen",
|
||||||
},
|
VerificationMicroservice: "domen",
|
||||||
Kafka: models.KafkaConfiguration{
|
TemplategenMicroserviceURL: "domen",
|
||||||
Tariff: models.TariffKafkaConfiguration{Topic: "topic"},
|
JwtCfg: models.JWTConfiguration{
|
||||||
Brokers: []string{"localhost:8080", "localhost:8081"},
|
PrivateKey: "jwt private key",
|
||||||
},
|
PublicKey: "jwt public key",
|
||||||
HubadminMicroservice: models.HubadminMicroserviceConfiguration{
|
Issuer: "issuer",
|
||||||
URL: defaultHubAdminURL,
|
Audience: "audience",
|
||||||
},
|
Algorithm: *jwt.SigningMethodRS256,
|
||||||
CurrencyMicroservice: models.CurrencyMicroserviceConfiguration{
|
ExpiresIn: 15 * time.Minute,
|
||||||
URL: defaultCurrencyURL,
|
|
||||||
},
|
|
||||||
DiscountMicroservice: models.DiscountMicroserviceConfiguration{
|
|
||||||
HostGRPC: "domen",
|
|
||||||
},
|
|
||||||
PaymentMicroservice: models.PaymentMicroserviceConfiguration{
|
|
||||||
HostGRPC: "domen",
|
|
||||||
},
|
|
||||||
VerificationMicroservice: models.VerificationMicroserviceConfiguration{
|
|
||||||
URL: models.VerificationMicroserviceURL{
|
|
||||||
Verification: "domen",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
TemplategenMicroserviceURL: models.TemplategenMicroserviceConfiguration{
|
|
||||||
URL: models.TemplategenMicroserviceURL{
|
|
||||||
Templategen: "domen",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
JWT: models.JWTConfiguration{
|
|
||||||
PrivateKey: "jwt private key",
|
|
||||||
PublicKey: "jwt public key",
|
|
||||||
Issuer: "issuer",
|
|
||||||
Audience: "audience",
|
|
||||||
Algorithm: *jwt.SigningMethodRS256,
|
|
||||||
ExpiresIn: 15 * time.Minute,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Database: mongo.Configuration{
|
Database: mongo.Configuration{
|
||||||
Host: "localhost",
|
Host: "localhost",
|
||||||
@ -121,25 +89,25 @@ func setDefaultTestingENV(t *testing.T) *models.Config {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Setenv("GRPC_HOST", defaultConfiguration.GRPC.Host)
|
t.Setenv("GRPC_HOST", defaultConfiguration.GrpcHost)
|
||||||
t.Setenv("GRPC_PORT", defaultConfiguration.GRPC.Port)
|
t.Setenv("GRPC_PORT", defaultConfiguration.GrpcPort)
|
||||||
t.Setenv("GRPC_DOMEN", defaultConfiguration.GRPC.Domen)
|
t.Setenv("GRPC_DOMEN", defaultConfiguration.GrpcDomen)
|
||||||
|
|
||||||
t.Setenv("JWT_PUBLIC_KEY", defaultConfiguration.Service.JWT.PublicKey)
|
t.Setenv("JWT_PUBLIC_KEY", defaultConfiguration.JwtCfg.PublicKey)
|
||||||
t.Setenv("JWT_PRIVATE_KEY", defaultConfiguration.Service.JWT.PrivateKey)
|
t.Setenv("JWT_PRIVATE_KEY", defaultConfiguration.JwtCfg.PrivateKey)
|
||||||
t.Setenv("JWT_ISSUER", defaultConfiguration.Service.JWT.Issuer)
|
t.Setenv("JWT_ISSUER", defaultConfiguration.JwtCfg.Issuer)
|
||||||
t.Setenv("JWT_AUDIENCE", defaultConfiguration.Service.JWT.Audience)
|
t.Setenv("JWT_AUDIENCE", defaultConfiguration.JwtCfg.Audience)
|
||||||
|
|
||||||
t.Setenv("KAFKA_BROKERS", "localhost:8080,localhost:8081")
|
t.Setenv("KAFKA_BROKERS", "localhost:8080,localhost:8081")
|
||||||
t.Setenv("KAFKA_TOPIC_TARIFF", defaultConfiguration.Service.Kafka.Tariff.Topic)
|
t.Setenv("KAFKA_TOPIC_TARIFF", defaultConfiguration.KafkaTopic)
|
||||||
|
|
||||||
t.Setenv("AUTH_MICROSERVICE_USER_URL", defaultConfiguration.Service.AuthMicroservice.URL.User)
|
t.Setenv("AUTH_MICROSERVICE_URL", defaultConfiguration.AuthMicroservice)
|
||||||
t.Setenv("HUBADMIN_MICROSERVICE_TARIFF_URL", defaultConfiguration.Service.HubadminMicroservice.URL.Tariff)
|
t.Setenv("HUBADMIN_MICROSERVICE_URL", defaultConfiguration.HubadminMicroservice)
|
||||||
t.Setenv("CURRENCY_MICROSERVICE_TRANSLATE_URL", defaultConfiguration.Service.CurrencyMicroservice.URL.Translate)
|
t.Setenv("CURRENCY_MICROSERVICE_URL", defaultConfiguration.CurrencyMicroservice)
|
||||||
t.Setenv("DISCOUNT_MICROSERVICE_GRPC_HOST", defaultConfiguration.Service.DiscountMicroservice.HostGRPC)
|
t.Setenv("DISCOUNT_MICROSERVICE_GRPC_HOST", defaultConfiguration.DiscountMicroservice)
|
||||||
t.Setenv("PAYMENT_MICROSERVICE_GRPC_HOST", defaultConfiguration.Service.PaymentMicroservice.HostGRPC)
|
t.Setenv("PAYMENT_MICROSERVICE_GRPC_HOST", defaultConfiguration.PaymentMicroservice)
|
||||||
t.Setenv("VERIFICATION_MICROSERVICE_USER_URL", defaultConfiguration.Service.VerificationMicroservice.URL.Verification)
|
t.Setenv("VERIFICATION_MICROSERVICE_URL", defaultConfiguration.VerificationMicroservice)
|
||||||
t.Setenv("TEMPLATEGEN_MICROSERVICE_URL", defaultConfiguration.Service.TemplategenMicroserviceURL.URL.Templategen)
|
t.Setenv("TEMPLATEGEN_MICROSERVICE_URL", defaultConfiguration.TemplategenMicroserviceURL)
|
||||||
|
|
||||||
t.Setenv("MONGO_HOST", defaultConfiguration.Database.Host)
|
t.Setenv("MONGO_HOST", defaultConfiguration.Database.Host)
|
||||||
t.Setenv("MONGO_PORT", defaultConfiguration.Database.Port)
|
t.Setenv("MONGO_PORT", defaultConfiguration.Database.Port)
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package initialize
|
package initialize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/themakers/hlog"
|
|
||||||
"go.uber.org/zap"
|
|
||||||
qutils "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/utils"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/broker/tariff"
|
"gitea.pena/PenaSide/customer/internal/interface/broker/tariff"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/controller/grpc/customer"
|
"gitea.pena/PenaSide/customer/internal/interface/controller/grpc/customer"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/controller/grpc/payment"
|
"gitea.pena/PenaSide/customer/internal/interface/controller/grpc/payment"
|
||||||
@ -16,7 +13,9 @@ import (
|
|||||||
"gitea.pena/PenaSide/customer/internal/interface/controller/http/history_admin"
|
"gitea.pena/PenaSide/customer/internal/interface/controller/http/history_admin"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/controller/http/history_client"
|
"gitea.pena/PenaSide/customer/internal/interface/controller/http/history_client"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/controller/http/wallet_client"
|
"gitea.pena/PenaSide/customer/internal/interface/controller/http/wallet_client"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"github.com/themakers/hlog"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
qutils "penahub.gitlab.yandexcloud.net/backend/quiz/common.git/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RpcControllersDeps struct {
|
type RpcControllersDeps struct {
|
||||||
@ -49,7 +48,7 @@ func NewRpcControllers(deps RpcControllersDeps) *RpcControllers {
|
|||||||
type HttpControllersDeps struct {
|
type HttpControllersDeps struct {
|
||||||
Encrypt *qutils.Encrypt
|
Encrypt *qutils.Encrypt
|
||||||
Producer *tariff.Producer
|
Producer *tariff.Producer
|
||||||
GRPC *models.ConfigurationGRPC
|
GRPCDomain string
|
||||||
MiddleWare *http.MiddleWare
|
MiddleWare *http.MiddleWare
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
Repositories *Repositories
|
Repositories *Repositories
|
||||||
@ -126,7 +125,7 @@ func NewHttpControllers(deps HttpControllersDeps) *HttpController {
|
|||||||
MiddleWare: deps.MiddleWare,
|
MiddleWare: deps.MiddleWare,
|
||||||
AuthClient: deps.Clients.AuthClient,
|
AuthClient: deps.Clients.AuthClient,
|
||||||
PaymentClient: deps.Clients.PaymentClient,
|
PaymentClient: deps.Clients.PaymentClient,
|
||||||
GRPC: deps.GRPC,
|
GRPCDomain: deps.GRPCDomain,
|
||||||
AccountRepo: deps.Repositories.AccountRepository,
|
AccountRepo: deps.Repositories.AccountRepository,
|
||||||
CurrencyClient: deps.Clients.CurrencyClient,
|
CurrencyClient: deps.Clients.CurrencyClient,
|
||||||
VerifyClient: deps.Clients.VerificationClient,
|
VerifyClient: deps.Clients.VerificationClient,
|
||||||
|
@ -3,11 +3,10 @@ package initialize_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"gitea.pena/PenaSide/customer/internal/initialize"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.mongodb.org/mongo-driver/mongo/integration/mtest"
|
"go.mongodb.org/mongo-driver/mongo/integration/mtest"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"gitea.pena/PenaSide/customer/internal/initialize"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewControllers(t *testing.T) {
|
func TestNewControllers(t *testing.T) {
|
||||||
@ -18,14 +17,14 @@ func TestNewControllers(t *testing.T) {
|
|||||||
|
|
||||||
assert.NotPanics(t, func() {
|
assert.NotPanics(t, func() {
|
||||||
clients := initialize.NewClients(initialize.ClientsDeps{
|
clients := initialize.NewClients(initialize.ClientsDeps{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
AuthURL: &models.AuthMicroserviceURL{},
|
AuthURL: "",
|
||||||
HubadminURL: &models.HubadminMicroserviceURL{},
|
HubadminURL: "",
|
||||||
CurrencyURL: &models.CurrencyMicroserviceURL{},
|
CurrencyURL: "",
|
||||||
DiscountServiceConfiguration: &models.DiscountMicroserviceConfiguration{HostGRPC: "host"},
|
DiscountServiceURL: "host",
|
||||||
PaymentServiceConfiguration: &models.PaymentMicroserviceConfiguration{HostGRPC: "host"},
|
PaymentServiceURL: "host",
|
||||||
VerificationURL: &models.VerificationMicroserviceURL{Verification: ""},
|
VerificationURL: "",
|
||||||
TemplategenURL: &models.TemplategenMicroserviceURL{Templategen: ""},
|
TemplategenURL: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
|
repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package initialize
|
package initialize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.uber.org/zap"
|
|
||||||
tb "gopkg.in/tucnak/telebot.v2"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/service/broker/tariff"
|
"gitea.pena/PenaSide/customer/internal/service/broker/tariff"
|
||||||
"gitea.pena/PenaSide/customer/internal/service/callback"
|
"gitea.pena/PenaSide/customer/internal/service/callback"
|
||||||
"gitea.pena/PenaSide/customer/internal/service/history"
|
"gitea.pena/PenaSide/customer/internal/service/history"
|
||||||
"gitea.pena/PenaSide/customer/internal/service/wallet"
|
"gitea.pena/PenaSide/customer/internal/service/wallet"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
tb "gopkg.in/tucnak/telebot.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServicesDeps struct {
|
type ServicesDeps struct {
|
||||||
@ -15,7 +14,6 @@ type ServicesDeps struct {
|
|||||||
Repositories *Repositories
|
Repositories *Repositories
|
||||||
Clients *Clients
|
Clients *Clients
|
||||||
Brokers *Brokers
|
Brokers *Brokers
|
||||||
ConfigurationGRPC *models.ConfigurationGRPC
|
|
||||||
Notifier *tb.Bot
|
Notifier *tb.Bot
|
||||||
NotificationChannel int64
|
NotificationChannel int64
|
||||||
AdminURL string
|
AdminURL string
|
||||||
|
@ -3,12 +3,11 @@ package initialize_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"gitea.pena/PenaSide/customer/internal/initialize"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/twmb/franz-go/pkg/kgo"
|
"github.com/twmb/franz-go/pkg/kgo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/integration/mtest"
|
"go.mongodb.org/mongo-driver/mongo/integration/mtest"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"gitea.pena/PenaSide/customer/internal/initialize"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewServices(t *testing.T) {
|
func TestNewServices(t *testing.T) {
|
||||||
@ -19,14 +18,14 @@ func TestNewServices(t *testing.T) {
|
|||||||
|
|
||||||
assert.NotPanics(t, func() {
|
assert.NotPanics(t, func() {
|
||||||
clients := initialize.NewClients(initialize.ClientsDeps{
|
clients := initialize.NewClients(initialize.ClientsDeps{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
AuthURL: &models.AuthMicroserviceURL{},
|
AuthURL: "",
|
||||||
HubadminURL: &models.HubadminMicroserviceURL{},
|
HubadminURL: "",
|
||||||
CurrencyURL: &models.CurrencyMicroserviceURL{},
|
CurrencyURL: "",
|
||||||
DiscountServiceConfiguration: &models.DiscountMicroserviceConfiguration{HostGRPC: "host"},
|
DiscountServiceURL: "host",
|
||||||
PaymentServiceConfiguration: &models.PaymentMicroserviceConfiguration{HostGRPC: "host"},
|
PaymentServiceURL: "host",
|
||||||
VerificationURL: &models.VerificationMicroserviceURL{Verification: ""},
|
VerificationURL: "",
|
||||||
TemplategenURL: &models.TemplategenMicroserviceURL{Templategen: ""},
|
TemplategenURL: "",
|
||||||
})
|
})
|
||||||
|
|
||||||
brokers := initialize.NewBrokers(initialize.BrokersDeps{
|
brokers := initialize.NewBrokers(initialize.BrokersDeps{
|
||||||
@ -40,11 +39,10 @@ func TestNewServices(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
services := initialize.NewServices(initialize.ServicesDeps{
|
services := initialize.NewServices(initialize.ServicesDeps{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
Clients: clients,
|
Clients: clients,
|
||||||
Repositories: repositories,
|
Repositories: repositories,
|
||||||
Brokers: brokers,
|
Brokers: brokers,
|
||||||
ConfigurationGRPC: &models.ConfigurationGRPC{Domen: "http://test:8080"},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.NotNil(t, services)
|
assert.NotNil(t, services)
|
||||||
|
@ -6,34 +6,34 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"gitea.pena/PenaSide/customer/internal/utils"
|
"gitea.pena/PenaSide/customer/internal/utils"
|
||||||
"gitea.pena/PenaSide/customer/pkg/client"
|
"gitea.pena/PenaSide/customer/pkg/client"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthClientDeps struct {
|
type AuthClientDeps struct {
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
URLs *models.AuthMicroserviceURL
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthClient struct {
|
type AuthClient struct {
|
||||||
urls *models.AuthMicroserviceURL
|
url string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAuthClient(deps AuthClientDeps) *AuthClient {
|
func NewAuthClient(deps AuthClientDeps) *AuthClient {
|
||||||
if deps.URLs == nil {
|
if deps.URL == "" {
|
||||||
log.Panicln("urls is nil on <NewAuthClient>")
|
log.Panicln("url is nil on <NewAuthClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &AuthClient{
|
return &AuthClient{
|
||||||
urls: deps.URLs,
|
url: deps.URL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver *AuthClient) GetUser(ctx context.Context, userID string) (*models.User, errors.Error) {
|
func (receiver *AuthClient) GetUser(ctx context.Context, userID string) (*models.User, errors.Error) {
|
||||||
userURL, err := url.JoinPath(receiver.urls.User, userID)
|
userURL, err := url.JoinPath(fmt.Sprintf("%s/user", receiver.url), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(
|
return nil, errors.New(
|
||||||
fmt.Errorf("failed to join path on <GetUser> of <AuthClient>: %w", err),
|
fmt.Errorf("failed to join path on <GetUser> of <AuthClient>: %w", err),
|
||||||
|
@ -6,21 +6,21 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"gitea.pena/PenaSide/customer/internal/utils"
|
"gitea.pena/PenaSide/customer/internal/utils"
|
||||||
"gitea.pena/PenaSide/customer/pkg/client"
|
"gitea.pena/PenaSide/customer/pkg/client"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CurrencyClientDeps struct {
|
type CurrencyClientDeps struct {
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
URLs *models.CurrencyMicroserviceURL
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type CurrencyClient struct {
|
type CurrencyClient struct {
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
urls *models.CurrencyMicroserviceURL
|
url string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCurrencyClient(deps CurrencyClientDeps) *CurrencyClient {
|
func NewCurrencyClient(deps CurrencyClientDeps) *CurrencyClient {
|
||||||
@ -28,19 +28,19 @@ func NewCurrencyClient(deps CurrencyClientDeps) *CurrencyClient {
|
|||||||
log.Panicln("logger is nil on <NewCurrencyClient>")
|
log.Panicln("logger is nil on <NewCurrencyClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.URLs == nil {
|
if deps.URL == "" {
|
||||||
log.Panicln("urls is nil on <NewCurrencyClient>")
|
log.Panicln("urls is nil on <NewCurrencyClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &CurrencyClient{
|
return &CurrencyClient{
|
||||||
logger: deps.Logger,
|
logger: deps.Logger,
|
||||||
urls: deps.URLs,
|
url: deps.URL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver *CurrencyClient) Translate(ctx context.Context, request *models.TranslateCurrency) (int64, errors.Error) {
|
func (receiver *CurrencyClient) Translate(ctx context.Context, request *models.TranslateCurrency) (int64, errors.Error) {
|
||||||
response, err := client.Get[models.CurrencyClientResponse[int64], models.CurrencyClientResponse[string]](ctx, &client.RequestSettings{
|
response, err := client.Get[models.CurrencyClientResponse[int64], models.CurrencyClientResponse[string]](ctx, &client.RequestSettings{
|
||||||
URL: receiver.urls.Translate,
|
URL: fmt.Sprintf("%s/change", receiver.url),
|
||||||
Headers: map[string]string{"Content-Type": "application/json"},
|
Headers: map[string]string{"Content-Type": "application/json"},
|
||||||
QueryParams: map[string]string{
|
QueryParams: map[string]string{
|
||||||
"currencyFrom": request.From,
|
"currencyFrom": request.From,
|
||||||
|
@ -6,21 +6,21 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"gitea.pena/PenaSide/customer/internal/utils"
|
"gitea.pena/PenaSide/customer/internal/utils"
|
||||||
"gitea.pena/PenaSide/customer/pkg/client"
|
"gitea.pena/PenaSide/customer/pkg/client"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HubadminClientDeps struct {
|
type HubadminClientDeps struct {
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
URLs *models.HubadminMicroserviceURL
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type HubadminClient struct {
|
type HubadminClient struct {
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
urls *models.HubadminMicroserviceURL
|
url string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHubadminClient(deps HubadminClientDeps) *HubadminClient {
|
func NewHubadminClient(deps HubadminClientDeps) *HubadminClient {
|
||||||
@ -28,18 +28,18 @@ func NewHubadminClient(deps HubadminClientDeps) *HubadminClient {
|
|||||||
log.Panicln("logger is nil on <NewHubadminClient>")
|
log.Panicln("logger is nil on <NewHubadminClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.URLs == nil {
|
if deps.URL == "" {
|
||||||
log.Panicln("urls is nil on <NewHubadminClient>")
|
log.Panicln("urls is nil on <NewHubadminClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &HubadminClient{
|
return &HubadminClient{
|
||||||
logger: deps.Logger,
|
logger: deps.Logger,
|
||||||
urls: deps.URLs,
|
url: deps.URL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver *HubadminClient) GetTariff(ctx context.Context, accessToken string, tariffID string) (*models.Tariff, errors.Error) {
|
func (receiver *HubadminClient) GetTariff(ctx context.Context, accessToken string, tariffID string) (*models.Tariff, errors.Error) {
|
||||||
tariffURL, err := url.JoinPath(receiver.urls.Tariff, tariffID)
|
tariffURL, err := url.JoinPath(fmt.Sprintf("%s/tariff", receiver.url), tariffID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(fmt.Errorf("failed to join path on <GetTariff> of <HubadminClient>: %w", err), errors.ErrInternalError)
|
return nil, errors.New(fmt.Errorf("failed to join path on <GetTariff> of <HubadminClient>: %w", err), errors.ErrInternalError)
|
||||||
}
|
}
|
||||||
|
@ -3,33 +3,35 @@ package client
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MailClientDeps struct {
|
|
||||||
ApiUrl string
|
|
||||||
Sender string
|
|
||||||
Auth *models.PlainAuth
|
|
||||||
ApiKey string
|
|
||||||
FiberClient *fiber.Client
|
|
||||||
Logger *zap.Logger
|
|
||||||
MailAddress string
|
|
||||||
}
|
|
||||||
|
|
||||||
type MailClient struct {
|
type MailClient struct {
|
||||||
deps MailClientDeps
|
apiUrl string
|
||||||
|
sender string
|
||||||
|
auth *models.PlainAuth
|
||||||
|
apiKey string
|
||||||
|
fiberClient *fiber.Client
|
||||||
|
logger *zap.Logger
|
||||||
|
mailAddress string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMailClient(deps MailClientDeps) *MailClient {
|
func NewMailClient(deps models.MailClientCfg, logger *zap.Logger) *MailClient {
|
||||||
if deps.FiberClient == nil {
|
if deps.FiberClient == nil {
|
||||||
deps.FiberClient = fiber.AcquireClient()
|
deps.FiberClient = fiber.AcquireClient()
|
||||||
}
|
}
|
||||||
return &MailClient{
|
return &MailClient{
|
||||||
deps: deps,
|
apiUrl: deps.ApiUrl,
|
||||||
|
sender: deps.Sender,
|
||||||
|
auth: deps.Auth,
|
||||||
|
apiKey: deps.ApiKey,
|
||||||
|
fiberClient: deps.FiberClient,
|
||||||
|
logger: logger,
|
||||||
|
mailAddress: deps.MailAddress,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,36 +49,36 @@ func (receiver *MailClient) SendMessage(userEmail string, verification *models.V
|
|||||||
defer writer.Close()
|
defer writer.Close()
|
||||||
|
|
||||||
fields := map[string]string{
|
fields := map[string]string{
|
||||||
"from": receiver.deps.Sender,
|
"from": receiver.sender,
|
||||||
"to": receiver.deps.MailAddress,
|
"to": receiver.mailAddress,
|
||||||
"subject": "Новая заявка на оплату через Р/С",
|
"subject": "Новая заявка на оплату через Р/С",
|
||||||
"html": body,
|
"html": body,
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value := range fields {
|
for key, value := range fields {
|
||||||
if err := writer.WriteField(key, value); err != nil {
|
if err := writer.WriteField(key, value); err != nil {
|
||||||
return handleError(receiver.deps.Logger, "Error writing form field", err)
|
return handleError(receiver.logger, "Error writing form field", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := writer.Close(); err != nil {
|
if err := writer.Close(); err != nil {
|
||||||
return handleError(receiver.deps.Logger, "Error closing form writer", err)
|
return handleError(receiver.logger, "Error closing form writer", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("SEEEEEND", receiver.deps.ApiUrl)
|
fmt.Println("SEEEEEND", receiver.apiUrl)
|
||||||
req := receiver.deps.FiberClient.Post(receiver.deps.ApiUrl).Body(form.Bytes()).ContentType(writer.FormDataContentType())
|
req := receiver.fiberClient.Post(receiver.apiUrl).Body(form.Bytes()).ContentType(writer.FormDataContentType())
|
||||||
if receiver.deps.ApiKey != "" {
|
if receiver.apiKey != "" {
|
||||||
req.Set("Authorization", receiver.deps.ApiKey)
|
req.Set("Authorization", receiver.apiKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
statusCode, _, errs := req.Bytes()
|
statusCode, _, errs := req.Bytes()
|
||||||
if errs != nil {
|
if errs != nil {
|
||||||
return handleError(receiver.deps.Logger, "Error sending request", errs[0])
|
return handleError(receiver.logger, "Error sending request", errs[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
if statusCode != fiber.StatusOK {
|
if statusCode != fiber.StatusOK {
|
||||||
err := fmt.Errorf("the SMTP service returned an error: %d", statusCode)
|
err := fmt.Errorf("the SMTP service returned an error: %d", statusCode)
|
||||||
return handleError(receiver.deps.Logger, "Error sending email", err)
|
return handleError(receiver.logger, "Error sending email", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -4,23 +4,24 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TemplateClientDeps struct {
|
type TemplateClientDeps struct {
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
URLs *models.TemplategenMicroserviceURL
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type TemplateClient struct {
|
type TemplateClient struct {
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
urls *models.TemplategenMicroserviceURL
|
url string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTemplateClient(deps TemplateClientDeps) *TemplateClient {
|
func NewTemplateClient(deps TemplateClientDeps) *TemplateClient {
|
||||||
@ -28,18 +29,18 @@ func NewTemplateClient(deps TemplateClientDeps) *TemplateClient {
|
|||||||
log.Panicln("logger is nil on <NewTemplateClient>")
|
log.Panicln("logger is nil on <NewTemplateClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.URLs == nil {
|
if deps.URL == "" {
|
||||||
log.Panicln("urls is nil on <NewTemplateClient>")
|
log.Panicln("urls is nil on <NewTemplateClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &TemplateClient{
|
return &TemplateClient{
|
||||||
logger: deps.Logger,
|
logger: deps.Logger,
|
||||||
urls: deps.URLs,
|
url: deps.URL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver *TemplateClient) SendData(ctx context.Context, data models.RespGeneratorService, fileContents []byte, email string) errors.Error {
|
func (receiver *TemplateClient) SendData(ctx context.Context, data models.RespGeneratorService, fileContents []byte, email string) errors.Error {
|
||||||
tmplURL := receiver.urls.Templategen
|
tmplURL := fmt.Sprintf("%s/generator/service", receiver.url)
|
||||||
|
|
||||||
body := &bytes.Buffer{}
|
body := &bytes.Buffer{}
|
||||||
writer := multipart.NewWriter(body)
|
writer := multipart.NewWriter(body)
|
||||||
|
@ -6,20 +6,20 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"gitea.pena/PenaSide/customer/pkg/client"
|
"gitea.pena/PenaSide/customer/pkg/client"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VerificationClientDeps struct {
|
type VerificationClientDeps struct {
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
URLs *models.VerificationMicroserviceURL
|
URL string
|
||||||
}
|
}
|
||||||
|
|
||||||
type VerificationClient struct {
|
type VerificationClient struct {
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
urls *models.VerificationMicroserviceURL
|
url string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVerificationClient(deps VerificationClientDeps) *VerificationClient {
|
func NewVerificationClient(deps VerificationClientDeps) *VerificationClient {
|
||||||
@ -27,18 +27,18 @@ func NewVerificationClient(deps VerificationClientDeps) *VerificationClient {
|
|||||||
log.Panicln("logger is nil on <NewVerificationClient>")
|
log.Panicln("logger is nil on <NewVerificationClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.URLs == nil {
|
if deps.URL == "" {
|
||||||
log.Panicln("urls is nil on <NewVerificationClient>")
|
log.Panicln("urls is nil on <NewVerificationClient>")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &VerificationClient{
|
return &VerificationClient{
|
||||||
logger: deps.Logger,
|
logger: deps.Logger,
|
||||||
urls: deps.URLs,
|
url: deps.URL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver *VerificationClient) GetVerification(ctx context.Context, token, userID string) (*models.Verification, errors.Error) {
|
func (receiver *VerificationClient) GetVerification(ctx context.Context, token, userID string) (*models.Verification, errors.Error) {
|
||||||
verifURL, err := url.JoinPath(receiver.urls.Verification, userID)
|
verifURL, err := url.JoinPath(fmt.Sprintf("%s/verification", receiver.url), userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(
|
return nil, errors.New(
|
||||||
fmt.Errorf("failed to join path on <GetVerification> of <VerificationClient>: %w", err),
|
fmt.Errorf("failed to join path on <GetVerification> of <VerificationClient>: %w", err),
|
||||||
|
@ -2,10 +2,7 @@ package wallet_client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/client"
|
"gitea.pena/PenaSide/customer/internal/interface/client"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/controller/http"
|
"gitea.pena/PenaSide/customer/internal/interface/controller/http"
|
||||||
@ -14,13 +11,16 @@ import (
|
|||||||
"gitea.pena/PenaSide/customer/internal/proto/treasurer"
|
"gitea.pena/PenaSide/customer/internal/proto/treasurer"
|
||||||
"gitea.pena/PenaSide/customer/internal/utils"
|
"gitea.pena/PenaSide/customer/internal/utils"
|
||||||
"gitea.pena/PenaSide/customer/pkg/validate"
|
"gitea.pena/PenaSide/customer/pkg/validate"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
"penahub.gitlab.yandexcloud.net/backend/penahub_common/log_mw"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
MiddleWare *http.MiddleWare
|
MiddleWare *http.MiddleWare
|
||||||
AuthClient *client.AuthClient
|
AuthClient *client.AuthClient
|
||||||
PaymentClient *client.PaymentClient
|
PaymentClient *client.PaymentClient
|
||||||
GRPC *models.ConfigurationGRPC
|
GRPCDomain string
|
||||||
AccountRepo *repository.AccountRepository
|
AccountRepo *repository.AccountRepository
|
||||||
CurrencyClient *client.CurrencyClient
|
CurrencyClient *client.CurrencyClient
|
||||||
VerifyClient *client.VerificationClient
|
VerifyClient *client.VerificationClient
|
||||||
@ -33,7 +33,7 @@ type WalletController struct {
|
|||||||
middleWare *http.MiddleWare
|
middleWare *http.MiddleWare
|
||||||
authClient *client.AuthClient
|
authClient *client.AuthClient
|
||||||
paymentClient *client.PaymentClient
|
paymentClient *client.PaymentClient
|
||||||
grpc *models.ConfigurationGRPC
|
grpcDomain string
|
||||||
accountRepo *repository.AccountRepository
|
accountRepo *repository.AccountRepository
|
||||||
currencyClient *client.CurrencyClient
|
currencyClient *client.CurrencyClient
|
||||||
verifyClient *client.VerificationClient
|
verifyClient *client.VerificationClient
|
||||||
@ -47,7 +47,7 @@ func NewWalletController(deps Deps) *WalletController {
|
|||||||
middleWare: deps.MiddleWare,
|
middleWare: deps.MiddleWare,
|
||||||
authClient: deps.AuthClient,
|
authClient: deps.AuthClient,
|
||||||
paymentClient: deps.PaymentClient,
|
paymentClient: deps.PaymentClient,
|
||||||
grpc: deps.GRPC,
|
grpcDomain: deps.GRPCDomain,
|
||||||
accountRepo: deps.AccountRepo,
|
accountRepo: deps.AccountRepo,
|
||||||
currencyClient: deps.CurrencyClient,
|
currencyClient: deps.CurrencyClient,
|
||||||
verifyClient: deps.VerifyClient,
|
verifyClient: deps.VerifyClient,
|
||||||
@ -148,7 +148,7 @@ func (receiver *WalletController) GetPaymentLinkBankCard(ctx context.Context, re
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.grpc.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
Customer: &treasurer.Customer{
|
Customer: &treasurer.Customer{
|
||||||
FullName: account.Name.Orgname + ". " + account.Name.FirstName + " " + account.Name.Secondname,
|
FullName: account.Name.Orgname + ". " + account.Name.FirstName + " " + account.Name.Secondname,
|
||||||
@ -178,7 +178,7 @@ func (receiver *WalletController) GetPaymentLinkYooMoney(ctx context.Context, re
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.grpc.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
Customer: &treasurer.Customer{
|
Customer: &treasurer.Customer{
|
||||||
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
||||||
@ -208,7 +208,7 @@ func (receiver *WalletController) GetPaymentLinkSberPay(ctx context.Context, req
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.grpc.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
Customer: &treasurer.Customer{
|
Customer: &treasurer.Customer{
|
||||||
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
||||||
@ -238,7 +238,7 @@ func (receiver *WalletController) GetPaymentLinkTinkoff(ctx context.Context, req
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.grpc.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
Customer: &treasurer.Customer{
|
Customer: &treasurer.Customer{
|
||||||
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
||||||
@ -268,7 +268,7 @@ func (receiver *WalletController) GetPaymentLinkSBP(ctx context.Context, request
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.grpc.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
Customer: &treasurer.Customer{
|
Customer: &treasurer.Customer{
|
||||||
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
||||||
@ -298,7 +298,7 @@ func (receiver *WalletController) GetPaymentLinkB2B(ctx context.Context, request
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.grpc.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
Customer: &treasurer.Customer{
|
Customer: &treasurer.Customer{
|
||||||
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
FullName: account.Name.Orgname + ", " + account.Name.FirstName + " " + account.Name.Secondname,
|
||||||
|
@ -1,61 +1,56 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"gitea.pena/PenaSide/common/encrypt"
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo"
|
"penahub.gitlab.yandexcloud.net/backend/penahub_common/mongo"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
HTTP ConfigurationHTTP
|
ClientHttpHost string `env:"CLIENT_HTTP_HOST,default=localhost"`
|
||||||
GRPC ConfigurationGRPC
|
ClientHttpPort string `env:"CLIENT_HTTP_PORT,default=8080"`
|
||||||
Service ServiceConfiguration
|
AdminHttpHost string `env:"ADMIN_HTTP_HOST,default=localhost"`
|
||||||
Database mongo.Configuration
|
AdminHttpPort string `env:"ADMIN_HTTP_PORT,default=8081"`
|
||||||
|
GrpcHost string `env:"GRPC_HOST,default=localhost"`
|
||||||
|
GrpcPort string `env:"GRPC_PORT,default=8081"`
|
||||||
|
GrpcDomen string `env:"GRPC_DOMEN,default=https://domen.ru"`
|
||||||
|
AuthMicroservice string `env:"AUTH_MICROSERVICE_URL,required"` // http://10.8.0.6:59300/user
|
||||||
|
HubadminMicroservice string `env:"HUBADMIN_MICROSERVICE_URL,required"` // http://10.8.0.6:59303/tariff
|
||||||
|
CurrencyMicroservice string `env:"CURRENCY_MICROSERVICE_URL,required"` // http://10.8.0.6:3131/change
|
||||||
|
DiscountMicroservice string `env:"DISCOUNT_MICROSERVICE_GRPC_HOST,required"`
|
||||||
|
CodewordMicroservice string `env:"CODEWORD_MICROSERVICE_GRPC_HOST,required"`
|
||||||
|
PaymentMicroservice string `env:"PAYMENT_MICROSERVICE_GRPC_HOST,required"`
|
||||||
|
VerificationMicroservice string `env:"VERIFICATION_MICROSERVICE_URL,required"` // http://10.8.0.6:7036/verification
|
||||||
|
TemplategenMicroserviceURL string `env:"TEMPLATEGEN_MICROSERVICE_URL,required"` // http://10.6.0.17/generator/service
|
||||||
|
KafkaTopic string `json:"topic" env:"KAFKA_TOPIC_TARIFF,required"`
|
||||||
|
KafkaBrokers []string `json:"brokers" env:"KAFKA_BROKERS,required"`
|
||||||
|
TrashLogHost string `env:"TRASH_LOG_HOST"`
|
||||||
|
ModuleLogger string `env:"MODULE_LOGGER"`
|
||||||
|
NotificationBotToken string `env:"NOTIFICATION_BOT_TOKEN"`
|
||||||
|
NotificationChannel int64 `env:"NOTIFICATION_CHANNEL"`
|
||||||
|
AdminURL string `env:"ADMIN_FRONT_URL"`
|
||||||
|
NotificationRsPayChannel int64 `env:"NOTIFICATION_RS_PAY_CHANNEL"`
|
||||||
|
EncryptCommon encrypt.Encrypt
|
||||||
|
JwtCfg JWTConfiguration
|
||||||
|
MailClientCfg MailClientCfg
|
||||||
|
Database mongo.Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigurationHTTP struct {
|
type MailClientCfg struct {
|
||||||
ClientHost string `env:"CLIENT_HTTP_HOST,default=localhost"`
|
ApiUrl string `env:"API_URL,required"`
|
||||||
ClientPort string `env:"CLIENT_HTTP_PORT,default=8080"`
|
Sender string `env:"MAIL_SENDER,required"`
|
||||||
AdminHost string `env:"ADMIN_HTTP_HOST,default=localhost"`
|
Auth *PlainAuth
|
||||||
AdminPort string `env:"ADMIN_HTTP_PORT,default=8081"`
|
ApiKey string `env:"MAIL_API_KEY,required"`
|
||||||
|
FiberClient *fiber.Client
|
||||||
|
MailAddress string `env:"MAIL_ADDRESS,required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigurationGRPC struct {
|
type PlainAuth struct {
|
||||||
Host string `env:"GRPC_HOST,default=localhost"`
|
Identity string `env:"MAIL_AUTH_IDENTITY"`
|
||||||
Port string `env:"GRPC_PORT,default=8081"`
|
Username string `env:"MAIL_AUTH_USERNAME,required"`
|
||||||
Domen string `env:"GRPC_DOMEN,default=https://domen.ru"`
|
Password string `env:"MAIL_AUTH_PASSWORD,required"`
|
||||||
}
|
|
||||||
|
|
||||||
type ServiceConfiguration struct {
|
|
||||||
AuthMicroservice AuthMicroserviceConfiguration
|
|
||||||
HubadminMicroservice HubadminMicroserviceConfiguration
|
|
||||||
CurrencyMicroservice CurrencyMicroserviceConfiguration
|
|
||||||
DiscountMicroservice DiscountMicroserviceConfiguration
|
|
||||||
CodewordMicroservice CodewordMicroserviceConfiguration
|
|
||||||
PaymentMicroservice PaymentMicroserviceConfiguration
|
|
||||||
VerificationMicroservice VerificationMicroserviceConfiguration
|
|
||||||
TemplategenMicroserviceURL TemplategenMicroserviceConfiguration
|
|
||||||
JWT JWTConfiguration
|
|
||||||
Kafka KafkaConfiguration
|
|
||||||
Mail MailConfiguration
|
|
||||||
TrashLogHost string `env:"TRASH_LOG_HOST"`
|
|
||||||
PubKey string `env:"PUBLIC_KEY"`
|
|
||||||
PrivKey string `env:"PRIVATE_KEY"`
|
|
||||||
ModuleLogger string `env:"MODULE_LOGGER"`
|
|
||||||
NotificationBotToken string `env:"NOTIFICATION_BOT_TOKEN"`
|
|
||||||
NotificationChannel int64 `env:"NOTIFICATION_CHANNEL"`
|
|
||||||
AdminURL string `env:"ADMIN_FRONT_URL"`
|
|
||||||
NotificationRsPayChannel int64 `env:"NOTIFICATION_RS_PAY_CHANNEL"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type KafkaConfiguration struct {
|
|
||||||
Tariff TariffKafkaConfiguration `json:"tariff"`
|
|
||||||
Brokers []string `json:"brokers" env:"KAFKA_BROKERS,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TariffKafkaConfiguration struct {
|
|
||||||
Topic string `json:"topic" env:"KAFKA_TOPIC_TARIFF,required"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type JWTConfiguration struct {
|
type JWTConfiguration struct {
|
||||||
@ -67,70 +62,4 @@ type JWTConfiguration struct {
|
|||||||
ExpiresIn time.Duration
|
ExpiresIn time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthMicroserviceConfiguration struct {
|
|
||||||
URL AuthMicroserviceURL
|
|
||||||
}
|
|
||||||
|
|
||||||
type HubadminMicroserviceConfiguration struct {
|
|
||||||
URL HubadminMicroserviceURL
|
|
||||||
}
|
|
||||||
|
|
||||||
type CurrencyMicroserviceConfiguration struct {
|
|
||||||
URL CurrencyMicroserviceURL
|
|
||||||
}
|
|
||||||
|
|
||||||
type VerificationMicroserviceConfiguration struct {
|
|
||||||
URL VerificationMicroserviceURL
|
|
||||||
}
|
|
||||||
|
|
||||||
type TemplategenMicroserviceConfiguration struct {
|
|
||||||
URL TemplategenMicroserviceURL
|
|
||||||
}
|
|
||||||
|
|
||||||
type CodewordMicroserviceConfiguration struct {
|
|
||||||
HostGRPC string `env:"CODEWORD_MICROSERVICE_GRPC_HOST,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PaymentMicroserviceConfiguration struct {
|
|
||||||
HostGRPC string `env:"PAYMENT_MICROSERVICE_GRPC_HOST,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DiscountMicroserviceConfiguration struct {
|
|
||||||
HostGRPC string `env:"DISCOUNT_MICROSERVICE_GRPC_HOST,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthMicroserviceURL struct {
|
|
||||||
User string `env:"AUTH_MICROSERVICE_USER_URL,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type HubadminMicroserviceURL struct {
|
|
||||||
Tariff string `env:"HUBADMIN_MICROSERVICE_TARIFF_URL,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CurrencyMicroserviceURL struct {
|
|
||||||
Translate string `env:"CURRENCY_MICROSERVICE_TRANSLATE_URL,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type VerificationMicroserviceURL struct {
|
|
||||||
Verification string `env:"VERIFICATION_MICROSERVICE_USER_URL,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TemplategenMicroserviceURL struct {
|
|
||||||
Templategen string `env:"TEMPLATEGEN_MICROSERVICE_URL,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MailConfiguration struct {
|
|
||||||
ApiUrl string `env:"API_URL,required"`
|
|
||||||
Sender string `env:"MAIL_SENDER,required"`
|
|
||||||
Auth PlainAuth
|
|
||||||
ApiKey string `env:"MAIL_API_KEY,required"`
|
|
||||||
MailAddress string `env:"MAIL_ADDRESS,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PlainAuth struct {
|
|
||||||
Identity string `env:"MAIL_AUTH_IDENTITY"`
|
|
||||||
Username string `env:"MAIL_AUTH_USERNAME,required"`
|
|
||||||
Password string `env:"MAIL_AUTH_PASSWORD,required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
const mongoVersion uint32 = 1
|
const mongoVersion uint32 = 1
|
||||||
|
@ -6,16 +6,15 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
|
"gitea.pena/PenaSide/customer/internal/initialize"
|
||||||
|
"gitea.pena/PenaSide/customer/internal/proto/customer"
|
||||||
|
"gitea.pena/PenaSide/customer/internal/proto/payment_callback"
|
||||||
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
||||||
grpc_zap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap"
|
grpc_zap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap"
|
||||||
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
|
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/initialize"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/proto/customer"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/proto/payment_callback"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DepsGRPC struct {
|
type DepsGRPC struct {
|
||||||
@ -48,8 +47,8 @@ func NewGRPC(deps DepsGRPC) (*GRPC, errors.Error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver *GRPC) Run(config *models.ConfigurationGRPC) {
|
func (receiver *GRPC) Run(host, port string) {
|
||||||
connectionString := fmt.Sprintf("%s:%s", config.Host, config.Port)
|
connectionString := fmt.Sprintf("%s:%s", host, port)
|
||||||
|
|
||||||
receiver.logger.Info("Starting GRPC Server", zap.String("host", connectionString))
|
receiver.logger.Info("Starting GRPC Server", zap.String("host", connectionString))
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/errors"
|
"gitea.pena/PenaSide/customer/internal/errors"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"gitea.pena/PenaSide/customer/internal/proto/treasurer"
|
"gitea.pena/PenaSide/customer/internal/proto/treasurer"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type paymentClient interface {
|
type paymentClient interface {
|
||||||
@ -23,17 +23,17 @@ type authClient interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
Logger *zap.Logger
|
Logger *zap.Logger
|
||||||
ConfigurationGRPC *models.ConfigurationGRPC
|
GRPCDomain string
|
||||||
PaymentClient paymentClient
|
PaymentClient paymentClient
|
||||||
AuthClient authClient
|
AuthClient authClient
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
configurationGRPC *models.ConfigurationGRPC
|
grpcDomain string
|
||||||
paymentClient paymentClient
|
paymentClient paymentClient
|
||||||
authClient authClient
|
authClient authClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(deps Deps) *Service {
|
func New(deps Deps) *Service {
|
||||||
@ -41,7 +41,7 @@ func New(deps Deps) *Service {
|
|||||||
log.Panicln("logger is nil on <New (payment service)>")
|
log.Panicln("logger is nil on <New (payment service)>")
|
||||||
}
|
}
|
||||||
|
|
||||||
if deps.ConfigurationGRPC == nil {
|
if deps.GRPCDomain == "" {
|
||||||
log.Panicln("ConfigurationGRPC is nil on <New (payment service)>")
|
log.Panicln("ConfigurationGRPC is nil on <New (payment service)>")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,10 +54,10 @@ func New(deps Deps) *Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &Service{
|
return &Service{
|
||||||
logger: deps.Logger,
|
logger: deps.Logger,
|
||||||
paymentClient: deps.PaymentClient,
|
paymentClient: deps.PaymentClient,
|
||||||
authClient: deps.AuthClient,
|
authClient: deps.AuthClient,
|
||||||
configurationGRPC: deps.ConfigurationGRPC,
|
grpcDomain: deps.GRPCDomain,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ func (receiver *Service) GetPaymentLinkBankCard(ctx context.Context, request *mo
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.configurationGRPC.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -111,7 +111,7 @@ func (receiver *Service) GetPaymentLinkYooMoney(ctx context.Context, request *mo
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.configurationGRPC.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -130,7 +130,7 @@ func (receiver *Service) GetPaymentLinkSberPay(ctx context.Context, request *mod
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.configurationGRPC.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -149,7 +149,7 @@ func (receiver *Service) GetPaymentLinkTinkoff(ctx context.Context, request *mod
|
|||||||
Amount: request.Body.Amount,
|
Amount: request.Body.Amount,
|
||||||
UserID: request.UserID,
|
UserID: request.UserID,
|
||||||
ClientIP: request.ClientIP,
|
ClientIP: request.ClientIP,
|
||||||
CallbackHostGRPC: []string{receiver.configurationGRPC.Domen},
|
CallbackHostGRPC: []string{receiver.grpcDomain},
|
||||||
ReturnURL: request.Body.ReturnURL,
|
ReturnURL: request.Body.ReturnURL,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -3,10 +3,10 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type JWT struct {
|
type JWT struct {
|
||||||
|
@ -1,20 +1,13 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
//func ValidateConfigurationURLs(config *models.ServiceConfiguration) error {
|
||||||
"fmt"
|
// return validateAuthMicroserviceURLs(&config.AuthMicroservice.URL)
|
||||||
|
//}
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
//
|
||||||
"gitea.pena/PenaSide/customer/pkg/validate"
|
//func validateAuthMicroserviceURLs(urls *models.AuthMicroserviceURL) error {
|
||||||
)
|
// if !validate.URL(urls.User) {
|
||||||
|
// return fmt.Errorf("invalid auth user url: %s", urls.User)
|
||||||
func ValidateConfigurationURLs(config *models.ServiceConfiguration) error {
|
// }
|
||||||
return validateAuthMicroserviceURLs(&config.AuthMicroservice.URL)
|
//
|
||||||
}
|
// return nil
|
||||||
|
//}
|
||||||
func validateAuthMicroserviceURLs(urls *models.AuthMicroserviceURL) error {
|
|
||||||
if !validate.URL(urls.User) {
|
|
||||||
return fmt.Errorf("invalid auth user url: %s", urls.User)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -49,9 +49,7 @@ func main() {
|
|||||||
|
|
||||||
authClient := client.NewAuthClient(client.AuthClientDeps{
|
authClient := client.NewAuthClient(client.AuthClientDeps{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
URLs: &models.AuthMicroserviceURL{
|
URL: AuthServiceUrl,
|
||||||
User: AuthServiceUrl,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
mongoClient, err := connectToMongoDB(ctx, MongoURL)
|
mongoClient, err := connectToMongoDB(ctx, MongoURL)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gitea.pena/PenaSide/customer/internal/interface/client"
|
||||||
|
"gitea.pena/PenaSide/customer/internal/models"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/client"
|
|
||||||
"gitea.pena/PenaSide/customer/internal/models"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,15 +13,14 @@ func TestSendMessage(t *testing.T) {
|
|||||||
sender := "noreply@mailing.pena.digital"
|
sender := "noreply@mailing.pena.digital"
|
||||||
apiKey := "P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev"
|
apiKey := "P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev"
|
||||||
|
|
||||||
mailClient := client.NewMailClient(client.MailClientDeps{
|
mailClient := client.NewMailClient(models.MailClientCfg{
|
||||||
ApiUrl: "https://api.smtp.bz/v1/smtp/send",
|
ApiUrl: "https://api.smtp.bz/v1/smtp/send",
|
||||||
Sender: sender,
|
Sender: sender,
|
||||||
ApiKey: apiKey,
|
ApiKey: apiKey,
|
||||||
Auth: &models.PlainAuth{Username: "kotilion.95@gmail.com", Password: "vWwbCSg4bf0p"},
|
Auth: &models.PlainAuth{Username: "kotilion.95@gmail.com", Password: "vWwbCSg4bf0p"},
|
||||||
FiberClient: fiber.AcquireClient(),
|
FiberClient: fiber.AcquireClient(),
|
||||||
Logger: zap.NewExample(),
|
|
||||||
MailAddress: "pashamullin2001@gmail.com",
|
MailAddress: "pashamullin2001@gmail.com",
|
||||||
})
|
}, zap.NewExample())
|
||||||
|
|
||||||
userEmail := "test@example.com"
|
userEmail := "test@example.com"
|
||||||
verification := &models.Verification{
|
verification := &models.Verification{
|
||||||
|
@ -31,14 +31,12 @@ func TestTrashLogger(t *testing.T) {
|
|||||||
ptime := time.Now()
|
ptime := time.Now()
|
||||||
|
|
||||||
config := models.Config{
|
config := models.Config{
|
||||||
Service: models.ServiceConfiguration{
|
TrashLogHost: "localhost:7113",
|
||||||
TrashLogHost: "localhost:7113",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
clickHouseLogger, err := zaptrashlog.NewCore(ctx, zap.InfoLevel, config.Service.TrashLogHost, version, commit, ptime.Unix())
|
clickHouseLogger, err := zaptrashlog.NewCore(ctx, zap.InfoLevel, config.TrashLogHost, version, commit, ptime.Unix())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user