hufscheer / spectator-server

7 stars 0 forks source link

[FEAT] 리그에 해당하는 경기 전체 조회 #202

Closed Jin409 closed 2 months ago

Jin409 commented 3 months ago

🌍 이슈 번호

📝 구현 내용

🍀 확인해야 할 부분

게임의 상태를 분류하는 코드를 DTO 에 넣는 것이 적절할지 고민이 됩니당

 public static LeagueResponseWithGames of(League league, List<Game> games) {
        List<GameDetailResponse> playingGames = games.stream()
                .filter(g -> g.getState().equals(GameState.PLAYING)).map(GameDetailResponse::of).toList();

        List<GameDetailResponse> scheduledGames = games.stream()
                .filter(g -> g.getState().equals(GameState.SCHEDULED)).map(GameDetailResponse::of).toList();

        List<GameDetailResponse> finishedGames = games.stream()
                .filter(g -> g.getState().equals(GameState.FINISHED)).map(GameDetailResponse::of).toList();

        return new LeagueResponseWithGames(
                league.getId(), league.getName(), league.getLeagueTeams().size(),
                league.getMaxRound().getDescription(), league.getStartAt(), league.getEndAt(), playingGames,
                scheduledGames, finishedGames
        );
    }