|
@@ -1,20 +1,19 @@
|
|
|
package com.ym.mec.cms.service.impl;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
import com.ym.mec.cms.dal.dao.SysNewsInformationDao;
|
|
|
-import com.ym.mec.cms.dal.entity.SysNewsInformation;
|
|
|
-import org.apache.commons.collections.CollectionUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
import com.ym.mec.cms.dal.dao.SysNewsTypeDao;
|
|
|
+import com.ym.mec.cms.dal.entity.SysNewsInformation;
|
|
|
import com.ym.mec.cms.dal.entity.SysNewsType;
|
|
|
import com.ym.mec.cms.dal.entity.SysNewsTypeTree;
|
|
|
import com.ym.mec.cms.service.SysNewsTypeService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class SysNewsTypeServiceImpl extends BaseServiceImpl<Integer, SysNewsType> implements SysNewsTypeService {
|
|
@@ -61,25 +60,17 @@ public class SysNewsTypeServiceImpl extends BaseServiceImpl<Integer, SysNewsType
|
|
|
e.setInformationList(list);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- List<SysNewsType> treeMenus = all.stream().filter((categoryEntity) -> {
|
|
|
- return categoryEntity.getParentId() == newsType.getParentId();
|
|
|
- }).map((menu) -> {
|
|
|
- menu.setChildren(getChildren(menu, all));
|
|
|
- return menu;
|
|
|
- }).filter(e -> {
|
|
|
- return e.getId().equals(id);
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ List<SysNewsType> treeMenus = all.stream()
|
|
|
+ .filter((e) -> e.getParentId().equals(newsType.getParentId()) || e.getId().equals(id))
|
|
|
+ .map((menu) -> menu.setChildren(getChildren(menu, all)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
return treeMenus;
|
|
|
}
|
|
|
|
|
|
private List<SysNewsType> getChildren(SysNewsType rootMenu, List<SysNewsType> allMenus) {
|
|
|
- List<SysNewsType> childrenList = allMenus.stream().filter(categoryEntity -> {
|
|
|
- return categoryEntity.getParentId().equals(rootMenu.getId());
|
|
|
- }).map(menu -> {
|
|
|
- menu.setChildren(getChildren(menu, allMenus));
|
|
|
- return menu;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ List<SysNewsType> childrenList = allMenus.stream().filter(e -> e.getParentId().equals(rootMenu.getId()))
|
|
|
+ .map(menu -> menu.setChildren(getChildren(menu, allMenus)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
return childrenList;
|
|
|
}
|
|
|
}
|