generated from VLADIMIR/template
fix
This commit is contained in:
@@ -8,10 +8,8 @@ import (
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
// ErrItemNotFound означает, что объект карты не найден.
|
||||
var ErrItemNotFound = errors.New("объект карты не найден")
|
||||
|
||||
// Item — объект на карте игры.
|
||||
type Item struct {
|
||||
GameID int
|
||||
Kind string
|
||||
@@ -21,7 +19,6 @@ type Item struct {
|
||||
Hidden bool
|
||||
}
|
||||
|
||||
// Repo работает с объектами карт в PostgreSQL.
|
||||
type Repo struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
@@ -31,7 +28,6 @@ func NewGameMapRepo(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)
|
||||
@@ -44,7 +40,6 @@ 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,
|
||||
@@ -75,7 +70,6 @@ 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,
|
||||
@@ -103,7 +97,6 @@ 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,
|
||||
|
||||
Reference in New Issue
Block a user