fix(资料中心): 资料中心完善
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
package com.jero.common.util;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class StreamUtils {
|
||||||
|
|
||||||
|
private StreamUtils(){
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 按某个指定字段去重
|
||||||
|
*
|
||||||
|
* @param keyExtractor 需要去重的字段
|
||||||
|
* @return java.util.function.Predicate<T>
|
||||||
|
* @author 陈賝
|
||||||
|
* @date 2022/9/2 13:49
|
||||||
|
*/
|
||||||
|
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
||||||
|
Map<Object, Boolean> seen = new ConcurrentHashMap<>();
|
||||||
|
return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+13
-13
@@ -1,25 +1,25 @@
|
|||||||
package com.jero.modules.laws.dataCenter.controller;
|
package com.jero.modules.laws.dataCenter.controller;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
import com.jero.common.exception.JeroBootException;
|
|
||||||
import com.jero.common.util.MessageUtils;
|
|
||||||
import com.jero.common.api.vo.ResultCommon;
|
import com.jero.common.api.vo.ResultCommon;
|
||||||
|
import com.jero.common.aspect.annotation.AutoLog;
|
||||||
|
import com.jero.common.exception.JeroBootException;
|
||||||
|
import com.jero.common.system.base.controller.JeroController;
|
||||||
|
import com.jero.common.util.MessageUtils;
|
||||||
import com.jero.modules.laws.dataCenter.entity.LawsDataCenterFolder;
|
import com.jero.modules.laws.dataCenter.entity.LawsDataCenterFolder;
|
||||||
import com.jero.modules.laws.dataCenter.service.ILawsDataCenterFolderService;
|
import com.jero.modules.laws.dataCenter.service.ILawsDataCenterFolderService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.jero.common.system.base.controller.JeroController;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
import java.util.List;
|
||||||
import com.jero.common.aspect.annotation.AutoLog;
|
import java.util.Map;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,8 +39,8 @@ public class LawsDataCenterFolderController extends JeroController<LawsDataCente
|
|||||||
@AutoLog(value = "资料中心-文件夹-获取树型列表")
|
@AutoLog(value = "资料中心-文件夹-获取树型列表")
|
||||||
@ApiOperation(value = "资料中心-文件夹-获取树型列表", notes = "资料中心-文件夹-获取树型列表")
|
@ApiOperation(value = "资料中心-文件夹-获取树型列表", notes = "资料中心-文件夹-获取树型列表")
|
||||||
@GetMapping(value = "/getTreeList")
|
@GetMapping(value = "/getTreeList")
|
||||||
public Result<List<LawsDataCenterFolder>> getTreeList() {
|
public Result<List<LawsDataCenterFolder>> getTreeList(String folderName) {
|
||||||
List<LawsDataCenterFolder> treeList = lawsDataCenterFolderService.getTreeList();
|
List<LawsDataCenterFolder> treeList = lawsDataCenterFolderService.getTreeList(folderName);
|
||||||
return Result.OK(treeList);
|
return Result.OK(treeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
@@ -143,4 +143,9 @@ public class LawsDataCenterFolder implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private java.lang.String pId;
|
private java.lang.String pId;
|
||||||
|
/**
|
||||||
|
* 层级结构名 用于搜索过滤
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private java.lang.String structureName;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-4
@@ -1,10 +1,11 @@
|
|||||||
package com.jero.modules.laws.dataCenter.mapper;
|
package com.jero.modules.laws.dataCenter.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import com.jero.modules.laws.dataCenter.entity.LawsDataCenterFile;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.jero.modules.laws.dataCenter.entity.LawsDataCenterFile;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 资料中心-文件数据
|
* @Description: 资料中心-文件数据
|
||||||
@@ -14,4 +15,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
*/
|
*/
|
||||||
public interface LawsDataCenterFileMapper extends BaseMapper<LawsDataCenterFile> {
|
public interface LawsDataCenterFileMapper extends BaseMapper<LawsDataCenterFile> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param queryWrapper
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Page<LawsDataCenterFile> queryByPage(Page<LawsDataCenterFile> page, @Param(Constants.WRAPPER) QueryWrapper<LawsDataCenterFile> queryWrapper);
|
||||||
}
|
}
|
||||||
|
|||||||
+21
@@ -16,4 +16,25 @@
|
|||||||
<result column="folder_id" property="folderId" />
|
<result column="folder_id" property="folderId" />
|
||||||
<result column="owner_id" property="ownerId" />
|
<result column="owner_id" property="ownerId" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="queryByPage" resultType="com.jero.modules.laws.dataCenter.entity.LawsDataCenterFile">
|
||||||
|
SELECT *
|
||||||
|
FROM (SELECT id,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
org_code,
|
||||||
|
del_flag,
|
||||||
|
file_name,
|
||||||
|
file_id,
|
||||||
|
push_range_ids,
|
||||||
|
file_description,
|
||||||
|
folder_id,
|
||||||
|
owner_id,
|
||||||
|
uploader,
|
||||||
|
(SELECT auth_manage_ids FROM laws_data_center_folder d WHERE d.id = folder_id) auth_manage_ids
|
||||||
|
FROM laws_data_center_file) t
|
||||||
|
${ew.customSqlSegment}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
+3
-1
@@ -27,6 +27,8 @@
|
|||||||
FROM
|
FROM
|
||||||
laws_data_center_folder ldcf
|
laws_data_center_folder ldcf
|
||||||
WHERE del_flag = 0 AND (ldcf.owner_id = #{userId}
|
WHERE del_flag = 0 AND (ldcf.owner_id = #{userId}
|
||||||
OR ldcf.auth_view_ids LIKE CONCAT('%',#{userId},'%'))
|
OR ldcf.auth_view_ids LIKE CONCAT('%',#{userId},'%')
|
||||||
|
OR ldcf.auth_manage_ids LIKE CONCAT('%',#{userId},'%'))
|
||||||
|
order by ldcf.sort, ldcf.create_time
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
+1
-1
@@ -17,7 +17,7 @@ public interface ILawsDataCenterFolderService extends IService<LawsDataCenterFol
|
|||||||
* @Date: 2023/10/26 17:16
|
* @Date: 2023/10/26 17:16
|
||||||
* @Description: 获取树型列表
|
* @Description: 获取树型列表
|
||||||
**/
|
**/
|
||||||
List<LawsDataCenterFolder> getTreeList();
|
List<LawsDataCenterFolder> getTreeList(String folderName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
|
|||||||
+13
-17
@@ -1,6 +1,6 @@
|
|||||||
package com.jero.modules.laws.dataCenter.service.impl;
|
package com.jero.modules.laws.dataCenter.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -50,6 +50,8 @@ public class LawsDataCenterFileServiceImpl extends ServiceImpl<LawsDataCenterFil
|
|||||||
private IOSSFileService ossFileService;
|
private IOSSFileService ossFileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SendMessageAPI sendMessageAPI;
|
private SendMessageAPI sendMessageAPI;
|
||||||
|
@Autowired
|
||||||
|
private LawsDataCenterFileMapper lawsDataCenterFileMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
@@ -61,33 +63,27 @@ public class LawsDataCenterFileServiceImpl extends ServiceImpl<LawsDataCenterFil
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IPage<LawsDataCenterFile> queryPage(LawsDataCenterFile lawsDataCenterFile, Integer pageNo, Integer pageSize) {
|
public IPage<LawsDataCenterFile> queryPage(LawsDataCenterFile lawsDataCenterFile, Integer pageNo, Integer pageSize) {
|
||||||
LambdaQueryWrapper<LawsDataCenterFile> queryWrapper = new LambdaQueryWrapper<>();
|
QueryWrapper<LawsDataCenterFile> queryWrapper = new QueryWrapper<>();
|
||||||
Page<LawsDataCenterFile> page = new Page<>(pageNo, pageSize);
|
Page<LawsDataCenterFile> page = new Page<>(pageNo, pageSize);
|
||||||
queryWrapper.like(StringUtils.isNotBlank(lawsDataCenterFile.getFileName()),
|
queryWrapper.like(StringUtils.isNotBlank(lawsDataCenterFile.getFileName()),
|
||||||
LawsDataCenterFile::getFileName, lawsDataCenterFile.getFileName());
|
"file_name", lawsDataCenterFile.getFileName());
|
||||||
queryWrapper.like(StringUtils.isNotBlank(lawsDataCenterFile.getUploader()),
|
queryWrapper.like(StringUtils.isNotBlank(lawsDataCenterFile.getUploader()),
|
||||||
LawsDataCenterFile::getUploader, lawsDataCenterFile.getUploader());
|
"uploader", lawsDataCenterFile.getUploader());
|
||||||
if (StringUtils.isNotBlank(lawsDataCenterFile.getUploadTime())) {
|
if (StringUtils.isNotBlank(lawsDataCenterFile.getUploadTime())) {
|
||||||
String[] timeArr = lawsDataCenterFile.getUploadTime().split(",");
|
String[] timeArr = lawsDataCenterFile.getUploadTime().split(",");
|
||||||
queryWrapper.between(LawsDataCenterFile::getCreateTime,
|
queryWrapper.between("create_time",
|
||||||
DateUtil.getDateSecond(timeArr[0]), DateUtil.getDateSecond(timeArr[1]));
|
DateUtil.getDateSecond(timeArr[0]), DateUtil.getDateSecond(timeArr[1]));
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(lawsDataCenterFile.getFolderId())) {
|
queryWrapper.eq(StringUtils.isNotBlank(lawsDataCenterFile.getFolderId()), "folder_id", lawsDataCenterFile.getFolderId());
|
||||||
queryWrapper.and(qw -> qw
|
|
||||||
.isNull(LawsDataCenterFile::getFolderId).or()
|
|
||||||
.like(LawsDataCenterFile::getPushRangeIds, CurrentUserUtil.getId())
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
queryWrapper.eq(LawsDataCenterFile::getFolderId, lawsDataCenterFile.getFolderId());
|
|
||||||
}
|
|
||||||
if (!CurrentUserUtil.getRoles().contains(FieldCommon.ROLE_ADMIN)) {
|
if (!CurrentUserUtil.getRoles().contains(FieldCommon.ROLE_ADMIN)) {
|
||||||
queryWrapper.and(qw -> qw
|
queryWrapper.and(qw -> qw
|
||||||
.eq(LawsDataCenterFile::getOwnerId, CurrentUserUtil.getId()).or()
|
.eq("owner_id", CurrentUserUtil.getId()).or()
|
||||||
.like(LawsDataCenterFile::getPushRangeIds, CurrentUserUtil.getId())
|
.like("push_range_ids", CurrentUserUtil.getId())
|
||||||
|
.or().like("auth_manage_ids", CurrentUserUtil.getId())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
queryWrapper.orderByDesc(LawsDataCenterFile::getCreateTime);
|
queryWrapper.orderByDesc("create_time");
|
||||||
Page<LawsDataCenterFile> result = page(page, queryWrapper);
|
Page<LawsDataCenterFile> result = lawsDataCenterFileMapper.queryByPage(page, queryWrapper);
|
||||||
if (!CurrentUserUtil.getRoles().contains(FieldCommon.ROLE_ADMIN)){
|
if (!CurrentUserUtil.getRoles().contains(FieldCommon.ROLE_ADMIN)){
|
||||||
for (LawsDataCenterFile file : result.getRecords()) {
|
for (LawsDataCenterFile file : result.getRecords()) {
|
||||||
// 管理权限标识
|
// 管理权限标识
|
||||||
|
|||||||
+66
-40
@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.jero.common.api.vo.ResultCommon;
|
import com.jero.common.api.vo.ResultCommon;
|
||||||
import com.jero.common.exception.JeroBootException;
|
import com.jero.common.exception.JeroBootException;
|
||||||
import com.jero.modules.laws.common.constant.FieldCommon;
|
import com.jero.common.system.vo.LoginUser;
|
||||||
|
import com.jero.common.util.BeanCopyUtils;
|
||||||
|
import com.jero.common.util.StreamUtils;
|
||||||
import com.jero.modules.laws.common.util.CurrentUserUtil;
|
import com.jero.modules.laws.common.util.CurrentUserUtil;
|
||||||
import com.jero.modules.laws.common.util.TreeNodeComparator;
|
import com.jero.modules.laws.common.util.TreeNodeComparator;
|
||||||
import com.jero.modules.laws.dataCenter.entity.LawsDataCenterFile;
|
import com.jero.modules.laws.dataCenter.entity.LawsDataCenterFile;
|
||||||
@@ -14,14 +16,15 @@ import com.jero.modules.laws.dataCenter.mapper.LawsDataCenterFolderMapper;
|
|||||||
import com.jero.modules.laws.dataCenter.service.ILawsDataCenterFileService;
|
import com.jero.modules.laws.dataCenter.service.ILawsDataCenterFileService;
|
||||||
import com.jero.modules.laws.dataCenter.service.ILawsDataCenterFolderService;
|
import com.jero.modules.laws.dataCenter.service.ILawsDataCenterFolderService;
|
||||||
import com.jero.modules.system.service.ISysUserService;
|
import com.jero.modules.system.service.ISysUserService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -35,6 +38,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Transactional(rollbackFor = JeroBootException.class)
|
@Transactional(rollbackFor = JeroBootException.class)
|
||||||
|
@Slf4j
|
||||||
public class LawsDataCenterFolderServiceImpl extends ServiceImpl<LawsDataCenterFolderMapper, LawsDataCenterFolder> implements ILawsDataCenterFolderService {
|
public class LawsDataCenterFolderServiceImpl extends ServiceImpl<LawsDataCenterFolderMapper, LawsDataCenterFolder> implements ILawsDataCenterFolderService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -43,54 +47,76 @@ public class LawsDataCenterFolderServiceImpl extends ServiceImpl<LawsDataCenterF
|
|||||||
private ILawsDataCenterFileService lawsDataCenterFileService;
|
private ILawsDataCenterFileService lawsDataCenterFileService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService sysUserService;
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: liao
|
* @Author: liao
|
||||||
* @Date: 2023/10/26 17:17
|
* @Date: 2023/10/26 17:17
|
||||||
* @Description: 获取树型列表
|
* @Description: 获取树型列表
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public List<LawsDataCenterFolder> getTreeList() {
|
public List<LawsDataCenterFolder> getTreeList(String folderName) {
|
||||||
// 获取全部文件夹集合
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
List<LawsDataCenterFolder> folders = list();
|
String roleIds = loginUser.getRoleIds();
|
||||||
// 翻译
|
// 全部数据
|
||||||
folders.forEach(root -> {
|
List<LawsDataCenterFolder> lawsDataCenterFolderList = list(new LambdaQueryWrapper<LawsDataCenterFolder>()
|
||||||
root.setAuthManageIdsDictText(sysUserService.dictByIdsOrUserNames(root.getAuthManageIds(), ""));
|
.orderByAsc(LawsDataCenterFolder::getSort).orderByAsc(LawsDataCenterFolder::getCreateTime));
|
||||||
root.setAuthViewIdsDictText(sysUserService.dictByIdsOrUserNames(root.getAuthViewIds(), ""));
|
List<LawsDataCenterFolder> allList = BeanCopyUtils.copyBeanList(lawsDataCenterFolderList, LawsDataCenterFolder.class);
|
||||||
});
|
|
||||||
|
|
||||||
// 创建节点映射,方便查找节点
|
// 非管理员只能看到自己创建的 or 拥有管理权限 or 拥有查看权限的文件夹
|
||||||
Map<String, LawsDataCenterFolder> nodeMap = new HashMap<>();
|
if (!roleIds.contains("admin")){
|
||||||
folders.forEach(node -> {
|
lawsDataCenterFolderList = lawsDataCenterFolderList.stream()
|
||||||
node.setPId(node.getParentId());
|
.filter(v -> (StringUtils.isNotBlank(v.getAuthManageIds()) && v.getAuthManageIds().contains(loginUser.getId()))
|
||||||
nodeMap.put(node.getId(), node);
|
|| (StringUtils.isNotBlank(v.getAuthViewIds()) && v.getAuthViewIds().contains(loginUser.getId()))
|
||||||
});
|
|| v.getOwnerId().equals(loginUser.getId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
// 非管理员角色只能查看自己拥有权限的文件夹
|
|
||||||
if (!CurrentUserUtil.getRoles().contains(FieldCommon.ROLE_ADMIN)) {
|
|
||||||
// 获取自己拥有权限的文件夹集合
|
|
||||||
List<LawsDataCenterFolder> myFolders = lawsDataCenterFolderMapper.getMyFolderList(CurrentUserUtil.getId());
|
|
||||||
|
|
||||||
Map<String, LawsDataCenterFolder> myNodeMap = new HashMap<>();
|
|
||||||
myFolders.forEach(node -> {
|
|
||||||
node.setPId(node.getParentId());
|
|
||||||
myNodeMap.put(node.getId(), node);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 如果有子级没有父级,则将子级挂在父级的父级上
|
|
||||||
myFolders.forEach(node -> buildParent(node, nodeMap, myNodeMap));
|
|
||||||
folders = myFolders;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建根节点列表
|
// 搜索
|
||||||
List<LawsDataCenterFolder> roots = folders.stream().filter(folder ->
|
if (StringUtils.isNotBlank(folderName)) {
|
||||||
"0".equals(folder.getParentId())).collect(Collectors.toList());
|
// 过滤搜索数据
|
||||||
|
lawsDataCenterFolderList = lawsDataCenterFolderList.stream().filter(v -> v.getFolderName().contains(folderName)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
// 对根节点进行排序
|
// 翻译
|
||||||
roots.sort(new TreeNodeComparator());
|
for (LawsDataCenterFolder lawsDataCenterFolder : lawsDataCenterFolderList) {
|
||||||
|
lawsDataCenterFolder.setAuthManageIdsDictText(sysUserService.dictByIdsOrUserNames(lawsDataCenterFolder.getAuthManageIds(), ""));
|
||||||
|
lawsDataCenterFolder.setAuthViewIdsDictText(sysUserService.dictByIdsOrUserNames(lawsDataCenterFolder.getAuthViewIds(), ""));
|
||||||
|
}
|
||||||
|
|
||||||
// 递归构建子节点
|
// 寻找每个子级的父节点直到最上级
|
||||||
roots.forEach(root -> buildChildren(root, nodeMap));
|
List<LawsDataCenterFolder> fatherNodeList = new ArrayList<>();
|
||||||
return roots;
|
findFatherNode(lawsDataCenterFolderList, allList, fatherNodeList);
|
||||||
|
lawsDataCenterFolderList.addAll(fatherNodeList);
|
||||||
|
// 过滤重复数据
|
||||||
|
lawsDataCenterFolderList = lawsDataCenterFolderList.stream().filter(StreamUtils.distinctByKey(LawsDataCenterFolder::getId)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 构建树结构
|
||||||
|
List<LawsDataCenterFolder> finalLawsDataCenterFolderList = lawsDataCenterFolderList;
|
||||||
|
return lawsDataCenterFolderList.stream().filter(v -> "0".equals(v.getParentId()))
|
||||||
|
.map(v -> v.setChildren(createChildrenList(v, finalLawsDataCenterFolderList)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void findFatherNode(List<LawsDataCenterFolder> lawsDataCenterFolderList, List<LawsDataCenterFolder> allList, List<LawsDataCenterFolder> fatherNodeList) {
|
||||||
|
for (LawsDataCenterFolder lawsDataCenterFolder : lawsDataCenterFolderList) {
|
||||||
|
String parentId = lawsDataCenterFolder.getParentId();
|
||||||
|
if ("0".equals(parentId)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<LawsDataCenterFolder> list = allList.stream().filter(v -> v.getId().equals(parentId)).collect(Collectors.toList());
|
||||||
|
// 没被添加过
|
||||||
|
boolean b = list.stream().noneMatch(v -> v.equals(lawsDataCenterFolder));
|
||||||
|
if (!list.isEmpty() && b){
|
||||||
|
fatherNodeList.add(list.get(0));
|
||||||
|
findFatherNode(list, allList, fatherNodeList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LawsDataCenterFolder> createChildrenList(LawsDataCenterFolder treeList, List<LawsDataCenterFolder> lawsDataCenterFolderList) {
|
||||||
|
return lawsDataCenterFolderList.stream().filter(children -> treeList.getId().equals(children.getParentId()))
|
||||||
|
.map(folder -> folder.setChildren(createChildrenList(folder, lawsDataCenterFolderList)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,7 +179,7 @@ public class LawsDataCenterFolderServiceImpl extends ServiceImpl<LawsDataCenterF
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void editById(LawsDataCenterFolder lawsDataCenterFolder) {
|
public void editById(LawsDataCenterFolder lawsDataCenterFolder) {
|
||||||
saveOrUpdate(lawsDataCenterFolder);
|
saveOrUpdate(lawsDataCenterFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user