-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2단계 - 웹 자동차 경주] 테오(최우성) 미션 제출합니다. (#133)
* refactor: 컨트롤러를 RestController로 변경 * refactor: 일반 객체가 아닌 ResponseEntity로 응답하도록 변경 * refactor: 변수명이 과도하게 의미를 내포하지 않도록 변경 * refactor: DTO 클래스명에서 보다 명확한 의미를 전달하도록 변경 * refactor: 구현체 메소드에 Override 명시 * fix: Multiple Key를 가져오던 문제 수정 * test: Service 객체의 생성 책임을 컨테이너에 위임, 더미 객체 삭제 * refactor: 테이블을 생성하는 sql 파일 네이밍 변경 * refactor: SpringBootTest을 JDBCTest로 변경 * feat: 예외 핸들링 메커니즘 생성 * docs: 1단계 리팩토링 기록 작성 * docs: 2단계 요구사항 정리 * refactor: DAO가 하나의 테이블에 매핑되도록 변경 * feat: 플레이 이력 조회에 대한 웹 요청/응답이 가능하다. * refactor: dto 패키지 이름 repository로 변경 * chore: 기존 콘솔 애플리케이션 컨트롤러 복구 * refactor: 조인 기능을 하는 메소드를 stream을 활용하도록 변경 * feat: Repository 추상화, 메모리 Repository 생성 * feat: 콘솔 어플리케이션이 기존 로직을 재사용하도록 변경 * chore: 패키지 추가 분리 * docs: 리팩토링 기록 작성 * refactor: 상수 분리 * chore: 클래스명을 명확하게 변경 * refactor: ExceptionAdvice 역할에 따라 추가 분리 * refactor: ReponseEntity의 badRequest 메소드를 이용하도록 변경 * chore: 패키지 구조 수정, entity를 persistence 하위로 변경 * chore: 메소드명 수정 * feat: `@Valid`를 통해 검출된 예외도 메세지를 반환하도록 수정 * feat: Service의 메소드를 Transactional하게 변경 * refactor: RacingGame 도메인 객체 구조 변경 * refactor: Key 값을 Number가 아닌 Long으로 반환하도록 변경 * refactor: 도메인에 시도 횟수를 반환하는 getter 생성 * refactor: 레이어 간 메세지 정의 Repository - DAO -> Entity Service - Repository -> Domain Controller - Service -> Domain Client - Controller -> DTO * refactor: 컨트롤러 간 공통적인 변환 로직 분리 * chore: 클래스명 변경 * test: 프로덕션 코드 수정으로 인한 테스트 코드 수정 * refactor: Service에서 DTO가 아닌 도메인 객체를 반환하도록 수정 * test: Repository Mock을 통한 테스트 개선 * chore: 사용되지 않는 메소드 제거 * docs: 리팩토링 기록 작성 * feat: 예외처리 시 로깅 기능 추가 * refactor: 쿼리를 매번 for문에서 생성하지 않도록 변경 * refactor: key를 Long으로 형변환할 때, `getKeyAs` 메소드를 사용하도록 변경 * chore: 메소드명, 클래스명 수정 * chore: DTO 패키지를 Presentation Layer로 이동 * chore: Layered Architecture에 따라 패키지 이름 구성 * chore: Layered Architecture에 따라 패키지 변경 * chore: 도메인 제약조건에 맞게 스키마 재설계 * refactor: 도메인 코드 개선 * chore: 메소드명 변경 * refactor: 키를 Long이 아닌 Integer로 받도록 변경 * chore: 커스텀 예외 제거에 따른 ExceptionHandler 변경 * fix: 컬럼 사이즈가 작아 우승자를 담지 못하는 문제 해결 * fix: 게임 이력이 제대로 복원되지 않던 문제 해결 * test: 도메인 구조 수정에 따른 테스트 변경 * docs: 고민사항 및 리팩토링 기록 작성 * chore: 변수명 변경 * refactor: 엔티티의 속성을 모두 Wrapper 타입으로 변경 null 지정 가능해짐 * refactor: 메소드 분리, 가독성 개선 * refactor: 불필요한 ControllerAdvice Order 지정 삭제 스프링에서는 여러 ExceptionHandler가 있을 때, 가장 구체적인 ExceptionHandler를 선택함 * refactor: 프로시저의 성격을 가지는 객체를 static하게 변경, 메소드명 변경 * chore: 불필요한 개행 삭제 * docs: 고민사항 및 리팩토링 기록 작성
- Loading branch information
1 parent
2d18c57
commit 5e66441
Showing
47 changed files
with
972 additions
and
464 deletions.
There are no files selected for viewing
This file contains 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 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,17 @@ | ||
package racingcar; | ||
|
||
import racingcar.presentation.ConsoleRacingGameController; | ||
import racingcar.view.input.InputView; | ||
import racingcar.view.output.ConsoleView; | ||
|
||
import java.util.Scanner; | ||
|
||
public class ConsoleRacingGameApplication { | ||
|
||
public static void main(String[] args) { | ||
new ConsoleRacingGameController( | ||
new InputView(new Scanner(System.in)), | ||
new ConsoleView() | ||
).start(); | ||
} | ||
} |
This file contains 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 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,49 @@ | ||
package racingcar.business; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import racingcar.domain.Car; | ||
import racingcar.domain.RacingGame; | ||
import racingcar.domain.RandomNumberGenerator; | ||
import racingcar.persistence.repository.GameRepository; | ||
import racingcar.presentation.dto.RacingGameRequest; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
public class RacingGameService { | ||
|
||
private final GameRepository gameRepository; | ||
|
||
public RacingGameService(final GameRepository gameRepository) { | ||
this.gameRepository = gameRepository; | ||
} | ||
|
||
@Transactional | ||
public RacingGame playRacingGame(final RacingGameRequest racingGameRequest) { | ||
RacingGame racingGame = createRacingGame(racingGameRequest); | ||
racingGame.start(); | ||
gameRepository.saveGame(racingGame); | ||
return racingGame; | ||
} | ||
|
||
private RacingGame createRacingGame(final RacingGameRequest racingGameRequest) { | ||
return new RacingGame( | ||
toCars(racingGameRequest.getNames()), | ||
racingGameRequest.getCount(), | ||
new RandomNumberGenerator() | ||
); | ||
} | ||
|
||
private List<Car> toCars(final String cars) { | ||
return Arrays.stream(cars.split(",")) | ||
.map(name -> new Car(name, 0)) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public List<RacingGame> readAllGames() { | ||
return gameRepository.selectAllGames(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
src/main/java/racingcar/dao/JdbcTemplateRacingGameDao.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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 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.