[π μ¬μ΄ν΄2 - λ―Έμ (κΈ°λ¬Ό νμ₯ + DB μ μ©)] λ²¨λ‘ λ―Έμ μ μΆν©λλ€.#270
[π μ¬μ΄ν΄2 - λ―Έμ
(κΈ°λ¬Ό νμ₯ + DB μ μ©)] λ²¨λ‘ λ―Έμ
μ μΆν©λλ€.#270juntae6942 wants to merge 91 commits intowoowacourse:juntae6942from
Conversation
donghoony
left a comment
There was a problem hiding this comment.
λ²¨λ‘ μλ
νμΈμ~ μ λ² μ¬μ΄ν΄λ κ·Έλ κ³ λ¦μ μκ°μμλ λΉ λ₯΄κ² 리뷰λ₯Ό λ°μν΄μ£Όμ
¨λ€μ. νΈλμμ
μ΄λΌλ κ°λ
μ κ°μ Έμμ ꡬνν΄μ£Όμ
μ κΉμ§ λλμ΅λλ€. κ·Έμ λμμ νΈλμμ
μ μ±
μμ? μΈνλΌ λ 벨μ μΆμνλ? μ κ°μ κ°μ²΄/κ³μΈ΅μ μ±
μ μ§λ¬Έμ λ λ¬Όμ΄μμ΄μ. π
λ¨κ²¨λλ¦° 리뷰λ₯Ό μ νμΈν΄λ³΄μκ³ λ°μν΄μ£ΌμΈμ. λ€μ μμ² λ λ€μ λ§λμ~!
| } | ||
|
|
||
| @Override | ||
| public JanggiGame loadGame(Long gameRoomId) { |
There was a problem hiding this comment.
gameRoomIdλ₯Ό primitiveλ₯Ό λ°μΌλ©΄ μλ κ²μ¦μ΄ λΆνμνμ§ μμκΉμ? μ updateμμλ κ²μ¦μ νμ§ μκ³ μμ΄μ, μ΄λ΄ λμλ μ€νλ € λ°μ λ μ νμ λλ κ² μΈμ§λΆνλ μ€μ΄λ€ κ² κ°μ΅λλ€.
| connection.commit(); | ||
| return result; | ||
| } catch (SQLException e) { | ||
| connection.rollback(); |
There was a problem hiding this comment.
- Daoμ μμΈκ° λ‘€λ°±μΌλ‘ μ§νλ κΉμ? π
- μ΄ ν¨μλ SQLExceptionμ λμ§λμ?
- μ΄μ 리뷰μμλ SQLExceptionμ Daoμμ λμ§λ μ± μμ λν΄μ μ¬μ€λ΄€μμ΅λλ€. μν©μ΄ λ°λ μ§κΈμ SQLExceptionμ μΈλΆλ‘ λμ§λ©΄, μ΄λ₯Ό λ°μ μ΄λ€ μν μ ν μ μμ΄λ³΄μ΄λ κ²μ²λΌ 보μ΄λ€μ. μ΄μ²λΌ μ½λ λ§₯λ½μ νμ¬ μ½λκ° μ΄λ»κ² μ§μ¬μ‘λμ§μ λ°λΌ μ μ°νκ² λ³νλ΅λλ€!
|
|
||
| import java.util.Arrays; | ||
|
|
||
| public enum GameCommand { |
There was a problem hiding this comment.
ππ» νν κ³μΈ΅μμμ κ°μ²΄λ₯Ό μ μμ±ν΄μ£Όμ ¨λ€κ³ μκ°ν©λλ€. μ μ ν μ± μλ κ°μ Έκ°κ³ μλ€μ
| private final DataConnectionManager manager; | ||
| private final GameRoomDao roomDao = new GameRoomDao(); | ||
| private final PiecesDao piecesDao = new PiecesDao(); |
There was a problem hiding this comment.
(κΆκΈ) managerλ μΈλΆμμ λ°μλ΄λλ°, Daoλ€μ λ΄λΆμμ newλ‘ μμ±νλ μ΄μ κ° μλμ?
| Console.close(); | ||
| } | ||
|
|
||
| private void playGame(Long roomId) { |
There was a problem hiding this comment.
| private void playGame(Long roomId) { | |
| private void playGame(long roomId) { |
μ 체μ μΌλ‘ νμΈν΄μ£ΌμΈμ. ν λ² νμ©νκ² λλ nullableμ λμ΄ν¬ μ μκ² λκ³€ ν©λλ€.
| moveStatement.executeUpdate(); | ||
| } | ||
|
|
||
| public List<PieceData> findAllByRoomId(Long roomId, Connection connection) { |
There was a problem hiding this comment.
μ΄ μΉκ΅¬λ μμΈλ₯Ό λννκ³ μλλ° ν΅μΌμ± μ§μΌμ£ΌμΈμ~!
|
|
||
| public class GameRoomDao { | ||
|
|
||
| public Long save(GameRoomData data, Connection connection) throws SQLException { |
There was a problem hiding this comment.
νΈλμμ
μ΄ λμ
λλ©΄μ λ³νμ μ±
μμ λ°μΌλ‘ λκΈ΄ μ΄μ κ° μκΈ΄ κ² κ°μ΅λλ€. ππ»
| OutputView.printWinner(game.getWinner()); | ||
| Console.close(); | ||
| public static void main(String[] args) throws SQLException { | ||
| Server server = Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", "9092").start(); |
There was a problem hiding this comment.
(μ ν) μκ°μ΄ λ§μ΄ λ¨μΌμκ±°λ μ¬μ΄ν΄μ μ°μ₯μ μΌλ‘ μκ°νμ λ€λ©΄ λμ ν΄λ³΄μ λ μ’κ² μ΅λλ€ γ γ
| JanggiGame game = repository.loadGame(roomId); | ||
| game.play(from, to); | ||
| repository.update(roomId, from, to, game); | ||
| } |
There was a problem hiding this comment.
PR μ§λ¬Έμ λν μ견) playκ° κ°μ²΄λ₯Ό λ³ννκ³ μμΌλ, μ΄λ₯Ό λ°ννμ¬ νμ©νλ©΄ DB λΆνλ₯Ό μ€μΌ μ μμ§ μμκΉμ? λμμ±κ³Ό DB λΆν λͺ¨λ μ±κΈΈ μ μμ κ² κ°μμ.

μ²΄ν¬ λ¦¬μ€νΈ
testλ₯Ό μ€ννμ λ, λͺ¨λ ν μ€νΈκ° μ μμ μΌλ‘ ν΅κ³Όνλμ?μλμ νκ²½λ³μλ₯Ό μ¬μ©νμ¬ h2 DBλ‘ μ°λνμμ΅λλ€.
νμ¬ μλ‘μ΄ μ₯κΈ°νμΌλ‘ κ²μμ ν κ²μΈμ§ μλλ©΄ κΈ°μ‘΄μ κ²μνμ μ°Ύμμ ν κ²μΈμ§ μ λ ₯λ°λ λ‘μ§μΌλ‘ ꡬννμμ΅λλ€.
λ€λ§ κΈ°μ‘΄ μ₯κΈ°ν 리μ€νΈ μ‘°νλ ꡬννμ§ λͺ»νμμ΅λλ€. μ΄μ μ°Έκ³ ν΄μ£Όμλ©΄ κ°μ¬νκ² μ΅λλ€.
μΆλ ₯ μμ
μ΄λ€ λΆλΆμ μ§μ€νμ¬ λ¦¬λ·°ν΄μΌ ν κΉμ?
1μ°¨ νΌλλ°±μ κΈ°λ°μΌλ‘ μ½λλ₯Ό μμ νμμ΅λλ€. μ μ μ£Όμ ¨λ λ΄μ©μ κ³ λ―Όν΄μ μΆμ 골격 ν΄λμ€λ₯Ό νμ€νκ² μ¬μ©νλ λ°©ν₯μ λͺ¨μν΄μ μ μ©ν΄λ³΄μμ΅λλ€.