From cd49b9164b28fc70744e2e2b16d53bbe0174981a Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Thu, 1 Oct 2026 15:39:38 +0700 Subject: [PATCH] fix --- internal/repos/game_map_repo/repo.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/repos/game_map_repo/repo.go b/internal/repos/game_map_repo/repo.go index 0112792..a1177aa 100644 --- a/internal/repos/game_map_repo/repo.go +++ b/internal/repos/game_map_repo/repo.go @@ -7,8 +7,10 @@ import ( "github.com/jackc/pgx/v5/pgxpool" ) +// ErrItemNotFound означает, что объект карты не найден. var ErrItemNotFound = errors.New("объект карты не найден") +// Item — объект на карте игры. type Item struct { GameID int Kind string @@ -18,14 +20,17 @@ type Item struct { Hidden bool } +// Repo работает с объектами карт в PostgreSQL. type Repo struct { pool *pgxpool.Pool } +// New создаёт repository объектов карты. func New(pool *pgxpool.Pool) *Repo { return &Repo{pool: pool} } +// Ensure добавляет объект карты, если он ещё не существует. func (r *Repo) Ensure(ctx context.Context, gameID int, kind string, itemID int) error { _, err := r.pool.Exec(ctx, ` INSERT INTO game_map_items (game_id, kind, item_id) @@ -38,6 +43,7 @@ func (r *Repo) Ensure(ctx context.Context, gameID int, kind string, itemID int) return err } +// List возвращает объекты карты игры. func (r *Repo) List(ctx context.Context, gameID int) ([]Item, error) { rows, err := r.pool.Query( ctx, @@ -68,6 +74,7 @@ func (r *Repo) List(ctx context.Context, gameID int) ([]Item, error) { return items, rows.Err() } +// Update изменяет координаты и видимость объекта карты. func (r *Repo) Update(ctx context.Context, item Item) error { result, err := r.pool.Exec( ctx, @@ -95,6 +102,7 @@ func (r *Repo) Update(ctx context.Context, item Item) error { return nil } +// Delete удаляет объект карты. func (r *Repo) Delete(ctx context.Context, item Item) error { _, err := r.pool.Exec( ctx,