-
Notifications
You must be signed in to change notification settings - Fork 166
[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๊ธฐ๋ฌผ ํ์ฅ + DB ์ ์ฉ)] ํ์ค ๋ฏธ์ ์ ์ถํฉ๋๋ค. #340
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
75 commits
Select commit
Hold shift + click to select a range
df9326e
docs: ๊ธฐ๋ฅ๋ชฉ๋ก ์์ฑ
ghkdtjfxkd a011878
feat: ์ด๋ ์ ๋ต ๋๋ฉ์ธ ์ค์ผ๋ ํค ์์ฑ
ghkdtjfxkd cf2c421
merge: step1-pre into step1
ghkdtjfxkd f9f48d0
feat: ์ด๋ ์ ๋ต ์ฅ๊ตฐ -> ๋ชฉ์ ์ง ์ด๋ ๊ฐ๋ฅ ์ฌ๋ถ ๊ตฌํ
yj9107v bb0c9a5
refactor: ์ฌ์ฉํ์ง ์๋ ํ๋ ์ ๊ฑฐ
ghkdtjfxkd 711297d
feat: ์ฌ ์ด๋ ๊ฐ๋ฅ ์ฌ๋ถ ํ์ธ ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd 4d33f90
feat: ์ด๋ ์ ๋ต ์กธ(์ด/ํ) -> ๋ชฉ์ ์ง ์ด๋ ๊ฐ๋ฅ ์ฌ๋ถ ๊ตฌํ
yj9107v 1d59f24
wip: ์๊ตฌ ์ฌํญ ๋ฐ์์ ์ํ ์์ ์ ์ฅ
ghkdtjfxkd 4603de9
feat: ์ฅ๊ธฐํ ๊ธฐ๋ฌผ ์ด๊ธฐํ ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd 86078f8
wip: ๋ง ์ด๋ ๊ตฌํ ์ค ๋๋ผ์ด๋ฒ ๋ณ๊ฒฝ
yj9107v 6f8377b
feat: ๋ง ์ด๋ ๊ท์น ์ถ๊ฐ
ghkdtjfxkd 1372e03
merge: step1-personal into step1
ghkdtjfxkd 3f33629
feat: ์ ๊ธฐ๋ฌผ ์ด๋ ๊ตฌํ
yj9107v b5fb478
docs: ์ ๊ธฐ๋ฌผ ์ด๋ ๊ตฌํ ์๋ฃ
yj9107v 774073a
feat: ์ฐจ ๊ธฐ๋ฌผ ์ด๋ ๊ตฌํ ์๋ฃ
yj9107v 4b689ae
refactor: MoveStrategy API ๋ฉ์๋ ๋ค์ด๋ฐ ๋ณ๊ฒฝ
ghkdtjfxkd aeea4d3
feat: ํฌ ์ด๋ ์ ๋ต ์ถ๊ฐ
ghkdtjfxkd cf1f512
docs: ๋๋ฝ๋ ํญ๋ชฉ๋ค ๋ฐ์
ghkdtjfxkd ccfede6
feat: ์ฅ๊ธฐํ ๊ธฐ๋ฌผ์ด ์ด๋ ๊ฐ๋ฅ ์ฌ๋ถ ํ์ธ ๊ธฐ๋ฅ ์ถ๊ฐ
yj9107v 5c6426a
feat: ๊ธฐ๋ฌผ ์ด๋ ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd dabf867
feat: ์ฅ๊ธฐ ๊ฒ์ ํ๋ ์ด์ด ์ ํ ๊ธฐ๋ฌผ ๋ฐ ๋ชฉ์ ์ง ์ด๋ ๊ฒ์ฆ ์ถ๊ฐ
yj9107v 641e6a0
wip: ๋ฆฌํฉํ ๋ง ์ ์์ ์ ์ฅ
ghkdtjfxkd a83b41d
refactor: ๊ธฐ๋ฌผ ๋คํ์ฑ ๋ณ๊ฒฝ
ghkdtjfxkd c783237
test: ๊ธฐ๋ฌผ ์์ง์ ํ
์คํธ ์ถ๊ฐ
ghkdtjfxkd cef2f61
merge: refactor-piece into step1
ghkdtjfxkd e20dd87
fix: ๊ธฐ๋ฌผ์ด ์ด๋์ ์ฑ๊ณตํ๋ฉด ๊ธฐ๋ฌผ์ ์์น๊ฐ ๋ณ๊ฒฝ๋๊ฒ ์์
yj9107v 3f2b921
feat: ํฌ๋ ํฌ๋ฅผ ๋์ง ๋ชปํ๋ ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd 1713fac
feat: ํฌ์ ์ด๋ ๊ท์น ์ถ๊ฐ
yj9107v 59979cb
feat: ํฌ์ ์ด๋ ๊ท์น ์ถ๊ฐ
yj9107v ca34273
chore: ์ปจํธ๋กค๋ฌ ์ค์ผ๋ ํค ์ถ๊ฐ
ghkdtjfxkd d22822c
feat: ์ปจํธ๋กค๋ฌ ์ถ๊ฐ ๋ฐ ๊ฒ์ ์งํ ๊ตฌํ
ghkdtjfxkd 35f8a1d
refactor: JanggiGame ์์ธ ์์ ๋ฐ ํจํค์ง ๊ตฌ์กฐ ๋ณ๊ฒฝ
ghkdtjfxkd 10943e7
refactor: JanggiGame ๊ตฌ์กฐ ์ผ๋ถ ๋ณ๊ฒฝ
ghkdtjfxkd 39c82d0
refactor: PieceProperty ๋ณ๊ฒฝ์ ๋ฐ๋ฅธ ์ด๋ ์ ๋ต ๋ด๋ถ ๋ณ๊ฒฝ
ghkdtjfxkd 9fd033a
refactor: ๊ถ ์ด๋ ์ ๋ต ๋ด๋ถ ๋ณ๊ฒฝ
ghkdtjfxkd aa1ba94
refactor: ์ด๋ ๊ท์น ๋ฆฌํฉํ ๋ง
ghkdtjfxkd 33dc115
refactor: ์ฅ๊ธฐํ ๋ฒ์ ์ ๊ฒ ์ฑ
์ ์ด๋
ghkdtjfxkd 6a9dfe4
refactor: ์กธ ์ด๋ ์ ๋ต ๋ด๋ถ ๋ฆฌํฉํ ๋ง
ghkdtjfxkd 63349a6
refactor: ์ ์ด๋ ์ ๋ต ๋ด๋ถ ๋ณ๊ฒฝ
ghkdtjfxkd 73f2ac4
refactor: Board ๋ด๋ถ ์ ๋ฆฌ
ghkdtjfxkd 64f0661
refactor: ํฌ ๋ด๋ถ ์ ๋ฆฌ
ghkdtjfxkd 64206c8
merge: step1-refactor into step1
ghkdtjfxkd 554b18b
refactor: ์์ธ ํ์ ์ถ๊ฐ
ghkdtjfxkd a874f60
refactor: Controller์ ์ถ๋ ฅ ์ฑ
์ ์ด๋
ghkdtjfxkd 939e21f
refactor: ์ฐจ ์ด๋๋ก์ง ๋ด๋ถ ๋ฆฌํฉํ ๋ง
ghkdtjfxkd fa4c5e1
refactor: cleanup
ghkdtjfxkd 1b21a22
docs: README.md ๋๋ฝ๋ ํญ๋ชฉ ๋ฐ์
ghkdtjfxkd ba3e25a
chore: ์ฌ์ํ ์์
ghkdtjfxkd 597c980
feat: ๊ถ์ฑ ์์น ํ์ธ ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd 5720588
merge: step1-refactor into step1
ghkdtjfxkd 8010683
wip: rebase ์ ์์ ์ ์ฅ
ghkdtjfxkd 2ea99a6
fix: merge ์ถฉ๋ ํด๊ฒฐ
ghkdtjfxkd 6d6c1e2
feat: ๊ถ์ฑ ๊ธฐ๋ฌผ ์ด๋ ์ ๋ต ์ถ๊ฐ
ghkdtjfxkd a6a9540
refactor: cleanup
ghkdtjfxkd 6260fc7
feat: ์ด๋๋ผ ์กธ์ ๊ถ์ฑ ๋ด๋ถ ์ด๋ ๊ท์น ์ถ๊ฐ
ghkdtjfxkd 23b94d9
feat: ํ๋๋ผ ์กธ์ ๊ถ์ฑ ๋ด๋ถ ์ด๋ ๊ท์น ์ถ๊ฐ
ghkdtjfxkd b0b18ca
merge: step2-soldier into step2
ghkdtjfxkd 96fb026
feat: ํฌ์ ๊ถ์ฑ ๋ด๋ถ ์ด๋ ๊ท์น ์ถ๊ฐ
ghkdtjfxkd ba584ad
feat: ํฌ์ ์ฐจ์ ๊ถ์ฑ ์ด๋ ๊ท์น ์ถ๊ฐ
ghkdtjfxkd 12c191c
refactor: ์๊ณผ ๋ง ๋ด๋ถ ๋ฆฌํฉํ ๋ง
ghkdtjfxkd e49ec2e
feat: ์ฌ๋ฐ๋ฅด์ง ์์ ํ์ ์
๋ ฅ ์ ์์ธ ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd ab9fc0a
refactor: DB ๋์
์ ์ค์ผ๋ ํค ์์ฑ
ghkdtjfxkd 6c1bdcb
refactor: Jdbc ์ ์ฅ์ ์ถ๊ฐ ๋ฐ HikariCP ์์กด์ฑ ์ถ๊ฐ
ghkdtjfxkd 1e08a60
feat: DB ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd de4c844
merge: step2-db into step2
ghkdtjfxkd ad52e57
feat: ์ข
๋ฃ๋์ง ์์ ๊ฒ์ ์ ํ ๋ฐ ์ด์ดํ๊ธฐ ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd 2a95f16
merge: step2-db into step2
ghkdtjfxkd 19a46d9
feat: ์ ์ ํฉ ๊ณ์ฐ ๊ธฐ๋ฅ ์ถ๊ฐ
ghkdtjfxkd 55c7232
merge: step2-point into step2
ghkdtjfxkd d78521b
fix: gameSnapshot์ด ์์ด๋ ๋ฌธ์ ํด๊ฒฐ
ghkdtjfxkd 0c16b29
refactor: ๊ฒ์ ID ์
๋ ฅ์ Dto๋ฅผ ์ฌ์ฉํ๋๋ก ๋ณ๊ฒฝ
ghkdtjfxkd efcaef8
refactor: ๊ฒ์ id ์กฐํ ์ฒ๋ฆฌ
ghkdtjfxkd eac763b
test: repository, service ํ
์คํธ ์ถ๊ฐ
ghkdtjfxkd 65b9aa5
refactor: cleanup
ghkdtjfxkd cad20bd
merge: step2-feedback into step2
ghkdtjfxkd 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
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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,17 +1,9 @@ | ||
| import config.JanggiConfig; | ||
| import controller.JanggiController; | ||
| import domain.Board; | ||
| import domain.GameStatus; | ||
| import domain.JanggiGame; | ||
| import factory.JanggiBoardFactory; | ||
|
|
||
| public class Application { | ||
| public static void main(String[] args) { | ||
| JanggiBoardFactory janggiBoardFactory = new JanggiBoardFactory(); | ||
| Board board = Board.of(janggiBoardFactory.initialBoard()); | ||
|
|
||
| JanggiGame janggiGame = new JanggiGame(board, GameStatus.GREEN_PLAYER_TURN); | ||
| JanggiController janggiController = new JanggiController(janggiGame); | ||
|
|
||
| JanggiController janggiController = JanggiConfig.setupController(); | ||
| janggiController.run(); | ||
| } | ||
| } |
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,57 @@ | ||
| package config; | ||
|
|
||
| import com.zaxxer.hikari.HikariConfig; | ||
| import com.zaxxer.hikari.HikariDataSource; | ||
| import controller.JanggiController; | ||
| import dao.JanggiGameDao; | ||
| import dao.JanggiGameStateDao; | ||
| import infrastructure.TransactionContext; | ||
| import java.sql.Connection; | ||
| import java.sql.SQLException; | ||
| import java.sql.Statement; | ||
| import javax.sql.DataSource; | ||
| import repository.JanggiRepository; | ||
| import repository.JdbcJanggiRepository; | ||
| import service.JanggiCommandService; | ||
| import service.JanggiQueryService; | ||
|
|
||
| public class JanggiConfig { | ||
|
|
||
| public static JanggiController setupController() { | ||
| JanggiRepository janggiRepository = setupJanggiRepository(); | ||
|
|
||
| JanggiCommandService janggiCommandService = new JanggiCommandService(janggiRepository); | ||
| JanggiQueryService janggiQueryService = new JanggiQueryService(janggiRepository); | ||
|
|
||
| return new JanggiController(janggiCommandService, janggiQueryService); | ||
| } | ||
|
|
||
| private static DataSource dataSource() { | ||
| HikariConfig config = new HikariConfig(); | ||
| config.setJdbcUrl("jdbc:h2:file:./janggi_db;MODE=MySQL"); | ||
| config.setUsername("root"); | ||
| config.setPassword("password"); | ||
| return new HikariDataSource(config); | ||
| } | ||
|
|
||
| private static JdbcJanggiRepository setupJanggiRepository() { | ||
| DataSource dataSource = dataSource(); | ||
| try { | ||
| initSchema(dataSource); | ||
| } catch (SQLException e) { | ||
| throw new RuntimeException("์คํค๋ง ์ด๊ธฐํ ์คํจ", e); | ||
| } | ||
| TransactionContext.init(dataSource); | ||
| return new JdbcJanggiRepository( | ||
| new JanggiGameDao(), | ||
| new JanggiGameStateDao() | ||
| ); | ||
| } | ||
|
|
||
| private static void initSchema(DataSource dataSource) throws SQLException { | ||
| try (Connection conn = dataSource.getConnection(); | ||
| Statement stmt = conn.createStatement()) { | ||
| stmt.execute("RUNSCRIPT FROM 'classpath:schema.sql'"); | ||
| } | ||
| } | ||
| } |
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,6 +1,8 @@ | ||
| package controller; | ||
|
|
||
| import exception.JanggiGameException; | ||
|
|
||
| @FunctionalInterface | ||
| interface ExecutableTask { | ||
| void execute() throws IllegalArgumentException; | ||
| void execute() throws JanggiGameException; | ||
| } |
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,113 @@ | ||
| package dao; | ||
|
|
||
| import dto.PieceSnapshot; | ||
| import dto.UnfinishedGameInfo; | ||
| import infrastructure.TransactionContext; | ||
| import java.sql.PreparedStatement; | ||
| import java.sql.ResultSet; | ||
| import java.sql.SQLException; | ||
| import java.sql.Statement; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| public class JanggiGameDao { | ||
|
|
||
| public long insertGame(List<PieceSnapshot> pieces) throws SQLException { | ||
| long gameId = insert(); | ||
| insertPieces(gameId, pieces); | ||
| return gameId; | ||
| } | ||
|
|
||
| public long updateGame(long gameId, List<PieceSnapshot> pieces) throws SQLException { | ||
| deletePieces(gameId); | ||
| insertPieces(gameId, pieces); | ||
| return gameId; | ||
| } | ||
|
|
||
| private long insert() throws SQLException { | ||
| String sql = "INSERT INTO game (created_at) VALUES (NOW())"; | ||
|
|
||
| try (PreparedStatement ps = TransactionContext.getPreparedStatement(sql, Statement.RETURN_GENERATED_KEYS)) { | ||
| ps.executeUpdate(); | ||
|
|
||
| ResultSet keys = ps.getGeneratedKeys(); | ||
| if (keys.next()) { | ||
| return keys.getLong(1); | ||
| } | ||
| throw new SQLException("game INSERT ํ id ํ๋ ์คํจ"); | ||
| } | ||
| } | ||
|
|
||
| private void deletePieces(long gameId) throws SQLException { | ||
| String sql = "DELETE FROM piece WHERE game_id = ?"; | ||
| try (PreparedStatement ps = TransactionContext.getPreparedStatement(sql)) { | ||
| ps.setLong(1, gameId); | ||
| ps.executeUpdate(); | ||
| } | ||
| } | ||
|
|
||
| private void insertPieces(long gameId, List<PieceSnapshot> pieces) throws SQLException { | ||
| String sql = "INSERT INTO piece (game_id, pos_row, pos_col, piece_name, team) VALUES (?, ?, ?, ?, ?)"; | ||
|
|
||
| try (PreparedStatement ps = TransactionContext.getPreparedStatement(sql)) { | ||
| for (PieceSnapshot piece : pieces) { | ||
| ps.setLong(1, gameId); | ||
| ps.setInt(2, piece.row()); | ||
| ps.setInt(3, piece.col()); | ||
| ps.setString(4, piece.name()); | ||
| ps.setString(5, piece.team()); | ||
| ps.addBatch(); | ||
| } | ||
| ps.executeBatch(); | ||
| } | ||
| } | ||
|
|
||
| public List<PieceSnapshot> findAllPieces(long gameId) throws SQLException { | ||
| String sql = "SELECT pos_row, pos_col, piece_name, team FROM piece WHERE game_id = ?"; | ||
|
|
||
| try (PreparedStatement ps = TransactionContext.getPreparedStatement(sql)) { | ||
| ps.setLong(1, gameId); | ||
|
|
||
| ResultSet rs = ps.executeQuery(); | ||
| List<PieceSnapshot> pieces = new ArrayList<>(); | ||
| while (rs.next()) { | ||
| pieces.add(PieceSnapshot.from( | ||
| rs.getInt("pos_row"), | ||
| rs.getInt("pos_col"), | ||
| rs.getString("piece_name"), | ||
| rs.getString("team") | ||
| )); | ||
| } | ||
| return pieces; | ||
| } | ||
| } | ||
|
|
||
| public Optional<Long> findLatestUnfinishedGameId() throws SQLException { | ||
| String sql = "SELECT game_id FROM game_state WHERE is_finished = false ORDER BY last_played_at DESC LIMIT 1"; | ||
|
|
||
| try (PreparedStatement ps = TransactionContext.getPreparedStatement(sql); | ||
| ResultSet rs = ps.executeQuery()) { | ||
| if (rs.next()) { | ||
| return Optional.of(rs.getLong("game_id")); | ||
| } | ||
| return Optional.empty(); | ||
| } | ||
| } | ||
|
|
||
| public List<UnfinishedGameInfo> findUnfinishedGameInfos() throws SQLException { | ||
| String sql = "SELECT game_id, last_played_at FROM game_state WHERE is_finished = false ORDER BY last_played_at ASC"; | ||
|
|
||
| try (PreparedStatement ps = TransactionContext.getPreparedStatement(sql)){ | ||
| ResultSet rs = ps.executeQuery(); | ||
| List<UnfinishedGameInfo> unfinishedGames = new ArrayList<>(); | ||
| while (rs.next()) { | ||
| unfinishedGames.add(UnfinishedGameInfo.from( | ||
| rs.getLong("game_id"), | ||
| rs.getTimestamp("last_played_at").toLocalDateTime() | ||
| )); | ||
| } | ||
| return unfinishedGames; | ||
| } | ||
| } | ||
| } |
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.
์ด ํด๋์ค๊ฐ ์๋ ํจํค์ง ๊ตฌ์กฐ์ ๋ํ ํผ๋๋ฐฑ์ ๋๋ค.
๊ฐ์ ์๊ณ์ ๋ชจ๋ ์ ํ์ ํจํค์ง๊ฐ ์์ต๋๋ค. ์ถ์ํ ๋จ๊ณ์ ๋ฐ๋ผ ํจํค์ง๋ฅผ ๊ทธ์ ๋ง์ถฐ ์ด๋ํ๋๊ฑด ์ด๋จ๊น์?
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.
์ฌ์ค ์ ๊ฐ ๋ง์ํด์ฃผ์ ๋ถ๋ถ์ ์ ์ดํด ๋ชปํ์ต๋๋ค...
์ถ์ํ ๋จ๊ณ์ ๋ฐ๋ผ ๋ฌถ๋๋ค๋ฉด presentation, application, domain, infrastructure ๊ฐ์ ๊ณ์ธต ๊ธฐ์ค์ผ๋ก ์ฌ๊ตฌ์ฑํ๋ ๋ฐฉํฅ์ ๋ง์ํ์๋ ๊ฑธ๊น์?!
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.
๊ทธ๋ ๊ฒ ํ๋ ๋ฐฉ๋ฒ๋ ์๊ณ ์ฌ๋ฌ๊ฐ์ง๊ฐ ์์๊ฑฐ ๊ฐ์์! ์ ๊ฐ ๋ง์๋๋ฆฐ ํฌ์ธํธ๋ repository ํ์์ dao๊ฐ ์์ด์ผํ ๊ฑฐ ๊ฐ์๋ฐ ๊ฐ์ ์๊ณ์ ์๋๊ฑธ ์์ ํด๋ฌ๋ผ๋ ๋ง์ด์์ต๋๋ค!