Skip to content
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단계 - 최단 경로 및 요금 조회 api] 주드 미션 제출합니다. #102

Merged
merged 38 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5a89962
feat: 노선 삭제 및 테스트케이스 추가
kevstevie May 14, 2023
e1daaf8
feat: 노선 삭제 예외 처리
kevstevie May 14, 2023
b56eed6
feat: 중복 이름 추가 시 예외 처리
kevstevie May 14, 2023
82584fc
refactor: 역 추가 분기 제거
kevstevie May 14, 2023
0cb99ee
feat: 최단 거리 및 경로 계산
kevstevie May 14, 2023
7938646
feat: 최단 경로 및 요금 조회 기능
kevstevie May 14, 2023
7e7190e
chore: 테스트와 db 분리
kevstevie May 14, 2023
16164f3
docs: 문서 추가
kevstevie May 14, 2023
a743a22
chore : package 구분
kevstevie May 14, 2023
ae645bc
feat: 기타 예외 처리 추가
kevstevie May 14, 2023
8cfe5a1
feat: request 검증 추가
kevstevie May 14, 2023
239cfba
refactor: 조회에 readonly 추가
kevstevie May 14, 2023
f53e541
chore: h2로 설정 변경
kevstevie May 16, 2023
d3dea5c
refactor: 상속으로 라이브러리 사용 분리
kevstevie May 16, 2023
2dfabe5
chore
kevstevie May 16, 2023
315d1ac
refactor: polishing
kevstevie May 16, 2023
bef9da2
fix: 역을 삭제하면 모든 노선에서 삭제
kevstevie May 16, 2023
718f4b7
refactor: rename
kevstevie May 16, 2023
bfb0d1c
refactor: polishing 및 테스트
kevstevie May 16, 2023
dc02b72
test: test 포맷 수정
kevstevie May 17, 2023
c083983
test: test 추가
kevstevie May 17, 2023
7d2ea49
refactor: polishing
kevstevie May 17, 2023
84c9e40
docs: 기능 정리
kevstevie May 17, 2023
607162d
feat: 없는 지하철역 예외 처리 및 테스트 추가
kevstevie May 17, 2023
abb225e
refactor: 최단 경로 계산 구조 변경
kevstevie May 20, 2023
ddef2bc
refactor: 요금 계산 로직 수정
kevstevie May 20, 2023
151e987
chore: 데이터베이스 세팅 수정
kevstevie May 20, 2023
e17f819
refactor: 이름 수정
kevstevie May 20, 2023
7d5c82e
test: 인수테스트 전면 수정
kevstevie May 22, 2023
e941eed
docs: 요구사항 추가
kevstevie May 22, 2023
f9f4cf7
refactor: polishing
kevstevie May 22, 2023
a24fc5a
test: 인수테스트 이름 수정
kevstevie May 22, 2023
f5966dc
refactor: depricated 제거
kevstevie May 24, 2023
372fc7c
refactor: slf4j 의존성 추가
kevstevie May 24, 2023
73b4433
refactor: 에러 로그 추가
kevstevie May 24, 2023
292bbaf
refactor: polishing
kevstevie May 25, 2023
7638bc3
refactor: response, request 기본 생성자 추가
kevstevie May 30, 2023
c452748
refactor: shortestPathResponse로 변경
kevstevie Jun 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion README.md
kevstevie marked this conversation as resolved.
Show resolved Hide resolved
kevstevie marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,65 @@
## 도메인

- Path
- id, 상행역, 하행역, 거리를 가지는 경로 객체
- id, 하행역, 거리를 가지는 경로 객체

- Line
- id, 이름, 색, Map<Station, Path> 컬렉션을 가짐

- Station
- id, 이름을 가짐

- ShortestWayCalculator
- Line 객체를 파라미터로 받아 최단 경로와 거리를 계산하는 객체

- Direction
- 노선에 경로 추가 시 상행, 하행을 결정하는 ENUM

- AddPathStrategy
- 노선에 경로 추가시 분기와 중복 코드를 제거하기 위해 도입

## 기능 요구 사항

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번 미션의 목표가 복잡한 도메인 이해와 설계인 만큼 요구사항이 좀 더 구체적이면 좋을 것 같아요! (e.g. 상행, 하행, 비용 정책 등..)


### 역

- 역을 등록할 수 있다.
- 역을 제거할 수 있다.

### 노선과 경로

- 노선은 하나의 직선이다.(순환하지 않는다.)
- 노선을 조회할 수 있다.
- 노선 조회 시 노선에 해당하는 역을 상행역부터 순서대로 조회한다.
- 모든 노선을 조회할 수 있다.
- 노선 조회 시 노선에 해당하는 역을 상행역부터 순서대로 조회한다.
- 노선을 등록할 수 있다.
- 노선을 제거할 수 있다.
- 노선 제거 시에 노선의 모든 경로가 제거 된다.
- 노선에 역(경로)를 등록할 수 있다.
- 기준역, 추가할 역, 거리, 추가할 역의 방향을 고려한다.
- 역들의 사이에 추가될 경우 등록할 경로의 거리가 기존 거리보다 짧아야 한다.
- 노선에 역이 없다면 최초 등록 시 두개의 역이 경로로 등록된다.
- 노선의 역(경로)를 제거할 수 있다.
- 중간에 등록된 역이 제거된다면 제거된 역의 양 쪽의 역의 경로 거리가 합산된다.
- 노선에 역이 두개 있다면 한개를 제거할 때 두 역이 모두 제거된다.
- 역이 제거될 때 노선에 등록된 역도 제거된다.

### 최단 경로 조회

- 두개 역 사이의 가장 짧은 거리를 계산한다.
- 경로와 거리, 비용도 같이 계산한다.
- 비용 정책 변경을 고려한다.
- 최단 거리에 따라 비용이 결정된다.
- 기본 정책
- 10km 까지 1250원
- 50km 까지 5km 당 100원의 추가 금액
- 50km 부터 8km 당 100원의 추가 금액
- [ ] 추가 정책
- 노선에 따른 추가 비용이 추가된다.
- 연령별 할인 정책이 추가된다.
- 13세 ~ 18세: 운임에서 350원을 공제한 금액의 20%할인
- 6세 ~ 12세: 운임에서 350원을 공제한 금액의 50%할인

## API

- GET /lines/{id}
Expand Down Expand Up @@ -94,3 +145,23 @@
- DELETE /lines/{line-id}/stations/{station-id}
- 노선의 역을 삭제한다.
- Response Status OK

- GET /fee?start={id}&end={id}
- Response OK

```json
{
"fee": 1250,
"stations": [
{
"id": 1,
"name": "수원"
},
{
"id": 2,
"name": "잠실나루"
}
]
}

```
31 changes: 19 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.9'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
id 'org.springframework.boot' version '2.7.9'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}

sourceCompatibility = '11'

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.jgrapht:jgrapht-core:1.5.2'
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'org.projectlombok:lombok'

implementation 'net.rakugakibox.spring.boot:logback-access-spring-boot-starter:2.7.1'
testAnnotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

testImplementation 'io.rest-assured:rest-assured:4.4.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'net.rakugakibox.spring.boot:logback-access-spring-boot-starter:2.7.1'

runtimeOnly 'com.h2database:h2'
testImplementation 'io.rest-assured:rest-assured:4.4.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

runtimeOnly 'com.h2database:h2'
}

test {
useJUnitPlatform()
}
useJUnitPlatform()
}
Binary file added db/subway.mv.db
Binary file not shown.
Loading