This commit is contained in:
2026-10-23 00:45:30 +07:00
parent 60119a07e8
commit 146700cf4c
34 changed files with 622 additions and 124 deletions
+15 -2
View File
@@ -3,6 +3,9 @@ package game_service
import (
"context"
"errors"
"time"
"evening_detective_server/internal/modules/team_qr_pdf"
"evening_detective_server/internal/repos/actions_repo"
"evening_detective_server/internal/repos/applications_repo"
"evening_detective_server/internal/repos/games_repo"
@@ -10,7 +13,6 @@ import (
"evening_detective_server/internal/repos/teams_repo"
"evening_detective_server/internal/services/game_model"
"evening_detective_server/internal/services/scenarios_service"
"time"
)
// GameService handles game lifecycle operations.
@@ -174,7 +176,18 @@ func (s *GameService) UpdateGame(
startAt time.Time,
scenarioID int32,
format string,
wifiName, wifiPassword *string,
) error {
nameValue, passwordValue := "", ""
if wifiName != nil {
nameValue = *wifiName
}
if wifiPassword != nil {
passwordValue = *wifiPassword
}
if err := team_qr_pdf.ValidateWiFi(nameValue, passwordValue); err != nil {
return err
}
if format == "" {
game, err := s.gamesRepo.GetGameByID(ctx, id)
if err != nil {
@@ -185,7 +198,7 @@ func (s *GameService) UpdateGame(
if format != "online" && format != "offline" {
return ErrInvalidGameFormat
}
return mapGameError(s.gamesRepo.UpdateGame(ctx, id, name, description, location, startAt, scenarioID, format))
return mapGameError(s.gamesRepo.UpdateGame(ctx, id, name, description, location, startAt, scenarioID, format, wifiName, wifiPassword))
}
// StartGame marks a game as started.