Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be/feature/api PR #17

Merged
merged 22 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0f1bed2
Feature : 게임 상세페이지 구현
choitree May 7, 2021
a8bd322
Feature : 게임 공격/수비 페이지 구현
choitree May 7, 2021
d29f70c
Feature : 구조 변경에 따라 schema 변경
choitree May 7, 2021
5639403
Feature : 샘플 데이터 추가
choitree May 7, 2021
ef95de0
Feature : 게임 목록 구현
choitree May 7, 2021
2cb83e7
Fix : ballCount 테이블 분리
choitree May 7, 2021
49a1f9e
Fix : ballCount 테이블 분리
choitree May 7, 2021
13ddb85
Feature : ScoreRepository 메소드 추가
choitree May 7, 2021
d0c07ca
Feature : Game Score 로직 구현 (1차 수정)
choitree May 10, 2021
f40b66e
Feature : Game Score 로직 구현 (2차 수정)
choitree May 10, 2021
e93bc73
Feature : 상세페이지 확인하기 구현
choitree May 12, 2021
82f33ae
Feature : 수비/공격 페이지 구현 (get/put)
choitree May 12, 2021
84b69b3
chore : application.properties에 url 포트번호 수정
choitree May 12, 2021
0aa9e91
chore : 샘플데이터 추가
choitree May 12, 2021
92fb9c7
chore : 샘플데이터 추가
choitree May 12, 2021
ae9fe69
fix : 대소문자 구별
kyupid May 12, 2021
cc03335
fix : 버그 수정
choitree May 12, 2021
62ce68f
Merge branch 'tree/ballCount' of https://github.com/kyu-kim-kr/baseba…
choitree May 12, 2021
15c199e
fix : 포트번호 변경
kyupid May 12, 2021
ffac0f3
add : 선수 데이터 추가
kyupid May 13, 2021
54991a6
Add : /delete 기능 추가
choitree May 14, 2021
4163826
Merge pull request #20 from kyupid/tree/ballCount
kyupid Jul 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public DetailController(DetailService detailService) {
this.detailService = detailService;
}

