资料中心显示根据当前树节点及子节点显示全部数据
This commit is contained in:
+18
-2
@@ -10,18 +10,21 @@ import com.adc.da.slrs.sarUser.dao.TsUserDao;
|
||||
import com.adc.da.slrs.sarUser.service.ITsUserService;
|
||||
import com.adc.da.slrs.tsRoleMeunData.entity.TsRoleMenuData;
|
||||
import com.adc.da.slrs.tsRoleMeunData.service.ITsRoleMenuDataService;
|
||||
import com.adc.da.slrs.zlTree.service.IZlTreeService;
|
||||
import com.adc.da.util.LoginUserUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.management.Query;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -44,6 +47,8 @@ public class FileMaterialServiceImpl extends ServiceImpl<FileMaterialDao, FileMa
|
||||
private ITsPositionService tsPositionService;
|
||||
@Autowired
|
||||
private ITsRoleMenuDataService iTsRoleMenuDataService;
|
||||
@Autowired
|
||||
private IZlTreeService zlTreeService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -70,11 +75,22 @@ public class FileMaterialServiceImpl extends ServiceImpl<FileMaterialDao, FileMa
|
||||
if(StringUtils.isEmpty(queryPage.getTreeId())) {
|
||||
queryPage.setTreeIdList(treeIdList);
|
||||
} else {
|
||||
// 查看菜单是否有数据权限
|
||||
if (!treeIdList.contains(queryPage.getTreeId())) {
|
||||
//通过当前treeId查询该节点及下级节点的全部数据
|
||||
List<String> treeIds = new ArrayList<>();
|
||||
zlTreeService.subordinateTreeNodes(treeIds, queryPage.getTreeId());
|
||||
if (ObjectUtils.isEmpty(treeIds)) {
|
||||
return null;
|
||||
}
|
||||
// 查看菜单是否有数据权限
|
||||
treeIds = treeIds.stream().filter(treeId -> treeIdList.contains(treeId)).collect(Collectors.toList());
|
||||
if (ObjectUtils.isEmpty(treeIds)) {
|
||||
return null;
|
||||
}
|
||||
queryPage.setTreeIdList(treeIds);
|
||||
}
|
||||
//dataType制空,不然节点重名会有bug
|
||||
queryPage.setDataType(null);
|
||||
queryPage.setTreeId(null);
|
||||
return fileMaterialDao.getFileMaterialPage(page,queryPage);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.adc.da.slrs.zlTree.entity.ZlTree;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -51,4 +52,6 @@ public interface IZlTreeService extends IService<ZlTree> {
|
||||
* @return
|
||||
*/
|
||||
ZlTree queryTree(String treeId);
|
||||
|
||||
void subordinateTreeNodes(List<String> treeIds,String parentTreeId);
|
||||
}
|
||||
|
||||
@@ -154,4 +154,23 @@ public class ZlTreeServiceImpl extends ServiceImpl<ZlTreeDao, ZlTree> implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据树的父节点查询所有子节点id
|
||||
*
|
||||
* @param parentTreeId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void subordinateTreeNodes(List<String> treeIds, String parentTreeId) {
|
||||
treeIds.add(parentTreeId);
|
||||
QueryWrapper<ZlTree> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("p_id", parentTreeId);
|
||||
List<ZlTree> list = list(queryWrapper);
|
||||
if (ObjectUtils.isNotEmpty(list)) {
|
||||
for (ZlTree zlTree : list) {
|
||||
subordinateTreeNodes(treeIds,zlTree.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user