Commit 69ec71c4 authored by shiyu's avatar shiyu

类目

parent 3dfd0b80
......@@ -217,16 +217,23 @@ public class CategoryServiceImpl implements CategoryService {
TransverseCategoryVo transverseCategoryVo = new TransverseCategoryVo();
//查询所有的第一级类目
List<Category> categoryList = categoryDao.queryByPid(TOP_PID);
//去除和田玉
categoryList = categoryList.stream().filter(category -> category.getId() != 1009595).collect(Collectors.toList());
List<TransverseCategory> firstCategoryVoList = categoryList.stream().map(e -> TransverseCategory.ofTitle(e)).collect(Collectors.toList());
transverseCategoryVo.setFirstCategory(firstCategoryVoList);
List<Map<String, Object>> childList = new ArrayList<>();
categoryList.forEach(firstCategory -> {
List<Category> thirdCategoryList = new ArrayList<>();
for (Category firstCategory : categoryList) {
int firstCategoryId = firstCategory.getId();
//查询第二级类目
List<Category> secondCategoryList = categoryDao.queryByPid(firstCategoryId);
List<Integer> secondCategoryIdList = secondCategoryList.stream().map(Category::getId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(secondCategoryIdList)) {
//查询三级类目
List<Category> thirdCategoryList = categoryDao.queryByPids(secondCategoryIdList);
thirdCategoryList = categoryDao.queryByPids(secondCategoryIdList);
}
List<TransverseCategory> secondCategoryVoList = secondCategoryList.stream().map(e -> TransverseCategory.ofTitle(e)).collect(Collectors.toList());
List<TransverseCategory> thirdCategoryVoList = thirdCategoryList.stream().map(e -> TransverseCategory.ofTitle(e)).collect(Collectors.toList());
......@@ -235,7 +242,7 @@ public class CategoryServiceImpl implements CategoryService {
valueMap.put("secondCategory", secondCategoryVoList);
valueMap.put("thirdCategory", thirdCategoryVoList);
childList.add(valueMap);
});
}
transverseCategoryVo.setChildCategory(childList);
return Result.success(transverseCategoryVo);
} catch (Exception e) {
......
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