Browse Source

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

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

42
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<CereProductClassify> getClassifySelect(ProductGetClassifyParam param) throws CoBusinessException {
List<CereProductClassify> 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<CereProductClassify> list=cereProductClassifyDAO.getAll(ContextUtil.getProject());
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());
@ -395,6 +396,43 @@ public class CereProductClassifyServiceImpl implements CereProductClassifyServic
classify.initData(ContextUtil.getLanguage());
}
}
}*/
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-business/src/main/resources/mybatis/mapper/product/CereProductClassifyDAO.xml

@ -220,7 +220,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 = #{project} ORDER BY update_time DESC,create_time DESC
</select>
</mapper>
Loading…
Cancel
Save