Kaynağa Gözat

展厅get报错

(cherry picked from commit cdf3c733bd761297908347728b7570b5bfa17ece)
licailing 3 yıl önce
ebeveyn
işleme
a695c2d124

+ 6 - 7
src/main/java/com/izouma/nineth/web/ShowroomController.java

@@ -100,13 +100,12 @@ public class ShowroomController extends BaseController {
         List<ShowCollection> origin = showCollectionRepo.findAllByShowroomIdOrderBySort(id);
         List<ShowCollection> neo = new ArrayList<>();
         if (origin != null) {
-            origin.forEach(orig -> {
-                Collection collection = collectionRepo.findById(orig.getCollectionId())
-                        .orElseThrow(new BusinessException("暂无"));
-                orig.setStatus(showroomService.getStatus(collection));
-                orig.setPrice(collection.getPrice());
-                neo.add(orig);
-            });
+            origin.forEach(orig -> collectionRepo.findById(orig.getCollectionId())
+                    .ifPresent(collection -> {
+                        orig.setStatus(showroomService.getStatus(collection));
+                        orig.setPrice(collection.getPrice());
+                        neo.add(orig);
+                    }));
         }
         showroom.setCollections(neo);
         User user = SecurityUtils.getAuthenticatedUser();