@GetMapping("/{gameId}/homeTeam")
public DetailPageDTO showDetailpage(@PathVariable Long gameId) {
return detailService.showDetailpage(gameId);
@GetMapping("/{gameId}/{teamName}")
public DetailPageDTO showDetailpage(@PathVariable Long gameId, @PathVariable String teamName) {
return detailService.showDetailpage(gameId, teamName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@
import com.example.baseball.dto.MatchedTeamDTO;
import com.example.baseball.service.GameListService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GameListController {
public class GameListController {
private final GameListService gameListService;

public GameListController (GameListService gameListService) {
this.gameListService = gameListService;
}

@GetMapping("/matchTeam/{id}")
public MatchedTeamDTO findGame(@PathVariable Long id) {
return gameListService.findGame(id);
}

@GetMapping("/matchList")
public List<MatchedTeamDTO> findGameList() {
List<MatchedTeamDTO> games = gameListService.findGameList();
return games
return games;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.example.baseball.controller;

import com.example.baseball.dto.GameDTO;
import com.example.baseball.dto.PlayGameDTO;
import com.example.baseball.entity.InningStatus;
import com.example.baseball.service.GameScoreService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GameScoreController {

private GameScoreService gameScoreService;
Expand All @@ -12,9 +17,20 @@ public GameScoreController(GameScoreService gameScoreService) {
this.gameScoreService = gameScoreService;
}

@GetMapping("/game/attack}")
public GameDTO showAttackScreen() {
GameDTO gameDTO = gameScoreService.findGameDTO();
return gameDTO;
@GetMapping("/game/attack/{inning}/{inningStatus}")
public PlayGameDTO showAttackScreen(@PathVariable Integer inning, @PathVariable String inningStatus) {
return gameScoreService.findAttackGameDTO(inning, inningStatus);
}

// @GetMapping("/game/defense/{inning}/{inningStatus}")
// public GameDTO showDefenseScreen(@PathVariable Integer inning, @PathVariable String inningStatus) {
// return gameScoreService.findGameDTO(inning, inningStatus);
// }

// @PutMapping("/game/defense/{inning}/{inningStatus}")
// public GameDTO updatePitch(@PathVariable Integer inning, @PathVariable String inningStatus) {
// return gameScoreService.updatePitch(inning, inningStatus);
// }


}
38 changes: 38 additions & 0 deletions BE/src/main/java/com/example/baseball/dto/BallCountDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.example.baseball.dto;

import com.example.baseball.entity.BallCount;

public class BallCountDTO {

private Long id;
private String playerName;
private String ball;
private Long gameId;

public BallCountDTO(Long id, String playerName, String ball, Long gameId) {
this.id = id;
this.playerName = playerName;
this.ball = ball;
this.gameId = gameId;
}

public Long getId() {
return id;
}

public String getPlayerName() {
return playerName;
}

public String getBall() {
return ball;
}

public Long getGameId() {
return gameId;
}

public static BallCountDTO of(BallCount ballCount) {
return new BallCountDTO(ballCount.getId(), ballCount.getPlayerName(), ballCount.getBall().getStatus(),ballCount.getGameId());
}
}
18 changes: 8 additions & 10 deletions BE/src/main/java/com/example/baseball/dto/DetailPageDTO.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package com.example.baseball.dto;

import com.example.baseball.entity.Score;

import java.util.List;

public class DetailPageDTO {
Score score;
GameScoreResponseDTO gameScoreResponseDTO;
List<HalfInningGameResponseDTO> halfInningGameResponseDTOs;
List<PlayerResponseDTO> playerResponseDTOS;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 접근 제어자 바꿔줘야 할거 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 네네!!


public DetailPageDTO(Score score, List<HalfInningGameResponseDTO> halfInningGameResponseDTOs, List<PlayerResponseDTO> playerResponseDTOS) {
this.score = score;
public DetailPageDTO(GameScoreResponseDTO gameScoreResponseDTO, List<HalfInningGameResponseDTO> halfInningGameResponseDTOs, List<PlayerResponseDTO> playerResponseDTOS) {
this.gameScoreResponseDTO = gameScoreResponseDTO;
this.halfInningGameResponseDTOs = halfInningGameResponseDTOs;
this.playerResponseDTOS = playerResponseDTOS;
}

public Score getScore() {
return score;
public GameScoreResponseDTO getGameScoreResponseDTO() {
return gameScoreResponseDTO;
}

public List<HalfInningGameResponseDTO> getHalfInningGameResponseDTOs() {
Expand All @@ -27,14 +25,14 @@ public List<PlayerResponseDTO> getPlayerResponseDTOS() {
return playerResponseDTOS;
}

public DetailPageDTO of(Score score, List<HalfInningGameResponseDTO> halfInningGameResponseDTOs, List<PlayerResponseDTO> playerResponseDTOS) {
return new DetailPageDTO(score, halfInningGameResponseDTOs, playerResponseDTOS);
public DetailPageDTO of(GameScoreResponseDTO gameScoreResponseDTO, List<HalfInningGameResponseDTO> halfInningGameResponseDTOs, List<PlayerResponseDTO> playerResponseDTOS) {
return new DetailPageDTO(gameScoreResponseDTO, halfInningGameResponseDTOs, playerResponseDTOS);
}

@Override
public String toString() {
return "DetailPageDTO{" +
"score=" + score +
"gameScoreResponseDTO=" + gameScoreResponseDTO +
", halfInningGameResponseDTOs=" + halfInningGameResponseDTOs +
", playerResponseDTOS=" + playerResponseDTOS +
'}';
Expand Down
21 changes: 0 additions & 21 deletions BE/src/main/java/com/example/baseball/dto/GameDTO.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@
import com.example.baseball.entity.Score;

public class GameScoreResponseDTO {
private Long id;
private String homeTeam;
private String awayTeam;
private int homeScore;
private int awayScore;
private Integer homeScore;
private Integer awayScore;

public GameScoreResponseDTO(String homeTeam, String awayTeam, int homeScore, int awayScore) {
public GameScoreResponseDTO(Long id, String homeTeam, String awayTeam, Integer homeScore, Integer awayScore) {
this.id = id;
this.homeTeam = homeTeam;
this.awayTeam = awayTeam;
this.homeScore = homeScore;
this.awayScore = awayScore;
}

public Long getId() {
return id;
}

public String getHomeTeam() {
return homeTeam;
}
Expand All @@ -23,15 +29,15 @@ public String getAwayTeam() {
return awayTeam;
}

public int getHomeScore() {
public Integer getHomeScore() {
return homeScore;
}

public int getAwayScore() {
public Integer getAwayScore() {
return awayScore;
}

public static GameScoreResponseDTO of(Score score) {
return new GameScoreResponseDTO(score.getHomeTeam(), score.getAwayTeam(), score.getHomeScore(), score.getAwayScore());
return new GameScoreResponseDTO(score.getId(), score.getHomeTeam(), score.getAwayTeam(), score.getHomeScore(), score.getAwayScore());
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
package com.example.baseball.dto;

import com.example.baseball.entity.BallCount;
import com.example.baseball.entity.Game;
import com.example.baseball.entity.InningStatus;

public class HalfInningGameResponseDTO {

private Long id;

private String homeTeam;
private String awayTeam;
private Integer homeScore;
private Integer awayScore;
private Integer inning;
private InningStatus status; //Enum으로 관리
private BallCount ballCount;
private String inningStatus; //Enum으로 관리
private Long scoreId;

public HalfInningGameResponseDTO(String homeTeam, String awayTeam, Integer homeScore, Integer awayScore, Integer inning, InningStatus status, BallCount ballCount) {
public HalfInningGameResponseDTO(Long id, String homeTeam, String awayTeam, Integer homeScore, Integer awayScore, Integer inning, String inningStatus, Long scoreId) {
this.id = id;
this.homeTeam = homeTeam;
this.awayTeam = awayTeam;
this.homeScore = homeScore;
this.awayScore = awayScore;
this.inning = inning;
this.status = status;
this.ballCount = ballCount;
this.inningStatus = inningStatus;
this.scoreId = scoreId;
}

public Long getId() {
return id;
}

public String getHomeTeam() {
Expand All @@ -44,24 +49,24 @@ public Integer getInning() {
return inning;
}

public InningStatus getStatus() {
return status;
public String getInningStatus() {
return inningStatus;
}

public BallCount getBallCount() {
return ballCount;
public Long getScoreId() {
return scoreId;
}


public static HalfInningGameResponseDTO of(Game game) {
return new HalfInningGameResponseDTO(
game.getId(),
game.getHomeTeam(),
game.getAwayTeam(),
game.getHomeScore(),
game.getAwayScore(),
game.getInning(),
game.getStatus(),
game.getBallCount()
game.getInningStatus().getStatus(),
game.getScoreId()
);
}
}
Expand Down
7 changes: 3 additions & 4 deletions BE/src/main/java/com/example/baseball/dto/MatchedTeamDTO.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.example.baseball.dto;

import com.example.baseball.entity.Game;
import org.springframework.data.annotation.Id;
import com.example.baseball.entity.Score;

public class MatchedTeamDTO {
@Id
private Long id;

private String homeTeam;
Expand All @@ -28,8 +27,8 @@ public String getAwayTeam() {
return awayTeam;
}

public static MatchedTeamDTO of(Game game) {
return new MatchedTeamDTO(game.getId(), game.getHomeTeam(), game.getAwayTeam());
public static MatchedTeamDTO of(Score score) {
return new MatchedTeamDTO(score.getId(), score.getHomeTeam(), score.getAwayTeam());
}

}
34 changes: 34 additions & 0 deletions BE/src/main/java/com/example/baseball/dto/PlayGameDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.baseball.dto;

import java.util.ArrayList;
import java.util.List;

public class PlayGameDTO {
private GameScoreResponseDTO gameScoreResponseDTO;
private HalfInningGameResponseDTO halfInningGameResponseDTO;
private List<PlayerResponseDTO> players = new ArrayList<>(2); //0 :투수, 1 :타자
private List<BallCountDTO> ballCounts;

public PlayGameDTO(GameScoreResponseDTO gameScoreResponseDTO, HalfInningGameResponseDTO halfInningGameResponseDTO, List<PlayerResponseDTO> players, List<BallCountDTO> ballCounts) {
this.gameScoreResponseDTO = gameScoreResponseDTO;
this.halfInningGameResponseDTO = halfInningGameResponseDTO;
this.players = players;
this.ballCounts = ballCounts;
}

public GameScoreResponseDTO getGameScoreResponseDTO() {
return gameScoreResponseDTO;
}

public HalfInningGameResponseDTO getHalfInningGameResponseDTO() {
return halfInningGameResponseDTO;
}

public List<PlayerResponseDTO> getPlayers() {
return players;
}

public List<BallCountDTO> getBallCounts() {
return ballCounts;
}
}