|
@@ -2,6 +2,9 @@ package com.dgtly.system.service.impl;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
import com.dgtly.common.core.domain.Ztree;
|
|
import com.dgtly.common.core.domain.Ztree;
|
|
|
import com.dgtly.common.utils.DateUtils;
|
|
import com.dgtly.common.utils.DateUtils;
|
|
|
import com.dgtly.common.utils.StringUtils;
|
|
import com.dgtly.common.utils.StringUtils;
|
|
@@ -154,6 +157,40 @@ public class SysUserOrderAuthorServiceImpl implements ISysUserOrderAuthorService
|
|
|
return ztrees;
|
|
return ztrees;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public List<Ztree> userAuthorTreeDataFmt(Long userId) {
|
|
|
|
|
+ List<Ztree> ztrees = new ArrayList<Ztree>();
|
|
|
|
|
+ List<SysUserOrderAuthor> menuList = sysUserOrderAuthorMapper.selectSysUserOrderAuthorList(new SysUserOrderAuthor());
|
|
|
|
|
+ List<Long> user = sysUserOrderAuthorMapper.selectAuthorTree(userId);
|
|
|
|
|
+ ztrees = initTree(menuList, user);
|
|
|
|
|
+ ztrees =ztrees.stream().filter(Ztree::isChecked).collect(Collectors.toList());
|
|
|
|
|
+ ztrees = buildTree(ztrees, 0l);
|
|
|
|
|
+
|
|
|
|
|
+ return ztrees;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //把一个List转成树
|
|
|
|
|
+ static List<Ztree> buildTree(List<Ztree> list,Long pid){
|
|
|
|
|
+ List<Ztree> tree=new ArrayList<>();
|
|
|
|
|
+ for(Ztree node:list){
|
|
|
|
|
+ if(Objects.equals(node.getpId(),pid)){
|
|
|
|
|
+ tree.add(findChild(node,list));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return tree;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ static Ztree findChild(Ztree node, List<Ztree> list){
|
|
|
|
|
+ for(Ztree n:list){
|
|
|
|
|
+ if(Objects.equals(n.getpId(),node.getId())){
|
|
|
|
|
+ if(node.getChildren() == null){
|
|
|
|
|
+ node.setChildren(new ArrayList<Ztree>());
|
|
|
|
|
+ }
|
|
|
|
|
+ node.getChildren().add(findChild(n,list));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return node;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 对象转树
|
|
* 对象转树
|
|
|
* @param sysUserOrderAuthorList
|
|
* @param sysUserOrderAuthorList
|