Skip to content

Commit

Permalink
add create balances func
Browse files Browse the repository at this point in the history
  • Loading branch information
KranjQ committed Dec 15, 2024
1 parent cdb5568 commit 8df8100
Show file tree
Hide file tree
Showing 6 changed files with 257 additions and 67 deletions.
2 changes: 1 addition & 1 deletion cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func main() {
paymentsClient := grpcpayments.NewPaymentClient(paymentsConn)

cors := corsMiddleware.New(logger)
signUp := signup.NewHandler(personalitiesClient, authClient, logger)
signUp := signup.NewHandler(personalitiesClient, authClient, paymentsClient, logger)
signIn := signin.NewHandler(personalitiesClient, authClient, logger)
getUsers := getuserlist.NewHandler(authClient, personalitiesClient, imageUseCase, communicationsClient, logger)
checkAuth := checkauth.NewHandler(authClient, logger)
Expand Down
18 changes: 17 additions & 1 deletion internal/pkg/auth/delivery/http/signup/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/go-park-mail-ru/2024_2_SaraFun/internal/models"
generatedAuth "github.com/go-park-mail-ru/2024_2_SaraFun/internal/pkg/auth/delivery/grpc/gen"
generatedPayments "github.com/go-park-mail-ru/2024_2_SaraFun/internal/pkg/payments/delivery/grpc/gen"
generatedPersonalities "github.com/go-park-mail-ru/2024_2_SaraFun/internal/pkg/personalities/delivery/grpc/gen"
"github.com/go-park-mail-ru/2024_2_SaraFun/internal/utils/consts"
"github.com/go-park-mail-ru/2024_2_SaraFun/internal/utils/hashing"
Expand Down Expand Up @@ -39,6 +40,7 @@ type PersonalitiesClient interface {
type Handler struct {
personalitiesClient generatedPersonalities.PersonalitiesClient
sessionClient generatedAuth.AuthClient
paymentsClient generatedPayments.PaymentClient
logger *zap.Logger
}

Expand All @@ -54,10 +56,13 @@ type Request struct {
Gender string `json:"gender"`
}

func NewHandler(personalitiesClient generatedPersonalities.PersonalitiesClient, sessionsClient generatedAuth.AuthClient, logger *zap.Logger) *Handler {
func NewHandler(personalitiesClient generatedPersonalities.PersonalitiesClient,
sessionsClient generatedAuth.AuthClient, paymentsClient generatedPayments.PaymentClient,
logger *zap.Logger) *Handler {
return &Handler{
personalitiesClient: personalitiesClient,
sessionClient: sessionsClient,
paymentsClient: paymentsClient,
logger: logger,
}
}
Expand Down Expand Up @@ -154,6 +159,17 @@ func (h *Handler) Handle(w http.ResponseWriter, r *http.Request) {
}
user.ID = int(id.UserId)

createBalancesRequest := &generatedPayments.CreateBalancesRequest{
UserID: id.UserId,
Amount: 3,
}
_, err = h.paymentsClient.CreateBalances(ctx, createBalancesRequest)
if err != nil {
h.logger.Error("failed to create balances", zap.Error(err))
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

//auth grpc
sessUser := &generatedAuth.User{
ID: int32(user.ID),
Expand Down
Loading

0 comments on commit 8df8100

Please sign in to comment.