-
Notifications
You must be signed in to change notification settings - Fork 464
[4단계 - 체스] 미아(이종미) 미션 제출합니다. #778
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
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
504a565
feat(PieceValue): PieceValue 캐싱
jongmee 782a065
build: mysql 의존성 설정
jongmee eb6ef8d
feat(MySqlConnection): mysql 연결 설정 클래스 생성
jongmee 4cf7ab7
feat(ChessBoardDao): 체스보드를 생성하고 id로 조회한다
jongmee bac7a37
feat(PieceDao): 특정 ChessBoard의 Piece를 저장하고 수정한다
jongmee b78d303
feat(TurnDao): 게임 차례를 저장하고 조회한다
jongmee 0572b66
refactor(StatementExecutor, ResultSetMapper): dao 리팩토링
jongmee 0388c70
refactor: dao 메소드 이름 변경
jongmee 004f830
feat(DataAccessException): dao 관련 커스텀 예외 생성
jongmee 89c3a2e
refactor: respository 패키지 구조 변경
jongmee 2330ed8
fix: ChessBoard의 id 를 long type으로 변경
jongmee 9ce63d3
feat(ChessGameService): 체스보드, 기물, 게임 차례를 어플리케이션에서 저장한다
jongmee 722a81d
feat(ChessBoardDao): 가장 최근 저장된 체스 보드 id를 조회한다
jongmee f9528f3
fix(ChessBoardDao): 가장 최근에 생성된 체스 보드를 조회한다.
jongmee 0bd4e1a
fix(ChessGameService): 이미 생성된 게임 차례가 있다면 새로 생성하지 않는다
jongmee f438b00
refactor(ChessBoardDao): ResultSetMapper 로직 리팩토링
jongmee 802c781
fix(ChessGameService): 게임 차례를 바꿀 때 기존 차례를 삭제한다
jongmee 4910aa9
feat(ChessBoardDao): ChessBoard에 게임 결과를 저장한다
jongmee 4adc0d9
fix(ChessBoardDao): 최근 체스보드 조회시 '진행중'인 것만 조회한다
jongmee 5653b5b
feat(ChessBoardDao): 게임 결과를 저장하고 조회한다
jongmee 336534e
feat: 최종 게임 결과를 판단하고 저장한다
jongmee 4fea615
feat: 이전 체스 게임 결과 목록을 조회한다
jongmee 121644a
chore(OutputView): 게임 안내 문구 수정
jongmee cbe6fa3
refactor: 불필요한 싱글톤 제거
jongmee fdadbd7
chore(MySqlConnection): 환경 변수 설정
jongmee 56d6e99
build: mysql docker 설정 및 MySqlConnector 설정 변경
jongmee 47ab38a
chore(ChessBoardDao): 쿼리 문자열 수정
jongmee 7aef379
docs: step4 기능 추가
jongmee d63dc73
remove(TurnMapper): TurnMapper getter로 대체
jongmee aa7d3ef
remove(ChessBoardGenerator): ChessBoardGenerator 인터페이스 삭제
jongmee 5fe009b
style: sql 포매팅
jongmee 15fa090
remove(PropertyLoadException): 사용하지 않는 exception 제거
jongmee 561f7d2
feat: 플레이어가 서로 합의하여 무승부가 될 수 있다
jongmee dd52c74
chore(OutputView): 게임 시작 문구 변경
jongmee 7f28d79
refactor(GameState): Move, Summarize state 생성
jongmee bb5087c
test(ChessGameServiceTest): ChessGameService 통합 테스트 추가
jongmee 1fb6789
chore: test용 ddl 별개의 파일로 분리
jongmee d32ea66
refactor: repository 패키지의 utility 패키지명 변경
jongmee 612db51
test(ChessBoardDaoTest): Optional 사용 로직 수정
jongmee cb48c6f
test: DB 연동 테스트 시 BeforeEach를 AfterEach로 변경
jongmee 07d3742
feat: turn 테이블 삭제, chess_board에 turn 속성 추가
jongmee 6e6f9be
refactor: 초기 체스판 조회시 게임 차례도 함께 조회
jongmee 8323757
refactor(MySqlConnector): 테스트와 프로덕션 db connection을 따로 관리
jongmee f64e100
chore: chess_board id 컬럼명 변경
jongmee a418e73
refactor(ChessBoardDao): 쿼리에서 컬럼 이름 변경
jongmee 8edc646
fix: ddl 오타 수정
jongmee 99ef558
fix: ddl 오타 수정
jongmee 9dfa5b9
refactor: repository에서 dao로 패키지명 변경
jongmee 8f32164
remove(MySqlConnectionTest): db 연결 테스트 삭제
jongmee 6b24c62
fix: db connection과 ddl 실행하는 계정 변경
jongmee a8677e5
docs: db 스키마 다이어그램 추가
jongmee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,3 +30,7 @@ out/ | |
|
|
||
| ### VS Code ### | ||
| .vscode/ | ||
|
|
||
| ## 설정 파일 ## | ||
| /src/main/resources | ||
| /src/test/resources | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| GRANT ALL PRIVILEGES ON *.* TO 'user'@'%'; | ||
| FLUSH PRIVILEGES; | ||
|
|
||
| CREATE DATABASE IF NOT EXISTS `chess` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; | ||
|
|
||
| USE chess; | ||
|
|
||
| CREATE TABLE chess_board | ||
| ( | ||
| id BIGINT NOT NULL AUTO_INCREMENT, | ||
| created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| game_result VARCHAR(15) NOT NULL, | ||
| turn VARCHAR(10) NOT NULL, | ||
| PRIMARY KEY (id) | ||
| ); | ||
|
|
||
| CREATE TABLE piece | ||
| ( | ||
| file VARCHAR(10) NOT NULL, | ||
| `rank` INT NOT NULL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (반영하지 않으셔도 됩니다.) 예약어는 현재처럼(`를 붙여야하는) 제약사항이 존재하기 때문에 가능하면 db에서 네이밍은 예약어를 피하려는 편입니다.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. level2에서 db를 많이 활용할 때 예약어를 피해서 설계해보도록 하겠습니다! 감사합니다 😊 |
||
| type VARCHAR(10) NOT NULL, | ||
| chess_board_id BIGINT NOT NULL, | ||
| side VARCHAR(10) NOT NULL, | ||
| FOREIGN KEY (`chess_board_id`) REFERENCES `chess_board` (`id`), | ||
| PRIMARY KEY (file, `rank`, chess_board_id) | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| CREATE DATABASE IF NOT EXISTS `chess_test` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; | ||
|
|
||
| USE chess_test; | ||
|
|
||
| CREATE TABLE chess_board | ||
| ( | ||
| id BIGINT NOT NULL AUTO_INCREMENT, | ||
| created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| game_result VARCHAR(15) NOT NULL, | ||
| turn VARCHAR(10) NOT NULL, | ||
| PRIMARY KEY (id) | ||
| ); | ||
|
|
||
| CREATE TABLE piece | ||
| ( | ||
| file VARCHAR(10) NOT NULL, | ||
| `rank` INT NOT NULL, | ||
| type VARCHAR(10) NOT NULL, | ||
| chess_board_id BIGINT NOT NULL, | ||
| side VARCHAR(10) NOT NULL, | ||
| FOREIGN KEY (`chess_board_id`) REFERENCES `chess_board` (`id`), | ||
| PRIMARY KEY (file, `rank`, chess_board_id) | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| version: "3.9" | ||
| services: | ||
| db: | ||
| image: mysql:8.0.28 | ||
| platform: linux/x86_64 | ||
| restart: always | ||
| ports: | ||
| - "13306:3306" | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: root | ||
| MYSQL_USER: user | ||
| MYSQL_PASSWORD: password | ||
| TZ: Asia/Seoul | ||
| volumes: | ||
| - ./db/mysql/init:/docker-entrypoint-initdb.d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,10 @@ | ||
| package chess; | ||
|
|
||
| import chess.controller.ChessGame; | ||
| import chess.view.input.InputView; | ||
| import chess.view.output.OutputView; | ||
|
|
||
| public class Application { | ||
| public static void main(String[] args) { | ||
| InputView inputView = new InputView(); | ||
| OutputView outputView = new OutputView(); | ||
| ChessGame chessGame = new ChessGame(inputView, outputView); | ||
| ChessGame chessGame = new ChessGame(); | ||
| chessGame.start(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| package chess.controller; | ||
|
|
||
| import chess.service.ChessGameService; | ||
| import chess.view.input.InputView; | ||
| import chess.view.output.OutputView; | ||
|
|
||
| public interface GameState { | ||
| GameState run(InputView inputView, OutputView outputView); | ||
| GameState run(InputView inputView, OutputView outputView, ChessGameService chessGameService); | ||
| boolean canContinue(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package chess.controller; | ||
|
|
||
| import chess.model.board.ChessBoard; | ||
| import chess.model.board.Turn; | ||
| import chess.service.ChessGameService; | ||
| import chess.view.input.InputView; | ||
| import chess.view.input.MoveArguments; | ||
| import chess.view.output.OutputView; | ||
|
|
||
| public class Move implements GameState { | ||
| private final ChessBoard chessBoard; | ||
| private final Turn turn; | ||
| private final MoveArguments moveArguments; | ||
|
|
||
| public Move(ChessBoard chessBoard, Turn turn, MoveArguments moveArguments) { | ||
| this.chessBoard = chessBoard; | ||
| this.turn = turn; | ||
| this.moveArguments = moveArguments; | ||
| } | ||
|
|
||
| @Override | ||
| public GameState run(InputView inputView, OutputView outputView, ChessGameService chessGameService) { | ||
| chessGameService.move(chessBoard, turn, moveArguments); | ||
| outputView.printChessBoard(chessBoard); | ||
| Turn nextTurn = chessGameService.saveNextTurn(chessBoard, turn); | ||
| return new Run(chessBoard, nextTurn); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean canContinue() { | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runtimeOnly는 어떤 기능으로 동작할까요? implementation, compileOnly, api와 무슨 차이가 있을까요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compileOnly은 컴파일에 의존하는 모듈들을 컴파일패스에 설정하고, runtimeOnly는 런타임에 의존하는 모듈들을 런타임패스에 설정하는 것이 좋습니다. 따라서 runtimeOnly는 DB 의존성에 사용하는 것이 좋습니다.
implementation과 api의 차이는 잘 몰라서 추가로 찾아보았습니다!
implementation과 api는 컴파일패스, 런타임패스에 모두 저장하는데, api는 전이 의존성을 허용하고 implementation은 허용하지 않습니다. implementation이 컴파일이 빠르고 재컴파일 횟수가 줄어들어 더 권장됩니다. 또한 전이 종속성에 실수로 빠지지 않습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api의 경우 해당 문제때문에 의존성의 방향이 한단계 밑으로 내려가서 사용을 지양하는 편이긴해요. 대부분의 예제가 그런 이유로 implementation을 예제로 뿌려주기도하구요.