|
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -53,7 +54,26 @@ public class SiteArticleServiceImpl extends AbstractCrudService<SiteArticleMappe
|
|
|
categoryidList.add(list.get(i).getId());
|
|
|
}
|
|
|
} else {
|
|
|
- categoryidList.add(categoryid);
|
|
|
+ LambdaQueryWrapper<SiteCategory> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(SiteCategory::getStatus,1);
|
|
|
+ List<SiteCategory> siteCategoryList = siteCategoryMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ List<Integer> childIds = new ArrayList<>();
|
|
|
+ List<Integer> finalCategoryidList = siteCategoryList.stream().filter(site -> site.getPid().equals(categoryid))
|
|
|
+ .map(vo -> {
|
|
|
+ List<Integer> ids = getChildrenData(vo,siteCategoryList);
|
|
|
+ if(ids.size() > 0){
|
|
|
+ ids.stream().forEach(s -> childIds.add(s));
|
|
|
+ }
|
|
|
+ return vo.getId();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ finalCategoryidList.add(categoryid);
|
|
|
+ if(childIds.size() > 0){
|
|
|
+ childIds.stream().forEach(e -> finalCategoryidList.add(e));
|
|
|
+ }
|
|
|
+ for (int i = 0; i < finalCategoryidList.size(); i++) {
|
|
|
+ categoryidList.add(finalCategoryidList.get(i));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -116,4 +136,22 @@ public class SiteArticleServiceImpl extends AbstractCrudService<SiteArticleMappe
|
|
|
this.update(updateWrapper);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public List<Integer> getChildrenData(SiteCategory root,List<SiteCategory> all){
|
|
|
+ List<Integer> childIds = new ArrayList<>();
|
|
|
+ List<Integer> ids = all.stream().filter(list -> list.getPid().equals(root.getId()))
|
|
|
+ .map(list -> {
|
|
|
+ List<Integer> childs = getChildrenData(list,all);
|
|
|
+ if(childs.size() > 0){
|
|
|
+ childs.stream().forEach(s ->childIds.add(s));
|
|
|
+ }
|
|
|
+ return list.getId();
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if(childIds.size() > 0){
|
|
|
+ childIds.stream().forEach(e -> ids.add(e));
|
|
|
+ }
|
|
|
+
|
|
|
+ return ids;
|
|
|
+ }
|
|
|
}
|