mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-08-01 03:44:07 +08:00
trade:增加管理后台的订单分页接口
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.product.api.property;
|
||||
|
||||
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
||||
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品属性值 API 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductPropertyValueApiImpl implements ProductPropertyValueApi {
|
||||
|
||||
@Resource
|
||||
private ProductPropertyValueService productPropertyValueService;
|
||||
|
||||
@Override
|
||||
public List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids) {
|
||||
return ProductPropertyValueConvert.INSTANCE.convertList02(
|
||||
productPropertyValueService.getPropertyValueDetailList(ids));
|
||||
}
|
||||
|
||||
}
|
@@ -63,7 +63,7 @@ public class ProductPropertyController {
|
||||
@ApiOperation("获得属性项列表")
|
||||
@PreAuthorize("@ss.hasPermission('product:property:query')")
|
||||
public CommonResult<List<ProductPropertyRespVO>> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) {
|
||||
return success(productPropertyService.getPropertyList(listReqVO));
|
||||
return success(productPropertyService.getPropertyVOList(listReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@@ -1,14 +1,22 @@
|
||||
package cn.iocoder.yudao.module.product.convert.propertyvalue;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
||||
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
/**
|
||||
* 属性值 Convert
|
||||
@@ -30,6 +38,18 @@ public interface ProductPropertyValueConvert {
|
||||
|
||||
PageResult<ProductPropertyValueRespVO> convertPage(PageResult<ProductPropertyValueDO> page);
|
||||
|
||||
List<ProductPropertyValueDO> convertList03(List<ProductPropertyValueCreateReqVO> list);
|
||||
default List<ProductPropertyValueDetailRespBO> convertList(List<ProductPropertyValueDO> values, List<ProductPropertyDO> keys) {
|
||||
Map<Long, ProductPropertyDO> keyMap = convertMap(keys, ProductPropertyDO::getId);
|
||||
return CollectionUtils.convertList(values, value -> {
|
||||
ProductPropertyValueDetailRespBO valueDetail = new ProductPropertyValueDetailRespBO()
|
||||
.setValueId(value.getId()).setValueName(value.getName());
|
||||
// 设置属性项
|
||||
MapUtils.findAndThen(keyMap, value.getPropertyId(),
|
||||
key -> valueDetail.setPropertyId(key.getId()).setPropertyName(key.getName()));
|
||||
return valueDetail;
|
||||
});
|
||||
}
|
||||
|
||||
List<ProductPropertyValueDetailRespDTO> convertList02(List<ProductPropertyValueDetailRespBO> list);
|
||||
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.service.property;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
@@ -41,7 +42,7 @@ public interface ProductPropertyService {
|
||||
* @param listReqVO 集合查询
|
||||
* @return 属性项集合
|
||||
*/
|
||||
List<ProductPropertyRespVO> getPropertyList(ProductPropertyListReqVO listReqVO);
|
||||
List<ProductPropertyRespVO> getPropertyVOList(ProductPropertyListReqVO listReqVO);
|
||||
|
||||
/**
|
||||
* 获取属性名称分页
|
||||
@@ -65,7 +66,15 @@ public interface ProductPropertyService {
|
||||
* @param ids 属性项的编号的集合
|
||||
* @return 属性项数组
|
||||
*/
|
||||
List<ProductPropertyRespVO> getPropertyList(Collection<Long> ids);
|
||||
List<ProductPropertyDO> getPropertyList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据属性项的编号的集合,获得对应的属性项数组
|
||||
*
|
||||
* @param ids 属性项的编号的集合
|
||||
* @return 属性项数组
|
||||
*/
|
||||
List<ProductPropertyRespVO> getPropertyVOList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得属性项 + 值的列表
|
||||
|
@@ -83,7 +83,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductPropertyRespVO> getPropertyList(ProductPropertyListReqVO listReqVO) {
|
||||
public List<ProductPropertyRespVO> getPropertyVOList(ProductPropertyListReqVO listReqVO) {
|
||||
return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectList(new LambdaQueryWrapperX<ProductPropertyDO>()
|
||||
.likeIfPresent(ProductPropertyDO::getName, listReqVO.getName())
|
||||
.eqIfPresent(ProductPropertyDO::getStatus, listReqVO.getStatus())));
|
||||
@@ -101,16 +101,21 @@ public class ProductPropertyServiceImpl implements ProductPropertyService {
|
||||
return ProductPropertyConvert.INSTANCE.convert(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductPropertyDO> getPropertyList(Collection<Long> ids) {
|
||||
return productPropertyMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
// TODO @芋艿:丢到 Controller
|
||||
@Override
|
||||
public List<ProductPropertyRespVO> getPropertyList(Collection<Long> ids) {
|
||||
public List<ProductPropertyRespVO> getPropertyVOList(Collection<Long> ids) {
|
||||
return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectBatchIds(ids));
|
||||
}
|
||||
|
||||
// TODO @芋艿:丢到 Controller
|
||||
@Override
|
||||
public List<ProductPropertyAndValueRespVO> getPropertyAndValueList(ProductPropertyListReqVO listReqVO) {
|
||||
List<ProductPropertyRespVO> propertyList = getPropertyList(listReqVO);
|
||||
List<ProductPropertyRespVO> propertyList = getPropertyVOList(listReqVO);
|
||||
|
||||
// 查询属性值
|
||||
List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.selectListByPropertyId(CollectionUtils.convertList(propertyList, ProductPropertyRespVO::getId));
|
||||
|
@@ -5,7 +5,9 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.Produc
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -45,6 +47,14 @@ public interface ProductPropertyValueService {
|
||||
*/
|
||||
ProductPropertyValueRespVO getPropertyValue(Long id);
|
||||
|
||||
/**
|
||||
* 根据编号数组,获得属性值列表
|
||||
*
|
||||
* @param ids 编号数组
|
||||
* @return 属性值明细列表
|
||||
*/
|
||||
List<ProductPropertyValueDetailRespBO> getPropertyValueDetailList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得属性值
|
||||
*
|
||||
|
@@ -1,21 +1,28 @@
|
||||
package cn.iocoder.yudao.module.product.service.property;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper;
|
||||
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS;
|
||||
|
||||
/**
|
||||
@@ -30,6 +37,10 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
|
||||
@Resource
|
||||
private ProductPropertyValueMapper productPropertyValueMapper;
|
||||
|
||||
@Resource
|
||||
@Lazy // 延迟加载,避免循环依赖
|
||||
private ProductPropertyService productPropertyService;
|
||||
|
||||
@Override
|
||||
public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) {
|
||||
if (productPropertyValueMapper.selectByName(createReqVO.getPropertyId(), createReqVO.getName()) != null) {
|
||||
@@ -62,6 +73,23 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
|
||||
return ProductPropertyValueConvert.INSTANCE.convert(productPropertyValueDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductPropertyValueDetailRespBO> getPropertyValueDetailList(Collection<Long> ids) {
|
||||
// 获得属性值列表
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ProductPropertyValueDO> values = productPropertyValueMapper.selectBatchIds(ids);
|
||||
if (CollUtil.isEmpty(values)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 获得属性项列表
|
||||
List<ProductPropertyDO> keys = productPropertyService.getPropertyList(
|
||||
convertSet(values, ProductPropertyValueDO::getPropertyId));
|
||||
// 组装明细
|
||||
return ProductPropertyValueConvert.INSTANCE.convertList(values, keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductPropertyValueRespVO> getPropertyValueListByPropertyId(List<Long> id) {
|
||||
return ProductPropertyValueConvert.INSTANCE.convertList(productPropertyValueMapper.selectList("property_id", id));
|
||||
|
@@ -89,7 +89,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
|
||||
.flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性
|
||||
.map(ProductSkuBaseVO.Property::getPropertyId) // 将每个 Property 转换成对应的 propertyId,最后形成集合
|
||||
.collect(Collectors.toSet());
|
||||
List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyList(propertyIds);
|
||||
List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyVOList(propertyIds);
|
||||
if (propertyList.size() != propertyIds.size()) {
|
||||
throw exception(PROPERTY_NOT_EXISTS);
|
||||
}
|
||||
|
@@ -142,7 +142,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
Map<Long, List<ProductSkuBaseVO.Property>> propertyMaps = properties.stream().collect(Collectors.groupingBy(ProductSkuBaseVO.Property::getPropertyId));
|
||||
|
||||
List<ProductPropertyValueRespVO> propertyValueList = productPropertyValueService.getPropertyValueListByPropertyId(new ArrayList<>(propertyMaps.keySet()));
|
||||
List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyList(new ArrayList<>(propertyMaps.keySet()));
|
||||
List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyVOList(new ArrayList<>(propertyMaps.keySet()));
|
||||
// 装载组装过后的属性
|
||||
List<ProductPropertyViewRespVO> productPropertyViews = new ArrayList<>();
|
||||
propertyList.forEach(p -> {
|
||||
|
@@ -188,7 +188,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
Mockito.when(productSkuService.getSkusBySpuId(createReqVO.getId())).thenReturn(productSkuDOS);
|
||||
Mockito.when(productPropertyValueService.getPropertyValueListByPropertyId(new ArrayList<>(collect.keySet()))).thenReturn(productPropertyValueRespVO);
|
||||
Mockito.when(productPropertyService.getPropertyList(new ArrayList<>(collect.keySet()))).thenReturn(productPropertyRespVOS);
|
||||
Mockito.when(productPropertyService.getPropertyVOList(new ArrayList<>(collect.keySet()))).thenReturn(productPropertyRespVOS);
|
||||
|
||||
// 调用
|
||||
ProductSpuDetailRespVO spuDetail = productSpuService.getSpuDetail(createReqVO.getId());
|
||||
|
Reference in New Issue
Block a user