Skip to content

Commit

Permalink
feature: PR 리뷰내용 (isExisted 메서드 삭제) 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
ss0ngcode committed Aug 20, 2024
1 parent 49023c8 commit 4c97313
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public class SubwayConfusionService {
public SubwayConfusionRespDto getConfusion(
Long stationId, String dayType, String updown, String timeSlot
) throws StationNotFoundException, ConfusionNotFoundException, InvalidTypeException {
isExisted(stationId);
if (!stationRepository.existsById(stationId)) {
throw new StationNotFoundException(stationId);
}

SubwayConfusionEntity entity = confusionRepository.findBySubwayStationIdAndDayTypeAndUpdownAndTimeSlot(
stationId,
Expand All @@ -43,7 +45,9 @@ public SubwayConfusionRespDto getConfusion(
public List<SubwayConfusionRespDto> getConfusionList(
Long stationId, String dayType, String updown, String startTimeSlot, String endTimeSlot
) throws StationNotFoundException, InvalidTypeException {
isExisted(stationId);
if (!stationRepository.existsById(stationId)) {
throw new StationNotFoundException(stationId);
}

List<SubwayConfusionEntity> entityList = confusionRepository.findBySubwayStationIdAndDayTypeAndUpdownAndTimeSlotBetween(
stationId,
Expand All @@ -57,11 +61,4 @@ public List<SubwayConfusionRespDto> getConfusionList(
.map(SubwayConfusionRespDto::of)
.toList();
}

private void isExisted(Long stationId) {
if (!stationRepository.existsById(stationId)) {
throw new StationNotFoundException(stationId);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public SubwayTimetableRespDto getTimetable(
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("H:mm:ss");
LocalTime parseTime = LocalTime.parse(time, formatter);

isExisted(stationId);
if (!stationRepository.existsById(stationId)) {
throw new StationNotFoundException(stationId);
}

SubwayTimetableEntity entity = timetableRepository.findBySubwayStationIdAndDayTypeAndUpdownAndArrivalTime(
stationId, DayType.valueOfEnumString(dayTypeCode), Updown.valueOfEnumString(updownCode), parseTime
Expand All @@ -48,7 +50,9 @@ public List<SubwayTimetableRespDto> getTimetableList(
LocalTime start = LocalTime.parse(startTime, formatter);
LocalTime end = LocalTime.parse(endTime, formatter);

isExisted(stationId);
if (!stationRepository.existsById(stationId)) {
throw new StationNotFoundException(stationId);
}

List<SubwayTimetableEntity> entityList = timetableRepository.findBySubwayStationIdAndDayTypeAndUpdownAndArrivalTimeBetween(
stationId, DayType.valueOfEnumString(dayTypeCode), Updown.valueOfEnumString(updownCode), start, end
Expand All @@ -58,10 +62,4 @@ public List<SubwayTimetableRespDto> getTimetableList(
.map(SubwayTimetableRespDto::of)
.toList();
}

private void isExisted(Long stationId) {
if (!stationRepository.existsById(stationId)) {
throw new StationNotFoundException(stationId);
}
}
}

0 comments on commit 4c97313

Please sign in to comment.