diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueRespVO.java index 8cbd45a7f..25fa25f02 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/propertyvalue/vo/ProductPropertyValueRespVO.java @@ -11,7 +11,7 @@ import io.swagger.annotations.*; public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO { @ApiModelProperty(value = "主键", required = true) - private Integer id; + private Long id; @ApiModelProperty(value = "创建时间") private Date createTime; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java index 7f8d00f71..0036225ab 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java @@ -12,8 +12,7 @@ import javax.validation.constraints.*; @Data public class ProductSkuBaseVO { - @ApiModelProperty(value = "spu编号", required = true) - @NotNull(message = "spu编号不能为空") + @ApiModelProperty(value = "spu编号") private Long spuId; @ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]", required = true) @@ -46,9 +45,9 @@ public class ProductSkuBaseVO { @Data public static class Property { @NotNull(message = "规格属性名id不能为空") - private Integer propertyId; + private Long propertyId; @NotNull(message = "规格属性值id不能为空") - private Integer valueId; + private Long valueId; } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java index 0f31b4f23..16d189a74 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuExcelVO.java @@ -15,7 +15,7 @@ import com.alibaba.excel.annotation.ExcelProperty; public class ProductSkuExcelVO { @ExcelProperty("主键") - private Integer id; + private Long id; @ExcelProperty("spu编号") private Long spuId; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java index cf5e83fb7..3b12ba21c 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java @@ -11,7 +11,7 @@ import io.swagger.annotations.*; public class ProductSkuRespVO extends ProductSkuBaseVO { @ApiModelProperty(value = "主键", required = true) - private Integer id; + private Long id; @ApiModelProperty(value = "创建时间") private Date createTime; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java index ee61ce4e6..05b8a833f 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java @@ -65,8 +65,7 @@ public class ProductSpuController { @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('product:spu:query')") public CommonResult getSpu(@RequestParam("id") Long id) { - ProductSpuDO spu = spuService.getSpu(id); - return success(ProductSpuConvert.INSTANCE.convert(spu)); + return success(spuService.getSpu(id)); } @GetMapping("/list") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java index 826b68a74..95567e27e 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/SpuRespVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.product.controller.admin.spu.vo; +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; import lombok.*; import java.util.*; import io.swagger.annotations.*; @@ -16,4 +17,6 @@ public class SpuRespVO extends ProductSpuBaseVO { @ApiModelProperty(value = "创建时间") private Date createTime; + List productSkuRespVOS; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/propertyvalue/ProductPropertyValueDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/propertyvalue/ProductPropertyValueDO.java index 2dd1e80b6..80e68ac4c 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/propertyvalue/ProductPropertyValueDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/propertyvalue/ProductPropertyValueDO.java @@ -27,7 +27,7 @@ public class ProductPropertyValueDO extends BaseDO { * 主键 */ @TableId - private Integer id; + private Long id; /** * 规格键 id * diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java index 23fc2e1bd..37e537bfa 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/sku/ProductSkuMapper.java @@ -5,6 +5,7 @@ import java.util.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import org.apache.ibatis.annotations.Mapper; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*; @@ -45,4 +46,9 @@ public interface ProductSkuMapper extends BaseMapperX { .orderByDesc(ProductSkuDO::getId)); } + default List selectBySpuId(Long spuId) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ProductSkuDO::getSpuId, spuId) + ); + } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java index 1e6d13c3a..a663a49ce 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java @@ -81,5 +81,5 @@ public interface ProductPropertyService { * @param propertyIds 属性名id集合 * @return */ - List selectByIds(List propertyIds); + List selectByIds(List propertyIds); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java index f6fadaae0..55a725d44 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java @@ -1,10 +1,7 @@ package cn.iocoder.yudao.module.product.service.property; -import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.product.controller.admin.property.vo.*; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyCreateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.property.vo.ProductPropertyUpdateReqVO; import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueCreateReqVO; import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO; import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert; @@ -12,7 +9,7 @@ import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValu import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.ProductPropertyValueDO; import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyMapper; -import cn.iocoder.yudao.module.product.service.propertyvalue.ProductPropertyValueService; +import cn.iocoder.yudao.module.product.dal.mysql.propertyvalue.ProductPropertyValueMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -21,6 +18,7 @@ import javax.annotation.Resource; import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -39,7 +37,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { private ProductPropertyMapper productPropertyMapper; @Resource - private ProductPropertyValueService productPropertyValueService; + private ProductPropertyValueMapper productPropertyValueMapper; @Override @Transactional(rollbackFor = Exception.class) @@ -52,7 +50,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { List propertyValueList = createReqVO.getPropertyValueList(); List productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList); productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(property.getId())); - productPropertyValueService.batchInsert(productPropertyValueDOList); + productPropertyValueMapper.insertBatch(productPropertyValueDOList); // 返回 return property.getId(); } @@ -66,11 +64,11 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO); productPropertyMapper.updateById(updateObj); //更新属性值,先删后加 - productPropertyValueService.deletePropertyValueByPropertyId(updateReqVO.getId()); + productPropertyValueMapper.deletePropertyValueByPropertyId(updateReqVO.getId()); List propertyValueList = updateReqVO.getPropertyValueList(); List productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList); productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(updateReqVO.getId())); - productPropertyValueService.batchInsert(productPropertyValueDOList); + productPropertyValueMapper.insertBatch(productPropertyValueDOList); } @Override @@ -80,7 +78,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { // 删除 productPropertyMapper.deleteById(id); //同步删除属性值 - productPropertyValueService.deletePropertyValueByPropertyId(id); + productPropertyValueMapper.deletePropertyValueByPropertyId(id); } private void validatePropertyExists(Long id) { @@ -117,7 +115,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { List propertyIds = propertyRespVOPageResult.getList().stream().map(ProductPropertyRespVO::getId).collect(Collectors.toList()); //获取属性值列表 - List productPropertyValueDOList = productPropertyValueService.getPropertyValueListByPropertyId(propertyIds); + List productPropertyValueDOList = productPropertyValueMapper.getPropertyValueListByPropertyId(propertyIds); List propertyValueRespVOList = ProductPropertyValueConvert.INSTANCE.convertList(productPropertyValueDOList); //组装一对多 propertyRespVOPageResult.getList().forEach(x->{ @@ -128,13 +126,17 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { return propertyRespVOPageResult; } + private List getPropertyValueListByPropertyId(List propertyIds) { + return productPropertyValueMapper.getPropertyValueListByPropertyId(propertyIds); + } + @Override public ProductPropertyRespVO getPropertyResp(Long id) { //查询规格 ProductPropertyDO property = getProperty(id); ProductPropertyRespVO propertyRespVO = ProductPropertyConvert.INSTANCE.convert(property); //查询属性值 - List valueDOList = productPropertyValueService.getPropertyValueListByPropertyId(Arrays.asList(id)); + List valueDOList = productPropertyValueMapper.getPropertyValueListByPropertyId(Arrays.asList(id)); List propertyValueRespVOS = ProductPropertyValueConvert.INSTANCE.convertList(valueDOList); //组装 propertyRespVO.setPropertyValueList(propertyValueRespVOS); @@ -142,7 +144,12 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { } @Override - public List selectByIds(List propertyIds) { - return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectBatchIds(propertyIds)); + public List selectByIds(List propertyIds) { + List productPropertyRespVO = ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectBatchIds(propertyIds)); + //查询属性值 + List valueDOList = productPropertyValueMapper.getPropertyValueListByPropertyId(propertyIds); + Map> propertyValuesMap = valueDOList.stream().collect(Collectors.groupingBy(ProductPropertyValueDO::getPropertyId)); + productPropertyRespVO.forEach(p -> p.setPropertyValueList(ProductPropertyValueConvert.INSTANCE.convertList(propertyValuesMap.get(p.getId())))); + return productPropertyRespVO; } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/ProductProductPropertyValueServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/ProductProductPropertyValueServiceImpl.java deleted file mode 100644 index 764f59c32..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/ProductProductPropertyValueServiceImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -package cn.iocoder.yudao.module.product.service.propertyvalue; - -import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.*; -import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert; -import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.ProductPropertyValueDO; -import cn.iocoder.yudao.module.product.dal.mysql.propertyvalue.ProductPropertyValueMapper; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.Collection; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_NOT_EXISTS; - -/** - * 规格值 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -public class ProductProductPropertyValueServiceImpl implements ProductPropertyValueService { - - @Resource - private ProductPropertyValueMapper productPropertyValueMapper; - - // TODO @franky:这个合并到 property 中。他们本身是在一起的哈。基本不存在只查询规格,而不查询规格值。 - - @Override - public Integer createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) { - // 插入 - ProductPropertyValueDO propertyValue = ProductPropertyValueConvert.INSTANCE.convert(createReqVO); - productPropertyValueMapper.insert(propertyValue); - // 返回 - return propertyValue.getId(); - } - - @Override - public void updatePropertyValue(ProductPropertyValueUpdateReqVO updateReqVO) { - // 校验存在 - this.validatePropertyValueExists(updateReqVO.getId()); - // 更新 - ProductPropertyValueDO updateObj = ProductPropertyValueConvert.INSTANCE.convert(updateReqVO); - productPropertyValueMapper.updateById(updateObj); - } - - @Override - public void deletePropertyValue(Integer id) { - // 校验存在 - this.validatePropertyValueExists(id); - // 删除 - productPropertyValueMapper.deleteById(id); - } - - private void validatePropertyValueExists(Integer id) { - if (productPropertyValueMapper.selectById(id) == null) { - throw exception(PROPERTY_VALUE_NOT_EXISTS); - } - } - - @Override - public ProductPropertyValueDO getPropertyValue(Integer id) { - return productPropertyValueMapper.selectById(id); - } - - @Override - public List getPropertyValueList(Collection ids) { - return productPropertyValueMapper.selectBatchIds(ids); - } - - @Override - public void batchInsert(List propertyValues) { - productPropertyValueMapper.insertBatch(propertyValues); - } - - @Override - public List getPropertyValueListByPropertyId(List propertyIds) { - return productPropertyValueMapper.getPropertyValueListByPropertyId(propertyIds); - } - - @Override - public void deletePropertyValueByPropertyId(Long propertyId) { - productPropertyValueMapper.deletePropertyValueByPropertyId(propertyId); - } - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/ProductPropertyValueService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/ProductPropertyValueService.java deleted file mode 100644 index a2bab1cf7..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/propertyvalue/ProductPropertyValueService.java +++ /dev/null @@ -1,71 +0,0 @@ -package cn.iocoder.yudao.module.product.service.propertyvalue; - -import java.util.*; -import javax.validation.*; -import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.*; -import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.ProductPropertyValueDO; - -/** - * 规格值 Service 接口 - * - * @author 芋道源码 - */ -public interface ProductPropertyValueService { - - /** - * 创建规格值 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Integer createPropertyValue(@Valid ProductPropertyValueCreateReqVO createReqVO); - - /** - * 更新规格值 - * - * @param updateReqVO 更新信息 - */ - void updatePropertyValue(@Valid ProductPropertyValueUpdateReqVO updateReqVO); - - /** - * 删除规格值 - * - * @param id 编号 - */ - void deletePropertyValue(Integer id); - - /** - * 获得规格值 - * - * @param id 编号 - * @return 规格值 - */ - ProductPropertyValueDO getPropertyValue(Integer id); - - /** - * 获得规格值列表 - * - * @param ids 编号 - * @return 规格值列表 - */ - List getPropertyValueList(Collection ids); - - /** - * 批量插入属性值 - * @param propertyValues - */ - void batchInsert(List propertyValues); - - /** - * 根据属性id查询 - * @param propertyIds - * @return - */ - List getPropertyValueListByPropertyId(List propertyIds); - - /** - * 根据属性id 删除 - * @param propertyId - */ - void deletePropertyValueByPropertyId(Long propertyId); -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java index df10d777e..f08944cfc 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuService.java @@ -79,4 +79,12 @@ public interface ProductSkuService { * @return */ void batchSave(List skuDOList); + + /** + * 获得商品sku 集合 + * + * @param spuId spu 编号 + * @return 商品sku 集合 + */ + List getSkusBySpuId(Long spuId); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java index eed0ee91f..e542872c4 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java @@ -92,7 +92,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { public void validatedSkuReq(List skuCreateReqList) { List skuPropertyList = skuCreateReqList.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList()); // 校验规格属性以及规格值是否存在 - List propertyIds = skuPropertyList.stream().map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList()); + List propertyIds = skuPropertyList.stream().map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList()); List propertyAndValueList = productPropertyService.selectByIds(propertyIds); if (propertyAndValueList.isEmpty()) throw ServiceExceptionUtil.exception(PROPERTY_NOT_EXISTS); @@ -122,4 +122,9 @@ public class ProductSkuServiceImpl implements ProductSkuService { public void batchSave(List skuDOList) { productSkuMapper.insertBatch(skuDOList); } + + @Override + public List getSkusBySpuId(Long spuId) { + return productSkuMapper.selectBySpuId(spuId); + } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java index e0a3409b1..d51c8d678 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java @@ -41,7 +41,7 @@ public interface ProductSpuService { * @param id 编号 * @return 商品spu */ - ProductSpuDO getSpu(Long id); + SpuRespVO getSpu(Long id); /** * 获得商品spu列表 diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index d0eb5879a..caa79fe5a 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.product.service.spu; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateReqVO; +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.service.category.CategoryService; @@ -89,8 +90,12 @@ public class ProductSpuServiceImpl implements ProductSpuService { } @Override - public ProductSpuDO getSpu(Long id) { - return ProductSpuMapper.selectById(id); + public SpuRespVO getSpu(Long id) { + ProductSpuDO spu = ProductSpuMapper.selectById(id); + SpuRespVO spuVO = ProductSpuConvert.INSTANCE.convert(spu); + List skuReqs = ProductSkuConvert.INSTANCE.convertList( productSkuService.getSkusBySpuId(id)); + spuVO.setProductSkuRespVOS(skuReqs); + return spuVO; } @Override