From a78ac42689cdd0a7ec43394dec70cb818b34ddcb Mon Sep 17 00:00:00 2001 From: L4168 <L4168@student.jamk.fi> Date: Wed, 3 Jul 2019 09:45:56 +0300 Subject: [PATCH] added listFactions for gm --- src/game/game.controller.ts | 7 +++++++ src/game/game.service.ts | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/game/game.controller.ts b/src/game/game.controller.ts index a97155c..015baf9 100644 --- a/src/game/game.controller.ts +++ b/src/game/game.controller.ts @@ -17,6 +17,7 @@ import { User } from '../user/user.decorator'; import { GameDTO, FlagboxEventDTO } from './game.dto'; import { ValidationPipe } from '../shared/validation.pipe'; import { Roles } from '../shared/roles.decorator'; +import { GameEntity } from './game.entity'; @Controller('game') export class GameController { @@ -48,6 +49,12 @@ export class GameController { return this.gameservice.returnGameInfo(id); } + @Get('get-factions/:id') + @Roles('admin') + async returnGameFactions(@Param('id') id: GameEntity) { + return this.gameservice.listFactions(id); + } + @Get('flag/:id') async flagboxQuery(@Param('id') id: string) { return this.gameservice.flagboxQuery(id); diff --git a/src/game/game.service.ts b/src/game/game.service.ts index 9a74a46..37f2e47 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -110,6 +110,10 @@ export class GameService { }; } + async listFactions(game: GameEntity) { + return this.factionRepository.find({ game }); + } + async deleteGame(id) { // TODO: Delete factions from Faction table associated with the deleted game await this.gameRepository.delete({ id }); -- GitLab