diff --git a/src/main/java/com/hanaro/triptogether/trip/service/TripService.java b/src/main/java/com/hanaro/triptogether/trip/service/TripService.java index 52512cc..95045bb 100644 --- a/src/main/java/com/hanaro/triptogether/trip/service/TripService.java +++ b/src/main/java/com/hanaro/triptogether/trip/service/TripService.java @@ -52,7 +52,9 @@ public Trip findByTripIdx(Long tripIdx) { public List getTripsByTeam(Long teamIdx) { teamService.findTeamByTeamIdx(teamIdx); // 팀 확인 + System.out.println("팀 존재~~"); List trips = tripRepository.findAllByTeam_TeamIdx(teamIdx); + System.out.println("여행 사이즈~~"+trips.size()); List dtos = new ArrayList<>(); for (Trip trip : trips) { dtos.add(toTripResDto(trip)); @@ -133,6 +135,18 @@ public void deleteTrip(Long tripIdx) throws NoSuchElementException{ private TripResDto toTripResDto(Trip trip) { List tripCities = tripCityService.getTripCountry(trip.getTripIdx()); + if(tripCities.isEmpty() || tripCities.get(0).getCity()==null || tripCities.get(0).getCity().getCountry()==null) { + return TripResDto.builder() + .teamIdx(trip.getTeam().getTeamIdx()) + .teamName(trip.getTeam().getTeamName()) + .tripIdx(trip.getTripIdx()) + .tripDay(trip.getTripDay()) + .tripContent(trip.getTripContent()) + .tripGoalAmount(trip.getTripGoalAmount()) + .tripName(trip.getTripName()) + .tripStartDay(trip.getTripStartDay()) + .build(); + } List cities = tripCities.stream().map(tripCity -> tripCity.getCity().toCity()).toList(); CountryEntity country = tripCities.get(0).getCity().getCountry(); return TripResDto.builder() diff --git a/src/main/java/com/hanaro/triptogether/tripCity/domain/TripCity.java b/src/main/java/com/hanaro/triptogether/tripCity/domain/TripCity.java index de4ee94..5894502 100644 --- a/src/main/java/com/hanaro/triptogether/tripCity/domain/TripCity.java +++ b/src/main/java/com/hanaro/triptogether/tripCity/domain/TripCity.java @@ -28,7 +28,7 @@ public class TripCity { private Trip trip; @ManyToOne - @JoinColumn(name = "city_idx", nullable = false) + @JoinColumn(name = "city_idx") private CityEntity city; @ManyToOne