-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: 기능 요구 사항 정리 * docs: 기능 요구 사항 정리 * style: 메소드 매개변수간 개행 문자 추가 * style: Class 끝에 개행문자 추가 * feat: 노선 생성 시 종점역(상행, 하행) 정보를 요청 파라미터에 함께 추가하기 * feat: 노선 조회 시 응답 결과에 역 목록 추가하기 * refactor: service > getStations 을 Line Entity 에 위임 * refactor: line 의 데이터 변경시, 역 목록이 보일 수 있도록 변경 * refactor: line의 역 정보가 상행에서 하행으로 보여지도록 수정 * docs: 피드백으로 받은 부분 리팩토링 Todo 정의 * refactor: Pull Request 피드백 코드 변경
- Loading branch information
Showing
10 changed files
with
322 additions
and
42 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
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,56 @@ | ||
package nextstep.subway.line.domain; | ||
|
||
import nextstep.subway.common.BaseEntity; | ||
import nextstep.subway.station.domain.Station; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
public class Section extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) | ||
private Line line; | ||
|
||
@OneToOne(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "up_station_id") | ||
private Station upStation; | ||
|
||
@OneToOne(cascade = CascadeType.ALL) | ||
@JoinColumn(name = "down_station_id") | ||
private Station downStation; | ||
|
||
private int distance; | ||
|
||
public Section() { | ||
} | ||
|
||
public Section(Station upStation, Station downStation, int distance) { | ||
this.upStation = upStation; | ||
this.downStation = downStation; | ||
this.distance = distance; | ||
} | ||
|
||
public Line getLine() { | ||
return line; | ||
} | ||
|
||
public Station getUpStation() { | ||
return upStation; | ||
} | ||
|
||
public Station getDownStation() { | ||
return downStation; | ||
} | ||
|
||
public int getDistance() { | ||
return distance; | ||
} | ||
|
||
public void toLine(Line line) { | ||
this.line = line; | ||
} | ||
} |
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,27 @@ | ||
package nextstep.subway.line.domain; | ||
|
||
import javax.persistence.*; | ||
import java.util.List; | ||
|
||
@Embeddable | ||
public class Sections { | ||
|
||
@OneToMany(mappedBy = "line", cascade = CascadeType.ALL) | ||
@Column(name = "sections") | ||
private List<Section> values; | ||
|
||
private Sections(List<Section> values) { | ||
this.values = values; | ||
} | ||
|
||
public Sections() { | ||
} | ||
|
||
public List<Section> getValues() { | ||
return values; | ||
} | ||
|
||
public static Sections of(List<Section> sections){ | ||
return new Sections(sections); | ||
} | ||
} |
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.