diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereProductClassifyServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereProductClassifyServiceImpl.java index bc2341c..93303c8 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereProductClassifyServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereProductClassifyServiceImpl.java @@ -5,6 +5,7 @@ */ package com.shop.cereshop.business.service.product.impl; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.PageHelper; @@ -52,7 +53,7 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic @Autowired private CerePlatformLogService cerePlatformLogService; - + @Override public List getClassifySelect(ProductGetClassifyParam param) throws CoBusinessException { List classifyList = cereProductClassifyDAO.getClassifySelect(ContextUtil.getProject(), param.getClassifyPid()); @@ -383,7 +384,7 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic public Page getAll(ClassifyGetAllParam param) throws CoBusinessException { PageHelper.startPage(param.getPage(),param.getPageSize()); List list=cereProductClassifyDAO.getAll(ContextUtil.getProject()); - List classifyIdList = new ArrayList<>(); + /* List classifyIdList = new ArrayList<>(); classifyIdList.addAll(list.stream().map(CereProductClassify::getClassifyId).collect(Collectors.toList())); classifyIdList = classifyIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList()); @@ -395,6 +396,43 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic classify.initData(ContextUtil.getLanguage()); } } + }*/ + + for (CereProductClassify classify : list) { + List classifyIdList = new ArrayList<>(); + classifyIdList.add(classify.getClassifyId()); + //查询所有二级分类 + List classifies=cereProductClassifyDAO.findByPid(classify.getClassifyId()); + if (ObjectUtil.isNotEmpty(classifies)){ + classifyIdList.addAll(classifies.stream().map(CereProductClassify::getClassifyId).collect(Collectors.toList())); + for (CereProductClassify a : classifies) { + //查询所有三级分类 + a.setChilds(cereProductClassifyDAO.findByPid(a.getClassifyId())); + classifyIdList.addAll(a.getChilds().stream().map(CereProductClassify::getClassifyId).collect(Collectors.toList())); + } + classify.setChilds(classifies); + } + + if(ObjectUtil.isNotEmpty(classifyIdList)) { + classifyIdList = classifyIdList.stream().filter(item -> item != null && item > 0).distinct().collect(Collectors.toList()); + List cereProductClassifyLangInfoList = cereProductClassifyLangInfoService.list(Wrappers.lambdaQuery().in(CereProductClassifyLangInfo::getClassifyId, classifyIdList)); + if (ObjectUtil.isNotEmpty(classify)) { + classify.initMap(cereProductClassifyLangInfoList); + classify.initData(); + if(CollectionUtils.isNotEmpty(classify.getChilds())) { + for (CereProductClassify secondClassify : classify.getChilds()) { + secondClassify.initMap(cereProductClassifyLangInfoList); + secondClassify.initData(); + if(CollectionUtils.isNotEmpty(secondClassify.getChilds())) { + for (CereProductClassify thirdClassify : secondClassify.getChilds()) { + thirdClassify.initMap(cereProductClassifyLangInfoList); + thirdClassify.initData(); + } + } + } + } + } + } } PageInfo pageInfo=new PageInfo<>(list); Page page=new Page(pageInfo.getList(),pageInfo.getTotal()); diff --git a/cereshop-business/src/main/resources/mybatis/mapper/product/CereProductClassifyDAO.xml b/cereshop-business/src/main/resources/mybatis/mapper/product/CereProductClassifyDAO.xml index 4f1ebc0..f5bd323 100644 --- a/cereshop-business/src/main/resources/mybatis/mapper/product/CereProductClassifyDAO.xml +++ b/cereshop-business/src/main/resources/mybatis/mapper/product/CereProductClassifyDAO.xml @@ -220,7 +220,7 @@