|
|
@@ -5,6 +5,7 @@ import com.izouma.ticketExchange.domain.Cinema;
|
|
|
import com.izouma.ticketExchange.domain.Location;
|
|
|
import com.izouma.ticketExchange.domain.Schedule;
|
|
|
import com.izouma.ticketExchange.domain.Show;
|
|
|
+import com.izouma.ticketExchange.exception.BusinessException;
|
|
|
import com.izouma.ticketExchange.repo.CinemaRepo;
|
|
|
import com.izouma.ticketExchange.repo.LocationRepo;
|
|
|
import com.izouma.ticketExchange.repo.ScheduleRepo;
|
|
|
@@ -59,6 +60,7 @@ public class SyncService {
|
|
|
|
|
|
public void syncCityShow() {
|
|
|
Set<Show> allShows = new HashSet<>();
|
|
|
+ List<Location> locationList = new ArrayList<>();
|
|
|
tppService.getLocations().forEach(region -> {
|
|
|
Location location = Location.builder()
|
|
|
.id(region.getId())
|
|
|
@@ -69,26 +71,13 @@ public class SyncService {
|
|
|
.pinYin(region.getPinYin())
|
|
|
.hot(false)
|
|
|
.build();
|
|
|
- List<FilmDataThirdPartySoonshowsGetResponse.Show> soonShows = tppService.getSoonShows(location.getCityCode());
|
|
|
- List<FilmDataThirdPartyHotshowsGetResponse.Show> hotShows = tppService.getHotShows(location.getCityCode());
|
|
|
Set<Show> showSet = new HashSet<>();
|
|
|
Gson gson = new Gson();
|
|
|
- Optional.ofNullable(soonShows).orElse(new ArrayList<>()).forEach(soonShow -> {
|
|
|
- Show show = gson.fromJson(gson.toJson(soonShow), Show.class);
|
|
|
- if (StringUtils.isNotEmpty(soonShow.getBackgroundPicture())) {
|
|
|
- show.setBackground(imagePrefix + soonShow.getBackgroundPicture());
|
|
|
- }
|
|
|
- show.setPoster(imagePrefix + show.getPoster());
|
|
|
- if (show.getTrailerList() != null) {
|
|
|
- show.setTrailerList(show.getTrailerList().stream().map(s -> imagePrefix + s).collect(Collectors.toList()));
|
|
|
- }
|
|
|
- showSet.add(show);
|
|
|
- allShows.add(show);
|
|
|
- });
|
|
|
-// Optional.ofNullable(hotShows).orElse(new ArrayList<>()).forEach(hotShow -> {
|
|
|
-// Show show = gson.fromJson(gson.toJson(hotShow), Show.class);
|
|
|
-// if (StringUtils.isNotEmpty(hotShow.getBackgroundPicture())) {
|
|
|
-// show.setBackground(imagePrefix + hotShow.getBackgroundPicture());
|
|
|
+// List<FilmDataThirdPartySoonshowsGetResponse.Show> soonShows = tppService.getSoonShows(location.getCityCode());
|
|
|
+// Optional.ofNullable(soonShows).orElse(new ArrayList<>()).forEach(soonShow -> {
|
|
|
+// Show show = gson.fromJson(gson.toJson(soonShow), Show.class);
|
|
|
+// if (StringUtils.isNotEmpty(soonShow.getBackgroundPicture())) {
|
|
|
+// show.setBackground(imagePrefix + soonShow.getBackgroundPicture());
|
|
|
// }
|
|
|
// show.setPoster(imagePrefix + show.getPoster());
|
|
|
// if (show.getTrailerList() != null) {
|
|
|
@@ -97,11 +86,28 @@ public class SyncService {
|
|
|
// showSet.add(show);
|
|
|
// allShows.add(show);
|
|
|
// });
|
|
|
+
|
|
|
+ List<FilmDataThirdPartyHotshowsGetResponse.Show> hotShows = tppService.getHotShows(location.getCityCode());
|
|
|
+ Optional.ofNullable(hotShows).orElse(new ArrayList<>()).forEach(hotShow -> {
|
|
|
+ Show show = gson.fromJson(gson.toJson(hotShow), Show.class);
|
|
|
+ if (StringUtils.isNotEmpty(hotShow.getBackgroundPicture())) {
|
|
|
+ show.setBackground(imagePrefix + hotShow.getBackgroundPicture());
|
|
|
+ }
|
|
|
+ show.setPoster(imagePrefix + show.getPoster());
|
|
|
+ if (show.getTrailerList() != null) {
|
|
|
+ show.setTrailerList(show.getTrailerList().stream().map(s -> imagePrefix + s).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ showSet.add(show);
|
|
|
+ allShows.add(show);
|
|
|
+ });
|
|
|
location.setShows(new ArrayList<>(showSet));
|
|
|
+ locationList.add(location);
|
|
|
+ });
|
|
|
|
|
|
+ new Thread(() -> {
|
|
|
showRepo.saveAll(allShows);
|
|
|
- locationRepo.save(location);
|
|
|
- });
|
|
|
+ locationRepo.saveAll(locationList);
|
|
|
+ }).start();
|
|
|
}
|
|
|
|
|
|
public void syncCinema() {
|