|
@@ -59,7 +59,7 @@ public class MerchantClassificationService {
|
|
|
*/
|
|
*/
|
|
|
public List<Goods> showGoods(Long classificationId) {
|
|
public List<Goods> showGoods(Long classificationId) {
|
|
|
MerchantClassification merchantClassification = merchantClassificationRepo.findById(classificationId).orElseThrow(new BusinessException("分类不存在"));
|
|
MerchantClassification merchantClassification = merchantClassificationRepo.findById(classificationId).orElseThrow(new BusinessException("分类不存在"));
|
|
|
- Set<Long> goodsIds = merchantClassification.getGoodsIds();
|
|
|
|
|
|
|
+ List<Long> goodsIds = merchantClassification.getGoodsIds();
|
|
|
List<Goods> goods = CollUtil.newArrayList();
|
|
List<Goods> goods = CollUtil.newArrayList();
|
|
|
goodsIds.forEach(s -> {
|
|
goodsIds.forEach(s -> {
|
|
|
goods.add(goodsRepo.findById(s).orElseThrow(new BusinessException("商品不存在")));
|
|
goods.add(goodsRepo.findById(s).orElseThrow(new BusinessException("商品不存在")));
|
|
@@ -78,10 +78,11 @@ public class MerchantClassificationService {
|
|
|
//查找分类
|
|
//查找分类
|
|
|
MerchantClassification merchantClassification = merchantClassificationRepo.findById(classificationId).orElseThrow(new BusinessException("无分类"));
|
|
MerchantClassification merchantClassification = merchantClassificationRepo.findById(classificationId).orElseThrow(new BusinessException("无分类"));
|
|
|
|
|
|
|
|
- Set<Long> goodsIds = merchantClassification.getGoodsIds();
|
|
|
|
|
|
|
+ List<Long> goodsIds = merchantClassification.getGoodsIds();
|
|
|
LongArrayConverter converter = new LongArrayConverter();
|
|
LongArrayConverter converter = new LongArrayConverter();
|
|
|
List<Long> longs = converter.convertToEntityAttribute(string);
|
|
List<Long> longs = converter.convertToEntityAttribute(string);
|
|
|
- goodsIds.addAll(longs);
|
|
|
|
|
|
|
+ longs.stream().filter(l -> !goodsIds.contains(l)).forEach(goodsIds::add);
|
|
|
|
|
+ //goodsIds.addAll(longs);
|
|
|
|
|
|
|
|
merchantClassification.setGoodsIds(goodsIds);
|
|
merchantClassification.setGoodsIds(goodsIds);
|
|
|
|
|
|
|
@@ -95,7 +96,7 @@ public class MerchantClassificationService {
|
|
|
//查找分类
|
|
//查找分类
|
|
|
MerchantClassification merchantClassification = merchantClassificationRepo.findById(classificationId).orElseThrow(new BusinessException("无分类"));
|
|
MerchantClassification merchantClassification = merchantClassificationRepo.findById(classificationId).orElseThrow(new BusinessException("无分类"));
|
|
|
|
|
|
|
|
- Set<Long> ids = merchantClassification.getGoodsIds();
|
|
|
|
|
|
|
+ List<Long> ids = merchantClassification.getGoodsIds();
|
|
|
|
|
|
|
|
if (!ids.contains(goodsId)) {
|
|
if (!ids.contains(goodsId)) {
|
|
|
ids.add(goodsId);
|
|
ids.add(goodsId);
|
|
@@ -111,7 +112,7 @@ public class MerchantClassificationService {
|
|
|
//查找分类
|
|
//查找分类
|
|
|
MerchantClassification merchantClassification = merchantClassificationRepo.findById(classificationId).orElseThrow(new BusinessException("无分类"));
|
|
MerchantClassification merchantClassification = merchantClassificationRepo.findById(classificationId).orElseThrow(new BusinessException("无分类"));
|
|
|
|
|
|
|
|
- Set<Long> goodsIds = merchantClassification.getGoodsIds();
|
|
|
|
|
|
|
+ List<Long> goodsIds = merchantClassification.getGoodsIds();
|
|
|
goodsIds.remove(goodId);
|
|
goodsIds.remove(goodId);
|
|
|
merchantClassification.setGoodsIds(goodsIds);
|
|
merchantClassification.setGoodsIds(goodsIds);
|
|
|
|
|
|