From 6aa30fbb25f05dfb659d99d5d93a59e47e547633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8B=E1=85=B5=E1=84=89?= =?UTF-8?q?=E1=85=A1=E1=86=A8?= Date: Fri, 7 May 2021 12:21:17 +0900 Subject: [PATCH] [#6] feat: Implements getting game list API --- .../java/team9/baseball/controller/ApiGameController.java | 5 +++++ .../src/main/java/team9/baseball/service/GameService.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/BE/baseball/src/main/java/team9/baseball/controller/ApiGameController.java b/BE/baseball/src/main/java/team9/baseball/controller/ApiGameController.java index de9a59107..2d3f27533 100644 --- a/BE/baseball/src/main/java/team9/baseball/controller/ApiGameController.java +++ b/BE/baseball/src/main/java/team9/baseball/controller/ApiGameController.java @@ -17,6 +17,11 @@ public ApiGameController(GameService gameService) { this.gameService = gameService; } + @GetMapping("/list") + public ApiResult getGameDescriptions() { + return ApiResult.succeed(gameService.getAllGameList()); + } + @PostMapping public ApiResult createGame() { gameService.createNewGame(1l, 1, 2); diff --git a/BE/baseball/src/main/java/team9/baseball/service/GameService.java b/BE/baseball/src/main/java/team9/baseball/service/GameService.java index d9fd1acb3..c8215169b 100644 --- a/BE/baseball/src/main/java/team9/baseball/service/GameService.java +++ b/BE/baseball/src/main/java/team9/baseball/service/GameService.java @@ -2,6 +2,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import team9.baseball.DTO.response.GameDescriptionDTO; import team9.baseball.DTO.response.GameStatusDTO; import team9.baseball.domain.aggregate.game.Game; import team9.baseball.domain.aggregate.team.Team; @@ -13,6 +14,8 @@ import team9.baseball.repository.TeamRepository; import team9.baseball.repository.UserRepository; +import java.util.List; + @Service public class GameService { private final GameRepository gameRepository; @@ -90,6 +93,10 @@ public void joinGame(long userId, long gameId, Venue venue) { userRepository.save(user); } + public List getAllGameList() { + return gameRepository.findAllGameDescription(); + } + private User getUser(long userId) { return userRepository.findById(userId).orElseThrow(() -> new NotFoundException(userId + " 사용자는 존재하지 않습니다.")); }