mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 08:25:07 +08:00
feature(uniapp商品): 新增商品数据
This commit is contained in:
@ -19,8 +19,7 @@ public class ProductSkuBaseVO {
|
||||
|
||||
// TODO @franky:类似这种字段,有额外说明的。可以写成; @ApiModelProperty(value = "规格值数组", required = true, notes = "json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]")
|
||||
|
||||
@ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]", required = true)
|
||||
@NotNull(message = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]不能为空")
|
||||
@ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]")
|
||||
private List<Property> properties;
|
||||
|
||||
@ApiModelProperty(value = "销售价格,单位:分", required = true)
|
||||
|
@ -91,7 +91,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
|
||||
@Override
|
||||
public void validateSkus(List<ProductSkuCreateReqVO> list) {
|
||||
List<ProductSkuBaseVO.Property> skuPropertyList = list.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList());
|
||||
List<ProductSkuBaseVO.Property> skuPropertyList = list.stream().flatMap(p -> Optional.of(p.getProperties()).orElse(new ArrayList<>()).stream()).collect(Collectors.toList());
|
||||
// 校验规格属性以及规格值是否存在
|
||||
List<Long> propertyIds = skuPropertyList.stream().map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList());
|
||||
List<ProductPropertyRespVO> propertyAndValueList = productPropertyService.selectByIds(propertyIds);
|
||||
|
@ -57,7 +57,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
categoryService.validateProductCategory(createReqVO.getCategoryId());
|
||||
// 校验SKU
|
||||
List<ProductSkuCreateReqVO> skuCreateReqList = createReqVO.getSkus();
|
||||
productSkuService.validateSkus(skuCreateReqList);
|
||||
if(createReqVO.getSpecType() == 1) {
|
||||
productSkuService.validateSkus(skuCreateReqList);
|
||||
}
|
||||
// 插入SPU
|
||||
ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO);
|
||||
ProductSpuMapper.insert(spu);
|
||||
@ -81,7 +83,9 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
categoryService.validateProductCategory(updateReqVO.getCategoryId());
|
||||
// 校验SKU
|
||||
List<ProductSkuCreateReqVO> skuCreateReqList = updateReqVO.getSkus();
|
||||
productSkuService.validateSkus(skuCreateReqList);
|
||||
if(updateReqVO.getSpecType() == 1) {
|
||||
productSkuService.validateSkus(skuCreateReqList);
|
||||
}
|
||||
// 更新
|
||||
ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO);
|
||||
ProductSpuMapper.updateById(updateObj);
|
||||
|
Reference in New Issue
Block a user