|
|
@@ -14,6 +14,7 @@ import com.izouma.nineth.repo.CollectionRepo;
|
|
|
import com.izouma.nineth.repo.ShowCollectionRepo;
|
|
|
import com.izouma.nineth.repo.ShowroomRepo;
|
|
|
import com.izouma.nineth.utils.JpaUtils;
|
|
|
+import com.izouma.nineth.utils.ObjUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
@@ -61,6 +62,10 @@ public class ShowroomService {
|
|
|
}
|
|
|
|
|
|
List<ShowCollection> showCollections = showroom.getCollections();
|
|
|
+ if (asset.getMaxCollection() < showCollections.size()) {
|
|
|
+ throw new BusinessException("选择的藏品数量大于最多可放置数量");
|
|
|
+ }
|
|
|
+
|
|
|
List<Long> collectionIds = showCollections.stream()
|
|
|
.map(ShowCollection::getCollectionId)
|
|
|
.collect(Collectors.toList());
|
|
|
@@ -92,9 +97,20 @@ public class ShowroomService {
|
|
|
Showroom room = showroomRepo.findById(showroom.getId()).orElseThrow(new BusinessException("无展厅"));
|
|
|
if (CollUtil.isNotEmpty(room.getCollections())) {
|
|
|
List<ShowCollection> collections = showCollectionRepo.findAllByShowroomId(showroom.getId());
|
|
|
+ Map<Long, ShowCollection> showCollectionMap = collections.stream()
|
|
|
+ .collect(Collectors.toMap(ShowCollection::getId, coll -> coll));
|
|
|
+
|
|
|
+
|
|
|
room.getCollections().forEach(coll -> {
|
|
|
if (coll.getId() != null) {
|
|
|
-
|
|
|
+ ShowCollection showCollection = showCollectionMap.get(coll.getId());
|
|
|
+ ObjUtils.merge(showCollection, coll);
|
|
|
+ showCollectionRepo.save(showCollection);
|
|
|
+ } else {
|
|
|
+// coll.setPic(collection.getPic().get(0).getUrl());
|
|
|
+// coll.setShowroomId(room.getId());
|
|
|
+// coll.setAssetId(collection.getAssetId());
|
|
|
+// showCollectionRepo.save(showCollection);
|
|
|
}
|
|
|
});
|
|
|
}
|