|
|
@@ -1,5 +1,6 @@
|
|
|
package com.izouma.nineth.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.izouma.nineth.domain.Asset;
|
|
|
import com.izouma.nineth.domain.Collection;
|
|
|
import com.izouma.nineth.domain.ShowCollection;
|
|
|
@@ -10,6 +11,7 @@ import com.izouma.nineth.enums.CollectionType;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.AssetRepo;
|
|
|
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 lombok.AllArgsConstructor;
|
|
|
@@ -17,6 +19,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.persistence.Id;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -26,9 +29,10 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class ShowroomService {
|
|
|
|
|
|
- private ShowroomRepo showroomRepo;
|
|
|
- private AssetRepo assetRepo;
|
|
|
- private CollectionRepo collectionRepo;
|
|
|
+ private ShowroomRepo showroomRepo;
|
|
|
+ private AssetRepo assetRepo;
|
|
|
+ private CollectionRepo collectionRepo;
|
|
|
+ private ShowCollectionRepo showCollectionRepo;
|
|
|
|
|
|
public Page<Showroom> all(PageQuery pageQuery) {
|
|
|
return showroomRepo.findAll(JpaUtils.toSpecification(pageQuery, Showroom.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
@@ -79,7 +83,20 @@ public class ShowroomService {
|
|
|
showCollection.setPic(collection.getPic().get(0).getUrl());
|
|
|
showCollection.setShowroomId(show.getId());
|
|
|
showCollection.setAssetId(collection.getAssetId());
|
|
|
+ showCollectionRepo.save(showCollection);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ public void update(Showroom showroom) {
|
|
|
+ Showroom room = showroomRepo.findById(showroom.getId()).orElseThrow(new BusinessException("无展厅"));
|
|
|
+ if (CollUtil.isNotEmpty(room.getCollections())) {
|
|
|
+ List<ShowCollection> collections = showCollectionRepo.findAllByShowroomId(showroom.getId());
|
|
|
+ room.getCollections().forEach(coll -> {
|
|
|
+ if (coll.getId() != null) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|