From d41e28de2e36a3f80a5c5c545654930bbc175dca Mon Sep 17 00:00:00 2001 From: linuxMate Date: Wed, 13 Dec 2023 22:45:32 +0300 Subject: [PATCH] udate err check --- .../auth/delivery/http/handlers.go | 5 ++--- .../category/repository/postgres/postgres.go | 19 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/internal/microservices/auth/delivery/http/handlers.go b/internal/microservices/auth/delivery/http/handlers.go index 2751e253..2f221138 100644 --- a/internal/microservices/auth/delivery/http/handlers.go +++ b/internal/microservices/auth/delivery/http/handlers.go @@ -2,7 +2,6 @@ package http import ( "encoding/json" - "errors" "net/http" "time" @@ -80,8 +79,8 @@ func (h *Handler) SignUp(w http.ResponseWriter, r *http.Request) { Password: signUpUser.PlaintPassword, }) if err != nil { - errUserAlreadyExists := status.Error(codes.AlreadyExists, "Alredy exist") //*models.UserAlreadyExistsError - if errors.As(err, &errUserAlreadyExists) { + // errUserAlreadyExists := status.Error(codes.AlreadyExists, "Alredy exist") //*models.UserAlreadyExistsError + if status.Code(err) == codes.AlreadyExists { response.ErrorResponse(w, http.StatusConflict, err, "User already exists", h.log) return } diff --git a/internal/microservices/category/repository/postgres/postgres.go b/internal/microservices/category/repository/postgres/postgres.go index bc1391dc..7832fcf8 100644 --- a/internal/microservices/category/repository/postgres/postgres.go +++ b/internal/microservices/category/repository/postgres/postgres.go @@ -6,8 +6,6 @@ import ( "errors" "fmt" - "github.com/jackc/pgx/v4" - "github.com/go-park-mail-ru/2023_2_Hamster/cmd/api/init/db/postgresql" "github.com/go-park-mail-ru/2023_2_Hamster/internal/common/logger" "github.com/go-park-mail-ru/2023_2_Hamster/internal/models" @@ -37,7 +35,7 @@ const ( WHERE user_id = $1 AND id = $2 );` - transactionAssociationDelete = "DELETE FROM TransactionCategory WHERE category_id = $1;" + // transactionAssociationDelete = "DELETE FROM TransactionCategory WHERE category_id = $1;" ) type Repository struct { @@ -209,10 +207,11 @@ func (r *Repository) CheckExist(ctx context.Context, userId uuid.UUID, tagId uui return true, nil } -func (r *Repository) deleteTransactionAssociations(ctx context.Context, tx pgx.Tx, tagID uuid.UUID) error { - _, err := tx.Exec(ctx, transactionAssociationDelete, tagID) - if err != nil { - return fmt.Errorf("[repo] failed to delete existing transaction associations: %w", err) - } - return nil -} +// +// func (r *Repository) deleteTransactionAssociations(ctx context.Context, tx pgx.Tx, tagID uuid.UUID) error { +// _, err := tx.Exec(ctx, transactionAssociationDelete, tagID) +// if err != nil { +// return fmt.Errorf("[repo] failed to delete existing transaction associations: %w", err) +// } +// return nil +// }