mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 01:01:52 +08:00
spu 保存,propertyValue合并到productProperty中
This commit is contained in:
parent
f07bf8b0fd
commit
4bcc6c374e
@ -11,7 +11,7 @@ import io.swagger.annotations.*;
|
|||||||
public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO {
|
public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "主键", required = true)
|
@ApiModelProperty(value = "主键", required = true)
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
@ -12,8 +12,7 @@ import javax.validation.constraints.*;
|
|||||||
@Data
|
@Data
|
||||||
public class ProductSkuBaseVO {
|
public class ProductSkuBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "spu编号", required = true)
|
@ApiModelProperty(value = "spu编号")
|
||||||
@NotNull(message = "spu编号不能为空")
|
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]", required = true)
|
@ApiModelProperty(value = "规格值数组-json格式, [{propertyId: , valueId: }, {propertyId: , valueId: }]", required = true)
|
||||||
@ -46,9 +45,9 @@ public class ProductSkuBaseVO {
|
|||||||
@Data
|
@Data
|
||||||
public static class Property {
|
public static class Property {
|
||||||
@NotNull(message = "规格属性名id不能为空")
|
@NotNull(message = "规格属性名id不能为空")
|
||||||
private Integer propertyId;
|
private Long propertyId;
|
||||||
@NotNull(message = "规格属性值id不能为空")
|
@NotNull(message = "规格属性值id不能为空")
|
||||||
private Integer valueId;
|
private Long valueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import com.alibaba.excel.annotation.ExcelProperty;
|
|||||||
public class ProductSkuExcelVO {
|
public class ProductSkuExcelVO {
|
||||||
|
|
||||||
@ExcelProperty("主键")
|
@ExcelProperty("主键")
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
@ExcelProperty("spu编号")
|
@ExcelProperty("spu编号")
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
|
@ -11,7 +11,7 @@ import io.swagger.annotations.*;
|
|||||||
public class ProductSkuRespVO extends ProductSkuBaseVO {
|
public class ProductSkuRespVO extends ProductSkuBaseVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "主键", required = true)
|
@ApiModelProperty(value = "主键", required = true)
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
@ -65,8 +65,7 @@ public class ProductSpuController {
|
|||||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||||
@PreAuthorize("@ss.hasPermission('product:spu:query')")
|
@PreAuthorize("@ss.hasPermission('product:spu:query')")
|
||||||
public CommonResult<SpuRespVO> getSpu(@RequestParam("id") Long id) {
|
public CommonResult<SpuRespVO> getSpu(@RequestParam("id") Long id) {
|
||||||
ProductSpuDO spu = spuService.getSpu(id);
|
return success(spuService.getSpu(id));
|
||||||
return success(ProductSpuConvert.INSTANCE.convert(spu));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
|
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
@ -16,4 +17,6 @@ public class SpuRespVO extends ProductSpuBaseVO {
|
|||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
List<ProductSkuRespVO> productSkuRespVOS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class ProductPropertyValueDO extends BaseDO {
|
|||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Integer id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 规格键 id
|
* 规格键 id
|
||||||
*
|
*
|
||||||
|
@ -5,6 +5,7 @@ import java.util.*;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
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 cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*;
|
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.*;
|
||||||
@ -45,4 +46,9 @@ public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {
|
|||||||
.orderByDesc(ProductSkuDO::getId));
|
.orderByDesc(ProductSkuDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<ProductSkuDO> selectBySpuId(Long spuId) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<ProductSkuDO>()
|
||||||
|
.eqIfPresent(ProductSkuDO::getSpuId, spuId)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,5 +81,5 @@ public interface ProductPropertyService {
|
|||||||
* @param propertyIds 属性名id集合
|
* @param propertyIds 属性名id集合
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ProductPropertyRespVO> selectByIds(List<Integer> propertyIds);
|
List<ProductPropertyRespVO> selectByIds(List<Long> propertyIds);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.product.service.property;
|
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.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.*;
|
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.ProductPropertyValueCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO;
|
import cn.iocoder.yudao.module.product.controller.admin.propertyvalue.vo.ProductPropertyValueRespVO;
|
||||||
import cn.iocoder.yudao.module.product.convert.property.ProductPropertyConvert;
|
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.property.ProductPropertyDO;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.propertyvalue.ProductPropertyValueDO;
|
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.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.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -21,6 +18,7 @@ import javax.annotation.Resource;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -39,7 +37,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
|||||||
private ProductPropertyMapper productPropertyMapper;
|
private ProductPropertyMapper productPropertyMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProductPropertyValueService productPropertyValueService;
|
private ProductPropertyValueMapper productPropertyValueMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@ -52,7 +50,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
|||||||
List<ProductPropertyValueCreateReqVO> propertyValueList = createReqVO.getPropertyValueList();
|
List<ProductPropertyValueCreateReqVO> propertyValueList = createReqVO.getPropertyValueList();
|
||||||
List<ProductPropertyValueDO> productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
|
List<ProductPropertyValueDO> productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
|
||||||
productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(property.getId()));
|
productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(property.getId()));
|
||||||
productPropertyValueService.batchInsert(productPropertyValueDOList);
|
productPropertyValueMapper.insertBatch(productPropertyValueDOList);
|
||||||
// 返回
|
// 返回
|
||||||
return property.getId();
|
return property.getId();
|
||||||
}
|
}
|
||||||
@ -66,11 +64,11 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
|||||||
ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO);
|
ProductPropertyDO updateObj = ProductPropertyConvert.INSTANCE.convert(updateReqVO);
|
||||||
productPropertyMapper.updateById(updateObj);
|
productPropertyMapper.updateById(updateObj);
|
||||||
//更新属性值,先删后加
|
//更新属性值,先删后加
|
||||||
productPropertyValueService.deletePropertyValueByPropertyId(updateReqVO.getId());
|
productPropertyValueMapper.deletePropertyValueByPropertyId(updateReqVO.getId());
|
||||||
List<ProductPropertyValueCreateReqVO> propertyValueList = updateReqVO.getPropertyValueList();
|
List<ProductPropertyValueCreateReqVO> propertyValueList = updateReqVO.getPropertyValueList();
|
||||||
List<ProductPropertyValueDO> productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
|
List<ProductPropertyValueDO> productPropertyValueDOList = ProductPropertyValueConvert.INSTANCE.convertList03(propertyValueList);
|
||||||
productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(updateReqVO.getId()));
|
productPropertyValueDOList.stream().forEach(x-> x.setPropertyId(updateReqVO.getId()));
|
||||||
productPropertyValueService.batchInsert(productPropertyValueDOList);
|
productPropertyValueMapper.insertBatch(productPropertyValueDOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -80,7 +78,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
|||||||
// 删除
|
// 删除
|
||||||
productPropertyMapper.deleteById(id);
|
productPropertyMapper.deleteById(id);
|
||||||
//同步删除属性值
|
//同步删除属性值
|
||||||
productPropertyValueService.deletePropertyValueByPropertyId(id);
|
productPropertyValueMapper.deletePropertyValueByPropertyId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validatePropertyExists(Long id) {
|
private void validatePropertyExists(Long id) {
|
||||||
@ -117,7 +115,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
|||||||
List<Long> propertyIds = propertyRespVOPageResult.getList().stream().map(ProductPropertyRespVO::getId).collect(Collectors.toList());
|
List<Long> propertyIds = propertyRespVOPageResult.getList().stream().map(ProductPropertyRespVO::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
//获取属性值列表
|
//获取属性值列表
|
||||||
List<ProductPropertyValueDO> productPropertyValueDOList = productPropertyValueService.getPropertyValueListByPropertyId(propertyIds);
|
List<ProductPropertyValueDO> productPropertyValueDOList = productPropertyValueMapper.getPropertyValueListByPropertyId(propertyIds);
|
||||||
List<ProductPropertyValueRespVO> propertyValueRespVOList = ProductPropertyValueConvert.INSTANCE.convertList(productPropertyValueDOList);
|
List<ProductPropertyValueRespVO> propertyValueRespVOList = ProductPropertyValueConvert.INSTANCE.convertList(productPropertyValueDOList);
|
||||||
//组装一对多
|
//组装一对多
|
||||||
propertyRespVOPageResult.getList().forEach(x->{
|
propertyRespVOPageResult.getList().forEach(x->{
|
||||||
@ -128,13 +126,17 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
|||||||
return propertyRespVOPageResult;
|
return propertyRespVOPageResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ProductPropertyValueDO> getPropertyValueListByPropertyId(List<Long> propertyIds) {
|
||||||
|
return productPropertyValueMapper.getPropertyValueListByPropertyId(propertyIds);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProductPropertyRespVO getPropertyResp(Long id) {
|
public ProductPropertyRespVO getPropertyResp(Long id) {
|
||||||
//查询规格
|
//查询规格
|
||||||
ProductPropertyDO property = getProperty(id);
|
ProductPropertyDO property = getProperty(id);
|
||||||
ProductPropertyRespVO propertyRespVO = ProductPropertyConvert.INSTANCE.convert(property);
|
ProductPropertyRespVO propertyRespVO = ProductPropertyConvert.INSTANCE.convert(property);
|
||||||
//查询属性值
|
//查询属性值
|
||||||
List<ProductPropertyValueDO> valueDOList = productPropertyValueService.getPropertyValueListByPropertyId(Arrays.asList(id));
|
List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.getPropertyValueListByPropertyId(Arrays.asList(id));
|
||||||
List<ProductPropertyValueRespVO> propertyValueRespVOS = ProductPropertyValueConvert.INSTANCE.convertList(valueDOList);
|
List<ProductPropertyValueRespVO> propertyValueRespVOS = ProductPropertyValueConvert.INSTANCE.convertList(valueDOList);
|
||||||
//组装
|
//组装
|
||||||
propertyRespVO.setPropertyValueList(propertyValueRespVOS);
|
propertyRespVO.setPropertyValueList(propertyValueRespVOS);
|
||||||
@ -142,7 +144,12 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProductPropertyRespVO> selectByIds(List<Integer> propertyIds) {
|
public List<ProductPropertyRespVO> selectByIds(List<Long> propertyIds) {
|
||||||
return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectBatchIds(propertyIds));
|
List<ProductPropertyRespVO> productPropertyRespVO = ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectBatchIds(propertyIds));
|
||||||
|
//查询属性值
|
||||||
|
List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.getPropertyValueListByPropertyId(propertyIds);
|
||||||
|
Map<Long, List<ProductPropertyValueDO>> propertyValuesMap = valueDOList.stream().collect(Collectors.groupingBy(ProductPropertyValueDO::getPropertyId));
|
||||||
|
productPropertyRespVO.forEach(p -> p.setPropertyValueList(ProductPropertyValueConvert.INSTANCE.convertList(propertyValuesMap.get(p.getId()))));
|
||||||
|
return productPropertyRespVO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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<ProductPropertyValueDO> getPropertyValueList(Collection<Integer> ids) {
|
|
||||||
return productPropertyValueMapper.selectBatchIds(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void batchInsert(List<ProductPropertyValueDO> propertyValues) {
|
|
||||||
productPropertyValueMapper.insertBatch(propertyValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ProductPropertyValueDO> getPropertyValueListByPropertyId(List<Long> propertyIds) {
|
|
||||||
return productPropertyValueMapper.getPropertyValueListByPropertyId(propertyIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deletePropertyValueByPropertyId(Long propertyId) {
|
|
||||||
productPropertyValueMapper.deletePropertyValueByPropertyId(propertyId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<ProductPropertyValueDO> getPropertyValueList(Collection<Integer> ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入属性值
|
|
||||||
* @param propertyValues
|
|
||||||
*/
|
|
||||||
void batchInsert(List<ProductPropertyValueDO> propertyValues);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据属性id查询
|
|
||||||
* @param propertyIds
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<ProductPropertyValueDO> getPropertyValueListByPropertyId(List<Long> propertyIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据属性id 删除
|
|
||||||
* @param propertyId
|
|
||||||
*/
|
|
||||||
void deletePropertyValueByPropertyId(Long propertyId);
|
|
||||||
}
|
|
@ -79,4 +79,12 @@ public interface ProductSkuService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void batchSave(List<ProductSkuDO> skuDOList);
|
void batchSave(List<ProductSkuDO> skuDOList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得商品sku 集合
|
||||||
|
*
|
||||||
|
* @param spuId spu 编号
|
||||||
|
* @return 商品sku 集合
|
||||||
|
*/
|
||||||
|
List<ProductSkuDO> getSkusBySpuId(Long spuId);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
|||||||
public void validatedSkuReq(List<ProductSkuCreateReqVO> skuCreateReqList) {
|
public void validatedSkuReq(List<ProductSkuCreateReqVO> skuCreateReqList) {
|
||||||
List<ProductSkuBaseVO.Property> skuPropertyList = skuCreateReqList.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList());
|
List<ProductSkuBaseVO.Property> skuPropertyList = skuCreateReqList.stream().flatMap(p -> p.getProperties().stream()).collect(Collectors.toList());
|
||||||
// 校验规格属性以及规格值是否存在
|
// 校验规格属性以及规格值是否存在
|
||||||
List<Integer> propertyIds = skuPropertyList.stream().map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList());
|
List<Long> propertyIds = skuPropertyList.stream().map(ProductSkuBaseVO.Property::getPropertyId).collect(Collectors.toList());
|
||||||
List<ProductPropertyRespVO> propertyAndValueList = productPropertyService.selectByIds(propertyIds);
|
List<ProductPropertyRespVO> propertyAndValueList = productPropertyService.selectByIds(propertyIds);
|
||||||
if (propertyAndValueList.isEmpty())
|
if (propertyAndValueList.isEmpty())
|
||||||
throw ServiceExceptionUtil.exception(PROPERTY_NOT_EXISTS);
|
throw ServiceExceptionUtil.exception(PROPERTY_NOT_EXISTS);
|
||||||
@ -122,4 +122,9 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
|||||||
public void batchSave(List<ProductSkuDO> skuDOList) {
|
public void batchSave(List<ProductSkuDO> skuDOList) {
|
||||||
productSkuMapper.insertBatch(skuDOList);
|
productSkuMapper.insertBatch(skuDOList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProductSkuDO> getSkusBySpuId(Long spuId) {
|
||||||
|
return productSkuMapper.selectBySpuId(spuId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public interface ProductSpuService {
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 商品spu
|
* @return 商品spu
|
||||||
*/
|
*/
|
||||||
ProductSpuDO getSpu(Long id);
|
SpuRespVO getSpu(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得商品spu列表
|
* 获得商品spu列表
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.product.service.spu;
|
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.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.convert.sku.ProductSkuConvert;
|
||||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||||
import cn.iocoder.yudao.module.product.service.category.CategoryService;
|
import cn.iocoder.yudao.module.product.service.category.CategoryService;
|
||||||
@ -89,8 +90,12 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProductSpuDO getSpu(Long id) {
|
public SpuRespVO getSpu(Long id) {
|
||||||
return ProductSpuMapper.selectById(id);
|
ProductSpuDO spu = ProductSpuMapper.selectById(id);
|
||||||
|
SpuRespVO spuVO = ProductSpuConvert.INSTANCE.convert(spu);
|
||||||
|
List<ProductSkuRespVO> skuReqs = ProductSkuConvert.INSTANCE.convertList( productSkuService.getSkusBySpuId(id));
|
||||||
|
spuVO.setProductSkuRespVOS(skuReqs);
|
||||||
|
return spuVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user