From c10ea9d9de6101e257c9e13d27f4b452f7950310 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 30 Apr 2023 17:35:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4ProductSku=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84status=E5=B1=9E=E6=80=A7=EF=BC=8C=E4=BF=AE=E6=94=B9Pro?= =?UTF-8?q?perty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../convert/property/ProductPropertyConvert.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java index 211bcc293..368da9416 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/property/ProductPropertyConvert.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.product.convert.property; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.ProductPropertyAndValueRespVO; @@ -11,9 +12,12 @@ import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyVa import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +import java.util.Collections; import java.util.List; import java.util.Map; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + /** * 属性项 Convert * @@ -38,7 +42,12 @@ public interface ProductPropertyConvert { Map> valueMap = CollectionUtils.convertMultiMap(values, ProductPropertyValueDO::getPropertyId); return CollectionUtils.convertList(keys, key -> { ProductPropertyAndValueRespVO respVO = convert02(key); - respVO.setValues(convertList02(valueMap.get(key.getId()))); + // 如果属性值为空value不为null,返回空列表 + if (CollUtil.isEmpty(values)) { + respVO.setValues(Collections.emptyList()); + }else { + respVO.setValues(convertList02(valueMap.get(key.getId()))); + } return respVO; }); }