Commit a1a99c0d by huluobin

update

parent 4c802a0d
...@@ -3,7 +3,6 @@ package com.gogirl.application.product.mall.impl; ...@@ -3,7 +3,6 @@ package com.gogirl.application.product.mall.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.product.mall.MallCategoryService; import com.gogirl.application.product.mall.MallCategoryService;
import com.gogirl.domain.product.mall.MallCategory; import com.gogirl.domain.product.mall.MallCategory;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.mapper.order.mall.CategoryMapper; import com.gogirl.infrastructure.mapper.order.mall.CategoryMapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -25,7 +24,9 @@ public class MallCategoryServiceImpl extends ServiceImpl<CategoryMapper, MallCat ...@@ -25,7 +24,9 @@ public class MallCategoryServiceImpl extends ServiceImpl<CategoryMapper, MallCat
@Override @Override
public List<MallCategory> getCategoryList(Long categoryId) { public List<MallCategory> getCategoryList(Long categoryId) {
List<MallCategory> list = this.getCategoryTreeList(); List<MallCategory> list = this.getCategoryTreeList();
return findSubTree(list, categoryId); List<MallCategory> result = new ArrayList<>();
findSubTree(list, categoryId, result);
return result;
} }
/** /**
...@@ -34,19 +35,17 @@ public class MallCategoryServiceImpl extends ServiceImpl<CategoryMapper, MallCat ...@@ -34,19 +35,17 @@ public class MallCategoryServiceImpl extends ServiceImpl<CategoryMapper, MallCat
* @param list * @param list
* @param subTreeId * @param subTreeId
*/ */
private List<MallCategory> findSubTree(List<MallCategory> list, Long subTreeId) { private void findSubTree(List<MallCategory> list, Long subTreeId, List<MallCategory> result) {
for (MallCategory mallCategory : list) { for (MallCategory mallCategory : list) {
if (mallCategory.getChildList() == null) {
mallCategory.setChildList(new ArrayList<>());
}
if (mallCategory.getId().equals(subTreeId)) { if (mallCategory.getId().equals(subTreeId)) {
if (ListUtil.isEmpty(mallCategory.getChildList())) { result.addAll(mallCategory.getChildList());
return new ArrayList<>();
}
return mallCategory.getChildList();
} else if (ListUtil.isNotEmpty(mallCategory.getChildList())) {
this.findSubTree(mallCategory.getChildList(), subTreeId);
} }
findSubTree(mallCategory.getChildList(), subTreeId, result);
} }
return new ArrayList<>();
} }
/** /**
......
spring: spring:
profiles: profiles:
active: prod active: pre
servlet: servlet:
#文件上传最大容量 #文件上传最大容量
multipart: multipart:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment