generated from VLADIMIR/template
add online games
This commit is contained in:
@@ -30,17 +30,19 @@ func (r *GamesRepo) AddGame(
|
||||
description string,
|
||||
startAt time.Time,
|
||||
scenarioId int32,
|
||||
format string,
|
||||
) (int, error) {
|
||||
id := 0
|
||||
err := r.pool.QueryRow(
|
||||
ctx,
|
||||
`INSERT INTO games (name, description, start_at, scenario_id)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
`INSERT INTO games (name, description, start_at, scenario_id, format)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING id`,
|
||||
name,
|
||||
description,
|
||||
startAt,
|
||||
scenarioId,
|
||||
format,
|
||||
).Scan(&id)
|
||||
|
||||
if err != nil {
|
||||
@@ -61,6 +63,7 @@ func (r *GamesRepo) GetGameByID(
|
||||
games.name,
|
||||
games.description,
|
||||
games.start_at,
|
||||
games.format,
|
||||
games.status,
|
||||
games.scenario_id,
|
||||
games.started_at,
|
||||
@@ -74,6 +77,7 @@ func (r *GamesRepo) GetGameByID(
|
||||
&game.Name,
|
||||
&game.Description,
|
||||
&game.StartAt,
|
||||
&game.Format,
|
||||
&game.Status,
|
||||
&game.ScenarioId,
|
||||
&game.StartedAt,
|
||||
@@ -118,6 +122,7 @@ func (r *GamesRepo) GetGames(
|
||||
games.name,
|
||||
games.description,
|
||||
games.start_at,
|
||||
games.format,
|
||||
games.status
|
||||
FROM games
|
||||
ORDER BY created_at DESC`,
|
||||
@@ -135,6 +140,7 @@ func (r *GamesRepo) GetGames(
|
||||
&game.Name,
|
||||
&game.Description,
|
||||
&game.StartAt,
|
||||
&game.Format,
|
||||
&game.Status,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -156,6 +162,7 @@ func (r *GamesRepo) UpdateGame(
|
||||
description string,
|
||||
startAt time.Time,
|
||||
scenarioId int32,
|
||||
format string,
|
||||
) error {
|
||||
tag, err := r.pool.Exec(
|
||||
ctx,
|
||||
@@ -165,12 +172,14 @@ func (r *GamesRepo) UpdateGame(
|
||||
description = $2,
|
||||
start_at = $3,
|
||||
scenario_id = $4,
|
||||
format = $5,
|
||||
updated_at = NOW()
|
||||
WHERE id = $5`,
|
||||
WHERE id = $6`,
|
||||
name,
|
||||
description,
|
||||
startAt,
|
||||
scenarioId,
|
||||
format,
|
||||
id,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user