Browse Source

1.分类列表获取业务功能添加子分类信息业务功能 2.解决一级分类图片上传无法显示问题

multiwx
dy-hu 8 months ago
parent
commit
2f8d917a92
  1. 43
      cereshop-admin/src/main/java/com/shop/cereshop/admin/service/product/impl/CereProductClassifyServiceImpl.java
  2. 2
      cereshop-admin/src/main/resources/mybatis/mapper/product/CereProductClassifyDAO.xml

43
cereshop-admin/src/main/java/com/shop/cereshop/admin/service/product/impl/CereProductClassifyServiceImpl.java

@ -5,6 +5,7 @@
*/
package com.shop.cereshop.admin.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;
@ -245,7 +246,7 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic
secondClassify.initMap(cereProductClassifyLangInfoList);
secondClassify.initData();
if(CollectionUtils.isNotEmpty(secondClassify.getChilds())) {
for (CereProductClassify thirdClassify : classify.getChilds()) {
for (CereProductClassify thirdClassify : secondClassify.getChilds()) {
thirdClassify.initMap(cereProductClassifyLangInfoList);
thirdClassify.initData();
}
@ -263,7 +264,7 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic
PageHelper.startPage(param.getPage(),param.getPageSize());
List<CereProductClassify> list=cereProductClassifyDAO.getAll();
List<Long> classifyIdList = new ArrayList<>();
/* List<Long> 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());
@ -276,6 +277,44 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic
}
}
}*/
for (CereProductClassify classify : list) {
List<Long> classifyIdList = new ArrayList<>();
classifyIdList.add(classify.getClassifyId());
//查询所有二级分类
List<CereProductClassify> 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<CereProductClassifyLangInfo> cereProductClassifyLangInfoList = cereProductClassifyLangInfoService.list(Wrappers.<CereProductClassifyLangInfo>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<CereProductClassify> pageInfo=new PageInfo<>(list);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());

2
cereshop-admin/src/main/resources/mybatis/mapper/product/CereProductClassifyDAO.xml

@ -163,7 +163,7 @@
</select>
<select id="getAll" resultType="com.shop.cereshop.commons.domain.product.CereProductClassify">
SELECT classify_id,classify_name FROM cere_product_classify
SELECT classify_id,classify_name,classify_image FROM cere_product_classify
where classify_level=1 AND project = '0' ORDER BY update_time DESC,create_time DESC
</select>

Loading…
Cancel
Save