generated from VLADIMIR/template
add last action delete
This commit is contained in:
@@ -233,5 +233,30 @@ func (s *GameService) AddTeamAction(ctx context.Context, teamId int, password st
|
||||
}
|
||||
|
||||
func (s *GameService) DeleteLastTeamAction(ctx context.Context, teamId int) error {
|
||||
panic("unimplemented")
|
||||
team, err := s.teamsRepo.GetTeamByID(ctx, teamId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
actions, err := s.actionsRepo.GetActionsByTeamID(ctx, teamId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
scenario, err := s.scenarioService.GetFullScenarioByID(ctx, team.ScenarioId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
teamStory := s.storyteller.GetStory(scenario.Story, actions)
|
||||
|
||||
lastPlace := teamStory.Places[len(teamStory.Places)-1]
|
||||
|
||||
for _, application := range lastPlace.Applications {
|
||||
if err := s.applicationsRepo.DeleteApplicationByTeamIdAndName(ctx, teamId, application.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return s.actionsRepo.DeleteLastActionByTeamId(ctx, teamId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user