Drew 6 years ago
parent
commit
c6f92db396
1 changed files with 3 additions and 4 deletions
  1. 3 4
      src/main/java/com/izouma/ticketExchange/service/TppService.java

+ 3 - 4
src/main/java/com/izouma/ticketExchange/service/TppService.java

@@ -120,7 +120,6 @@ public class TppService {
 
     public void syncLocationAndShow() {
         Set<Show> allShows = new HashSet<>();
-        List<Location> locationList = new ArrayList<>();
         getLocations().forEach(region -> {
             Location location = Location.builder()
                                         .id(region.getId())
@@ -160,10 +159,10 @@ public class TppService {
                 allShows.add(show);
             });
             location.setShows(new ArrayList<>(showSet));
-            locationList.add(location);
+
+            showRepo.saveAll(allShows);
+            locationRepo.save(location);
         });
-        showRepo.saveAll(allShows);
-        locationRepo.saveAll(locationList);
     }
 
     public List<FilmDataThirdPartyCinemasGetResponse.MtopCinema> getCinemas(Integer page) {