Skip to content

Commit

Permalink
Merge pull request #230 from hufscheer/feat/#227-league
Browse files Browse the repository at this point in the history
[FEAT] 매니저가 생성한 리그와 리그의 경기중 게임 전체 조회 기능
  • Loading branch information
Zena0128 authored Sep 26, 2024
2 parents 9f12ecf + f4ed0de commit 5976ea7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public List<LeagueResponseWithInProgressGames> findLeaguesByManager(final Member
private Map<League, List<Game>> getGamesForLeague(List<League> leagues) {
return leagues.stream()
.collect(toMap(league -> league,
league -> gameQueryRepository.findPlayingGamesByLeagueWithGameTeams(league)));
gameQueryRepository::findPlayingGamesByLeagueWithGameTeams));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ public record LeagueResponseWithInProgressGames(
Long id,
String name,
String state,
int sizeOfLeagueTeams,
String maxRound,
LocalDateTime startAt,
LocalDateTime endAt,
List<GameDetailResponse> inProgressGames

) {
public static LeagueResponseWithInProgressGames of(League league, String state, List<Game> games) {
return new LeagueResponseWithInProgressGames(
league.getId(), league.getName(), state, league.getLeagueTeams().size(),
league.getMaxRound().getDescription(), league.getStartAt(), league.getEndAt(),
league.getId(), league.getName(), state,
games.stream()
.map(GameDetailResponse::of)
.toList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface LeagueQueryRepository extends Repository<League, Long>, LeagueQ

@Query(
"SELECT l FROM League l "
+ "JOIN FETCH l.leagueTeams "
+ "LEFT JOIN FETCH l.leagueTeams "
+ "WHERE l.manager =:member"
)
List<League> findByManager(Member member);
Expand Down
53 changes: 14 additions & 39 deletions src/main/resources/static/docs/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,7 @@ <h4 id="_게임_등록_http_request"><a class="link" href="#_게임_등록_http_
"round" : "16강",
"quarter" : "경기전",
"state" : "SCHEDULED",
"startTime" : "2024-09-18T18:41:01.634111",
"startTime" : "2024-09-22T13:58:05.288702",
"idOfTeam1" : 1,
"idOfTeam2" : 2,
"videoId" : "videoId"
Expand Down Expand Up @@ -2133,16 +2133,15 @@ <h4 id="_리그_생성_http_request"><a class="link" href="#_리그_생성_http_
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">POST /leagues HTTP/1.1
Content-Type: application/json
Content-Length: 179
Content-Length: 150
Host: www.api.hufstreaming.site
Cookie: HCC_SES=temp-cookie

{
"organizationId" : 1,
"name" : "우물정 제기차기 대회",
"maxRound" : "4강",
"startAt" : "2024-09-18T18:41:01.840974",
"endAt" : "2024-09-18T18:41:01.840975"
"maxRound" : 4,
"startAt" : "2024-09-22T13:58:05.536391",
"endAt" : "2024-09-22T13:58:05.536393"
}</code></pre>
</div>
</div>
Expand Down Expand Up @@ -2175,8 +2174,8 @@ <h4 id="_리그_생성_request_fields"><a class="link" href="#_리그_생성_req
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>maxRound</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">대회 진행 라운드 수</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Number</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">대회 진행 라운드 수. 결승은 2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>startAt</code></p></td>
Expand Down Expand Up @@ -2211,14 +2210,14 @@ <h4 id="_리그_수정_http_request"><a class="link" href="#_리그_수정_http_
<div class="content">
<pre class="highlightjs highlight nowrap"><code class="language-http hljs" data-lang="http">PUT /leagues/5124 HTTP/1.1
Content-Type: application/json
Content-Length: 166
Content-Length: 165
Host: www.api.hufstreaming.site
Cookie: HCC_SES=temp-cookie

{
"name" : "훕치치배 망고 빨리먹기 대회",
"startAt" : "2024-09-18T18:41:01.856257",
"endAt" : "2024-09-18T18:41:01.856261",
"startAt" : "2024-09-22T13:58:05.554006",
"endAt" : "2024-09-22T13:58:05.55401",
"maxRound" : "16강"
}</code></pre>
</div>
Expand Down Expand Up @@ -3090,20 +3089,16 @@ <h4 id="_매니저가_생성한_리그_전체_조회홈_화면_http_response"><a
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json
Content-Length: 633
Content-Length: 496

[ {
"id" : 1,
"name" : "삼건물 대회",
"state" : "진행 중",
"sizeOfLeagueTeams" : 2,
"maxRound" : "16강",
"startAt" : "2024-09-18T18:41:05.056959",
"endAt" : "2024-09-18T18:41:05.056959",
"inProgressGames" : [ {
"id" : 1,
"state" : "PLAYING",
"startTime" : "2024-09-18T18:41:05.056951",
"startTime" : "2024-09-22T13:58:08.963596",
"gameTeams" : [ {
"gameTeamId" : 1,
"gameTeamName" : "경영 야생마",
Expand Down Expand Up @@ -3152,26 +3147,6 @@ <h4 id="_매니저가_생성한_리그_전체_조회홈_화면_response_fields">
<td class="tableblock halign-left valign-top"><p class="tableblock">리그의 진행 상태 ex. 진행 중, 종료</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>[].sizeOfLeagueTeams</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Number</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">리그 팀의 수</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>[].maxRound</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">리그의 최대 라운드</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>[].startAt</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">리그 시작 날짜</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>[].endAt</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">리그 종료 날짜</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>[].inProgressGames</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Array</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">진행 중인 게임들</p></td>
Expand Down Expand Up @@ -4542,7 +4517,7 @@ <h4 id="_사용자_로그인_http_response"><a class="link" href="#_사용자_
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Set-Cookie: HCC_SES=testAccessToken; Path=/; Max-Age=604800; Expires=Wed, 25 Sep 2024 09:40:56 GMT; Secure; HttpOnly; SameSite=Strict</code></pre>
Set-Cookie: HCC_SES=testAccessToken; Path=/; Max-Age=604800; Expires=Sun, 29 Sep 2024 04:58:00 GMT; Secure; HttpOnly; SameSite=Strict</code></pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -4616,7 +4591,7 @@ <h4 id="_사용자_정보_조회_response_fields"><a class="link" href="#_사용
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2024-09-18 18:40:18 +0900
Last updated 2024-09-20 16:44:51 +0900
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ public class LeagueQueryControllerTest extends DocumentationTest {
);

List<LeagueResponseWithInProgressGames> responses = List.of(
new LeagueResponseWithInProgressGames(1L, "삼건물 대회", "진행 중", 2, "16강", LocalDateTime.now(),
LocalDateTime.now(), inProgressGames));
new LeagueResponseWithInProgressGames(1L, "삼건물 대회", "진행 중", inProgressGames));

Cookie cookie = new Cookie(COOKIE_NAME, "temp-cookie");

Expand All @@ -246,10 +245,6 @@ public class LeagueQueryControllerTest extends DocumentationTest {
fieldWithPath("[].name").type(JsonFieldType.STRING).description("리그의 이름"),
fieldWithPath("[].state").type(JsonFieldType.STRING)
.description("리그의 진행 상태 ex. 진행 중, 종료"),
fieldWithPath("[].sizeOfLeagueTeams").type(JsonFieldType.NUMBER).description("리그 팀의 수"),
fieldWithPath("[].maxRound").type(JsonFieldType.STRING).description("리그의 최대 라운드"),
fieldWithPath("[].startAt").type(JsonFieldType.STRING).description("리그 시작 날짜"),
fieldWithPath("[].endAt").type(JsonFieldType.STRING).description("리그 종료 날짜"),
fieldWithPath("[].inProgressGames").type(JsonFieldType.ARRAY).description("진행 중인 게임들"),
fieldWithPath("[].inProgressGames[].id").type(JsonFieldType.NUMBER)
.description("진행 중인 게임의 ID"),
Expand Down

0 comments on commit 5976ea7

Please sign in to comment.