generated from VLADIMIR/template
fix
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// GameService handles game lifecycle operations.
|
||||
type GameService struct {
|
||||
gamesRepo *games_repo.GamesRepo
|
||||
teamsRepo *teams_repo.TeamsRepo
|
||||
@@ -30,6 +31,7 @@ var (
|
||||
ErrInvalidGameFormat = errors.New("Формат игры должен быть online или offline")
|
||||
)
|
||||
|
||||
// NewGameService creates a game service.
|
||||
func NewGameService(
|
||||
gamesRepo *games_repo.GamesRepo,
|
||||
teamsRepo *teams_repo.TeamsRepo,
|
||||
@@ -50,6 +52,7 @@ func NewGameService(
|
||||
}
|
||||
}
|
||||
|
||||
// AddGame creates a game.
|
||||
func (s *GameService) AddGame(
|
||||
ctx context.Context,
|
||||
name string,
|
||||
@@ -72,6 +75,7 @@ func (s *GameService) AddGame(
|
||||
return id, nil
|
||||
}
|
||||
|
||||
// GetGame returns a game by ID.
|
||||
func (s *GameService) GetGame(ctx context.Context, id int) (*game_model.Game, error) {
|
||||
game, err := s.gamesRepo.GetGameByID(ctx, id)
|
||||
if err != nil {
|
||||
@@ -81,6 +85,7 @@ func (s *GameService) GetGame(ctx context.Context, id int) (*game_model.Game, er
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// GetGameMedia returns a game with its media references.
|
||||
func (s *GameService) GetGameMedia(ctx context.Context, id int) (*game_model.Game, error) {
|
||||
game, err := s.gamesRepo.GetGameByID(ctx, id)
|
||||
if err != nil {
|
||||
@@ -94,6 +99,7 @@ func (s *GameService) GetGameMedia(ctx context.Context, id int) (*game_model.Gam
|
||||
return gameResult, nil
|
||||
}
|
||||
|
||||
// GetFullGame returns a game with its full related data.
|
||||
func (s *GameService) GetFullGame(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
@@ -141,6 +147,7 @@ func (s *GameService) GetFullGame(
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// DeleteGame removes a game.
|
||||
func (s *GameService) DeleteGame(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
@@ -148,6 +155,7 @@ func (s *GameService) DeleteGame(
|
||||
return mapGameError(s.gamesRepo.DeleteGameByID(ctx, id))
|
||||
}
|
||||
|
||||
// GetGames returns games matching the requested filters.
|
||||
func (s *GameService) GetGames(
|
||||
ctx context.Context,
|
||||
) ([]*game_model.Game, error) {
|
||||
@@ -158,6 +166,7 @@ func (s *GameService) GetGames(
|
||||
return game_model.MapGames(games, s.domain), nil
|
||||
}
|
||||
|
||||
// UpdateGame updates a game's editable fields.
|
||||
func (s *GameService) UpdateGame(
|
||||
ctx context.Context,
|
||||
id int,
|
||||
@@ -181,22 +190,27 @@ func (s *GameService) UpdateGame(
|
||||
return mapGameError(s.gamesRepo.UpdateGame(ctx, id, name, description, location, startAt, scenarioID, format))
|
||||
}
|
||||
|
||||
// StartGame marks a game as started.
|
||||
func (s *GameService) StartGame(ctx context.Context, id int) error {
|
||||
return mapGameError(s.gamesRepo.StartGame(ctx, id))
|
||||
}
|
||||
|
||||
// PauseGame marks a game as paused.
|
||||
func (s *GameService) PauseGame(ctx context.Context, id int) error {
|
||||
return mapGameError(s.gamesRepo.PauseGame(ctx, id))
|
||||
}
|
||||
|
||||
// PlayGame resumes a paused game.
|
||||
func (s *GameService) PlayGame(ctx context.Context, id int) error {
|
||||
return mapGameError(s.gamesRepo.PlayGame(ctx, id))
|
||||
}
|
||||
|
||||
// FinishGame marks a game as finished.
|
||||
func (s *GameService) FinishGame(ctx context.Context, id int) error {
|
||||
return mapGameError(s.gamesRepo.FinishGame(ctx, id))
|
||||
}
|
||||
|
||||
// ResetGame resets a game's state.
|
||||
func (s *GameService) ResetGame(ctx context.Context, id int) error {
|
||||
return mapGameError(s.gamesRepo.ResetGame(ctx, id))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user