From 536d8fdc8b097d9066f6fdf3657571bd399a3975 Mon Sep 17 00:00:00 2001 From: dy-hu Date: Wed, 5 Jun 2024 15:41:02 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=95=86=E5=AE=B6=E7=AB=AF=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=88=97=E8=A1=A8=E8=8E=B7=E5=8F=96=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0=E5=AD=90=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E4=BF=A1=E6=81=AF=E4=B8=9A=E5=8A=A1=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=202.=E5=95=86=E5=AE=B6=E7=AB=AF=E5=88=86=E7=B1=BB=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E4=B8=80=E7=BA=A7=E5=88=86=E7=B1=BB=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/CereProductClassifyServiceImpl.java | 42 ++++++++++++++++++++-- .../mapper/product/CereProductClassifyDAO.xml | 2 +- 2 files changed, 41 insertions(+), 3 deletions(-) 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 @@