-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] 지하철에 관련된 엔티티 생성 및 레포지토리 구현 (#58)
- 지하철 역 엔티티 구현 - 지하철 혼잡도 엔티티 구현 - 지하철 시간표 엔티티 구현 - 각 레포지토리 구현 Closes #56 **현재까지 진행내용 merge하여 충돌 해결**
- Loading branch information
Showing
23 changed files
with
502 additions
and
12 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.../talkka/server/review/enums/TimeSlot.java → .../talkka/server/common/enums/TimeSlot.java
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
5 changes: 2 additions & 3 deletions
5
...server/review/util/TimeSlotConverter.java → ...server/common/util/TimeSlotConverter.java
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
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
84 changes: 84 additions & 0 deletions
84
server/src/main/java/com/talkka/server/subway/dao/SubwayConfusionEntity.java
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,84 @@ | ||
package com.talkka.server.subway.dao; | ||
|
||
import java.util.Objects; | ||
|
||
import com.talkka.server.common.enums.TimeSlot; | ||
import com.talkka.server.common.util.TimeSlotConverter; | ||
import com.talkka.server.subway.enums.DayType; | ||
import com.talkka.server.subway.enums.Line; | ||
import com.talkka.server.subway.enums.Updown; | ||
import com.talkka.server.subway.util.DayTypeConverter; | ||
import com.talkka.server.subway.util.LineConverter; | ||
import com.talkka.server.subway.util.UpdownConverter; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Convert; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Entity(name = "subway_confusion") | ||
@Getter | ||
@Builder | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SubwayConfusionEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "subway_confusion_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "station_id") | ||
private SubwayStationEntity subwayStation; | ||
|
||
@Column(name = "day_type", nullable = false) | ||
@Convert(converter = DayTypeConverter.class) | ||
private DayType dayType; | ||
|
||
@Column(name = "line_cd", nullable = false) | ||
@Convert(converter = LineConverter.class) | ||
private Line line; | ||
|
||
@Column(name = "fr_code", nullable = false) | ||
private String frCode; | ||
|
||
@Column(name = "station_name", nullable = false) | ||
private String stationName; | ||
|
||
@Column(name = "updown", nullable = false) | ||
@Convert(converter = UpdownConverter.class) | ||
private Updown updown; | ||
|
||
@Column(name = "time_slot", nullable = false) | ||
@Convert(converter = TimeSlotConverter.class) | ||
private TimeSlot timeslot; | ||
|
||
@Column(name = "confusion") | ||
private Double confusion; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
SubwayConfusionEntity that = (SubwayConfusionEntity)o; | ||
return Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(id); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
server/src/main/java/com/talkka/server/subway/dao/SubwayConfusionRepository.java
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,8 @@ | ||
package com.talkka.server.subway.dao; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface SubwayConfusionRepository extends JpaRepository<SubwayConfusionEntity, Long> { | ||
} |
71 changes: 71 additions & 0 deletions
71
server/src/main/java/com/talkka/server/subway/dao/SubwayStationEntity.java
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,71 @@ | ||
package com.talkka.server.subway.dao; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import com.talkka.server.subway.enums.Line; | ||
import com.talkka.server.subway.util.LineConverter; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Convert; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Entity(name = "subway_station") | ||
@Getter | ||
@Builder | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SubwayStationEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "station_id", nullable = false) | ||
private Long id; | ||
|
||
@Column(name = "api_station_id") | ||
private String apiStationId; | ||
|
||
@Column(name = "station_name", nullable = false) | ||
private String stationName; | ||
|
||
@Column(name = "fr_code", nullable = false) | ||
private String frCode; | ||
|
||
@Column(name = "line_code", nullable = false) | ||
@Convert(converter = LineConverter.class) | ||
private Line line; | ||
|
||
@OneToMany(mappedBy = "subwayStation") | ||
@Builder.Default | ||
private List<SubwayTimetableEntity> timetables = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "subwayStation") | ||
@Builder.Default | ||
private List<SubwayConfusionEntity> confusions = new ArrayList<>(); | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
SubwayStationEntity that = (SubwayStationEntity)o; | ||
return Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(id); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
server/src/main/java/com/talkka/server/subway/dao/SubwayStationRepository.java
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,11 @@ | ||
package com.talkka.server.subway.dao; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface SubwayStationRepository extends JpaRepository<SubwayStationEntity, Long> { | ||
List<SubwayStationEntity> findByStationNameLikeOrderByStationNameAsc(String stationName); | ||
} |
97 changes: 97 additions & 0 deletions
97
server/src/main/java/com/talkka/server/subway/dao/SubwayTimetableEntity.java
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,97 @@ | ||
package com.talkka.server.subway.dao; | ||
|
||
import java.time.LocalTime; | ||
import java.util.Objects; | ||
|
||
import com.talkka.server.subway.enums.DayType; | ||
import com.talkka.server.subway.enums.Express; | ||
import com.talkka.server.subway.enums.Line; | ||
import com.talkka.server.subway.enums.Updown; | ||
import com.talkka.server.subway.util.DayTypeConverter; | ||
import com.talkka.server.subway.util.ExpressConverter; | ||
import com.talkka.server.subway.util.LineConverter; | ||
import com.talkka.server.subway.util.UpdownConverter; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Convert; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Entity(name = "subway_timetable") | ||
@Getter | ||
@Builder | ||
@ToString | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SubwayTimetableEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "subway_timetable_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "station_id", nullable = false) | ||
private SubwayStationEntity subwayStation; | ||
|
||
@Column(name = "line_code", nullable = false) | ||
@Convert(converter = LineConverter.class) | ||
private Line line; | ||
|
||
@Column(name = "fr_code", nullable = false) | ||
private String frCode; | ||
|
||
@Column(name = "station_name", nullable = false) | ||
private String stationName; | ||
|
||
@Column(name = "day_type", nullable = false) | ||
@Convert(converter = DayTypeConverter.class) | ||
private DayType dayType; | ||
|
||
@Column(name = "updown", nullable = false) | ||
@Convert(converter = UpdownConverter.class) | ||
private Updown updown; | ||
|
||
@Column(name = "is_express", nullable = false) | ||
@Convert(converter = ExpressConverter.class) | ||
private Express express; | ||
|
||
@Column(name = "train_code", nullable = false) | ||
private String trainCode; | ||
|
||
@Column(name = "arrival_time", nullable = false) | ||
private LocalTime arrivalTime; | ||
|
||
@Column(name = "depart_time", nullable = false) | ||
private LocalTime departTime; | ||
|
||
@Column(name = "start_station_name", nullable = false) | ||
private String startStationName; | ||
|
||
@Column(name = "end_station_name", nullable = false) | ||
private String endStationName; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
SubwayTimetableEntity that = (SubwayTimetableEntity)o; | ||
return Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(id); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
server/src/main/java/com/talkka/server/subway/dao/SubwayTimetableRepository.java
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,8 @@ | ||
package com.talkka.server.subway.dao; | ||
|
||
import org.hibernate.type.descriptor.converter.spi.JpaAttributeConverter; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface SubwayTimetableRepository extends JpaAttributeConverter<SubwayTimetableEntity, Long> { | ||
} |
20 changes: 20 additions & 0 deletions
20
server/src/main/java/com/talkka/server/subway/enums/DayType.java
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,20 @@ | ||
package com.talkka.server.subway.enums; | ||
|
||
import com.talkka.server.common.util.EnumCodeInterface; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum DayType implements EnumCodeInterface { | ||
DAY("평일", "DAY"), | ||
SAT("토요일", "SAT"), | ||
SUN("일요일", "SUN"); | ||
|
||
private String name; | ||
private String code; | ||
|
||
DayType(String name, String code) { | ||
this.name = name; | ||
this.code = code; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
server/src/main/java/com/talkka/server/subway/enums/Express.java
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,18 @@ | ||
package com.talkka.server.subway.enums; | ||
|
||
import com.talkka.server.common.util.EnumCodeInterface; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum Express implements EnumCodeInterface { | ||
EXPRESS("급행", "0"), NORMAL("일반", "1"); | ||
|
||
private final String type; | ||
private final String code; | ||
|
||
Express(String type, String code) { | ||
this.type = type; | ||
this.code = code; | ||
} | ||
} |
Oops, something went wrong.