mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
spu 查询分类展示
This commit is contained in:
parent
8aab073c13
commit
1bc812fd05
@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 商品spu Response VO")
|
||||
@ -29,4 +30,7 @@ public class SpuRespVO extends ProductSpuBaseVO {
|
||||
*/
|
||||
List<ProductSkuRespVO> skus;
|
||||
|
||||
@ApiModelProperty(value = "分类id数组,一直递归到一级父节点", example = "[1,2,4]")
|
||||
LinkedList<Long> categoryIds;
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*;
|
||||
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
|
||||
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.category.CategoryDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper;
|
||||
@ -16,9 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -105,6 +104,19 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
if (null != spuVO) {
|
||||
List<ProductSkuRespVO> skuReqs = ProductSkuConvert.INSTANCE.convertList(productSkuService.getSkusBySpuId(id));
|
||||
spuVO.setSkus(skuReqs);
|
||||
// 组合分类
|
||||
if (null != spuVO.getCategoryId()) {
|
||||
LinkedList<Long> categoryArray = new LinkedList<>();
|
||||
Long parentId = spuVO.getCategoryId();
|
||||
categoryArray.addFirst(parentId);
|
||||
while (parentId != 0) {
|
||||
parentId = categoryService.getCategory(parentId).getParentId();
|
||||
if (parentId > 0) {
|
||||
categoryArray.addFirst(parentId);
|
||||
}
|
||||
}
|
||||
spuVO.setCategoryIds(categoryArray);
|
||||
}
|
||||
}
|
||||
return spuVO;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user