Skip to content

Commit

Permalink
deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyKomarovCoder committed Dec 24, 2023
1 parent c3368a6 commit 91ce069
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (h *Handler) GetFeed(w http.ResponseWriter, r *http.Request) {

var dataResponse []models.TransactionTransfer

var userT models.User
var userT *models.User
for _, transaction := range dataFeed {
userT, err = h.userService.GetUser(r.Context(), transaction.UserID)

Check failure on line 124 in internal/microservices/transaction/delivery/http/handlers.go

View workflow job for this annotation

GitHub Actions / lint_and_test

ineffectual assignment to err (ineffassign)
dataResponse = append(dataResponse, models.InitTransactionTransfer(transaction, userT.Login))
Expand Down
8 changes: 4 additions & 4 deletions internal/microservices/user/repository/postgresql/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ func (r *UserRep) CreateUser(ctx context.Context, u models.User) (uuid.UUID, err
return id, nil
}

func (r *UserRep) GetByID(ctx context.Context, userID uuid.UUID) (models.User, error) {
func (r *UserRep) GetByID(ctx context.Context, userID uuid.UUID) (*models.User, error) {
row := r.db.QueryRow(ctx, UserIDGetByID, userID)
var u models.User

err := row.Scan(&u.ID, &u.Login, &u.Username, &u.Password, &u.PlannedBudget, &u.AvatarURL)
if errors.Is(err, sql.ErrNoRows) {
return u, fmt.Errorf("[repo] %w: %v", &models.NoSuchUserError{UserID: userID}, err)
return nil, fmt.Errorf("[repo] %w: %v", &models.NoSuchUserError{UserID: userID}, err)
} else if err != nil {
return u,
return nil,
fmt.Errorf("failed request db %s, %w", UserIDGetByID, err)

}
return u, nil
return nil, nil
}

func (r *UserRep) GetUserByLogin(ctx context.Context, login string) (*models.User, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/microservices/user/usecase/user_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewUsecase(
}
}

func (u *Usecase) GetUser(ctx context.Context, userID uuid.UUID) (models.User, error) { // need test
func (u *Usecase) GetUser(ctx context.Context, userID uuid.UUID) (*models.User, error) { // need test
user, err := u.userRepo.GetByID(ctx, userID)
if err != nil {
return user, fmt.Errorf("[usecase] can't get user from repository %w", err)
Expand Down
4 changes: 2 additions & 2 deletions internal/microservices/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Usecase interface {
GetCurrentBudget(ctx context.Context, userID uuid.UUID) (float64, error)
GetAccounts(ctx context.Context, userID uuid.UUID) ([]models.Accounts, error)
GetFeed(ctx context.Context, userID uuid.UUID) (*transfer_models.UserFeed, error)
GetUser(ctx context.Context, userID uuid.UUID) (models.User, error)
GetUser(ctx context.Context, userID uuid.UUID) (*models.User, error)
UpdateUser(ctx context.Context, user *models.User) error
UpdatePhoto(ctx context.Context, usserID uuid.UUID) (uuid.UUID, error)
AddUserInAccount(ctx context.Context, accountInput models.AddUserAccount, adminID uuid.UUID) error
Expand All @@ -25,7 +25,7 @@ type Usecase interface {
}

type Repository interface {
GetByID(ctx context.Context, userID uuid.UUID) (models.User, error)
GetByID(ctx context.Context, userID uuid.UUID) (*models.User, error)
CreateUser(ctx context.Context, user models.User) (uuid.UUID, error)
// IncreaseUserVersion(ctx context.Context, ctx context.Context, userID uuid.UUID) error
GetUserByLogin(ctx context.Context, login string) (*models.User, error)
Expand Down

0 comments on commit 91ce069

Please sign in to comment.