-
Notifications
You must be signed in to change notification settings - Fork 97
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
[2단계 - 경로 조회 기능] 제이미(임정수) 미션 제출합니다. #195
Merged
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
a84733b
refactor: 패키지 분리 및 이동
JJ503 bcf9345
refactor: SectionStationMapper 엔티티 생성
JJ503 b5fb095
refactor: Sections sort 메서드 분리
JJ503 1604c0f
refactor: Domain, Entity 동등성 재정의 및 toString 재정의
JJ503 2bce4a2
fix: 오류 발생 테스트 문제 해결
JJ503 fae6028
refactor: schema section 필드 추가
JJ503 9c5b287
test: SectionDao 단위 테스트 추가
JJ503 9ce5ea5
refactor: LineDao NamedParameterJdbcTemplate로 변경
JJ503 50a54d7
refactor: SectionDao SimpleJdbcInsert 수정
JJ503 1491e9e
test: LineDao 단위 테스트 추가
JJ503 b803d60
refactor: Station을 도메인과 엔티티로 분리
JJ503 e991338
test: LineDao 테스트 조건 수정
JJ503 deed89c
refactor: exception 네이밍 변경
JJ503 94ab852
test: StationDao 단위 테스트 추가
JJ503 21cfb58
refactor: Section 필드에 id 추가
JJ503 69f38f6
refactor: 역 추가에 대한 로직을 서비스에서 Sections로 이동
JJ503 d07b5b3
test: 추가적인 SectionDao 단위 테스트 추가
JJ503 4ed9e53
refactor: 역 제거 대한 로직을 서비스에서 Sections로 이동
JJ503 aa7eaab
refactor: 기타 컨벤션 적용
JJ503 8629a4f
test: 삭제 인수 테스트 추가
JJ503 ae241ae
docs: 경로 조회 api 추가
JJ503 24fd5cc
refactor: 프로덕션과 테스트 데이터베이스 분리
JJ503 7716d5d
feat: 최단 경로 조회 기능 추가
JJ503 2f5fa83
feat: 데이터 초기값 파일 설정 추가
JJ503 4e4ee12
feat: 경로와 거리를 담는 path 생성
JJ503 fdc0c60
docs: 2단계 기능 목록 추가 및 완료 사항 체크
JJ503 b51b860
feat: 지하철 요금 계산 및 조회 기능 추가
JJ503 e1729e7
refactor: 코드 컨벤션 적용
JJ503 c8e5200
test: SectionDao 단위 테스트 추가 및 컨벤션 적용
JJ503 d00523e
test: StationDao 단위 테스트 추가 및 컨벤션 적용
JJ503 fff3ab8
refactor: LineDaoTest, SectionDaoTest given-when-then 패턴 적용
JJ503 a2d3262
test: 테스트 초기 정보 수정
JJ503 b96cc79
fix: 역 정렬 잘못된 로직 수정
JJ503 7ab3454
test: LineDaoTest 초기 정보 수정
JJ503 65a7139
refactor: 정적팩토리메서드로 객체 생성
JJ503 3519845
test: LineService 단위 테스트 추가
JJ503 7430b1b
feat: 누락된 fare 파일 추가
JJ503 6a8592c
refactor: 중복 코드 제거
JJ503 d3b33bd
refactor: 중복되는 상수들 TestFeature로 묶음
JJ503 c6d8dc0
test: Sections 단위 테스트 추가
JJ503 95251c7
test: Map 단위 테스트 추가
JJ503 4571dba
test: Fare 단위 테스트 추가
JJ503 c3dce4d
test: PathService 단위 테스트 추가
JJ503 3df8609
test: SectionService 단위 테스트 추가
JJ503 6811348
docs: 완료한 기능 목록 체크
JJ503 5ddbeea
test: StationService 단위 테스트 추가
JJ503 8c95325
refactor: SQLException GlobalExceptionHandler로 통합
JJ503 f078c63
refactor: 주석 제거
JJ503 99b8ce2
feat: MethodArgumentNotValidException에 대한 예외 처리 추가
JJ503 247f12c
test: Line 통합 테스트 추가
JJ503 378c5f6
test: StationController 단위 테스트 추가
JJ503 c947831
test: SectionController 단위 테스트 추가
JJ503 6691c86
test: PathController 단위 테스트 추가
JJ503 197d9db
test: SectionController 통합 테스트 추가
JJ503 1c2346a
fix: 코드 수정으로 인한 테스트 오류 해결
JJ503 e7593a0
test: PathController 통합 테스트 추가
JJ503 ee150fa
refactor: 존재 여부에 대해 exist를 통해 확인하도록 수정
JJ503 5127fe8
refactor: 중복코드 제거를 위한 메서드 분리
JJ503 8f7c83e
refactor: 노선의 구간 존재 여부 확인을 dao에서 하도록 수정
JJ503 b32430d
refactor: 사용하지 않는 생성자 제거
JJ503 0227734
feat: StationService delete 역 존재 여부 검증 추가
JJ503 02bcca7
refactor: 생성자 체이닝 적용
JJ503 c2cc9e2
refactor: SubwayMap 클래스 네이밍 변성
JJ503 9100f67
refactor: 사용하지 않는 생성자 제거
JJ503 4093128
refactor: 한 메서드가 10라인이 넘지 않도록 수정
JJ503 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
refactor: Station을 도메인과 엔티티로 분리
- Loading branch information
commit b803d60c3c814949196505487d39b4178dde7165
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package subway.application; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.springframework.stereotype.Service; | ||
import subway.dao.StationDao; | ||
import subway.dao.entity.StationEntity; | ||
import subway.domain.Station; | ||
import subway.dto.request.StationRequest; | ||
import subway.dto.response.StationResponse; | ||
import subway.exception.NotFoundException; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
public class StationService { | ||
|
||
|
@@ -20,33 +22,39 @@ public StationService(StationDao stationDao) { | |
|
||
public StationResponse saveStation(StationRequest stationRequest) { | ||
checkDuplicatedStationName(stationRequest); | ||
Station station = stationDao.insert(new Station(stationRequest.getName())); | ||
return StationResponse.of(station); | ||
StationEntity station = stationDao.insert(new StationEntity(stationRequest.getName())); | ||
return StationResponse.of(Station.from(station)); | ||
} | ||
|
||
public StationResponse findStationResponseById(Long id) { | ||
Station station = stationDao.findById(id).orElseThrow(() -> new NotFoundException("해당 역이 존재하지 않습니다.")); | ||
return StationResponse.of(station); | ||
StationEntity station = stationDao.findById(id) | ||
.orElseThrow(() -> new NotFoundException("해당 역이 존재하지 않습니다.")); | ||
return StationResponse.of(Station.from(station)); | ||
} | ||
|
||
public List<StationResponse> findAllStationResponses() { | ||
List<Station> stations = stationDao.findAll(); | ||
List<StationEntity> stationEntities = stationDao.findAll(); | ||
|
||
List<Station> stations = stationEntities.stream() | ||
.map(Station::from) | ||
.collect(Collectors.toList()); | ||
|
||
return stations.stream() | ||
.map(StationResponse::of) | ||
.collect(Collectors.toList()); | ||
.map(StationResponse::of) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public void updateStation(Long id, StationRequest stationRequest) { | ||
stationDao.update(new Station(id, stationRequest.getName())); | ||
stationDao.update(new StationEntity(id, stationRequest.getName())); | ||
} | ||
|
||
public void deleteStationById(Long id) { | ||
stationDao.deleteById(id); | ||
} | ||
|
||
private void checkDuplicatedStationName(StationRequest stationRequest) { | ||
if (stationDao.findByName(stationRequest.getName()).isPresent()) { | ||
private void checkDuplicatedStationName(StationRequest stationRequest) { | ||
if (stationDao.findByName(stationRequest.getName()) | ||
.isPresent()) { | ||
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. exists 쿼리를 통해 한 번에 존재여부 확인을 할 수도 있겠네요 ㅎㅎ 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. 존재 여부에 대한 확인만 필요하다면 굳이 findBy~를 통해 찾아와 레코드를 가져오고 객체를 생성하는 과정을 수행하는 것보다는 확인만 하고 데이터를 가져오지 않는 방법의 성능이 더 낫겠네요! |
||
throw new IllegalArgumentException("이미 존재하는 역 이름 입니다"); | ||
} | ||
} | ||
|
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
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.
존재하지 않는 역의 id로 삭제요청을 보내는 경우에 대한 처리가 필요할 것 같아요
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.
감사합니다!
해당 id를 먼저 검증하도록 수정했습니다.