调通了层级树查询。
This commit is contained in:
parent
f51f76fa6d
commit
53f61ba8f8
|
|
@ -4,6 +4,7 @@ import com.electromagnetic.industry.software.common.annotations.RequiredPermissi
|
||||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||||
import com.electromagnetic.industry.software.common.enums.FilePermission;
|
import com.electromagnetic.industry.software.common.enums.FilePermission;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.PrjQuerySource;
|
||||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||||
|
|
@ -12,7 +13,6 @@ import com.electromagnetic.industry.software.manage.pojo.req.CreateFolderDTO;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
||||||
import com.electromagnetic.industry.software.manage.service.EdFileFavoriteService;
|
|
||||||
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||||
import org.springframework.core.io.InputStreamResource;
|
import org.springframework.core.io.InputStreamResource;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
@ -29,13 +29,11 @@ public class EdFileInfoController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EdFileInfoService edFileInfoService;
|
private EdFileInfoService edFileInfoService;
|
||||||
@Resource
|
|
||||||
private EdFileFavoriteService edFileFavoriteService;
|
|
||||||
|
|
||||||
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequestMapping("tree")
|
@RequestMapping("tree")
|
||||||
public ElectromagneticResult<?> tree() {
|
public ElectromagneticResult<?> tree() {
|
||||||
return edFileInfoService.tree(DataOwnEnum.SYS_PRJ.code);
|
return edFileInfoService.tree(PrjQuerySource.PRJ_INTERFACE.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.controller;
|
||||||
|
|
||||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.PrjQuerySource;
|
||||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||||
|
|
@ -48,7 +49,7 @@ public class ProjectController {
|
||||||
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||||
@RequestMapping("queryAll")
|
@RequestMapping("queryAll")
|
||||||
public ElectromagneticResult<?> queryAll() {
|
public ElectromagneticResult<?> queryAll() {
|
||||||
return edPrjService.queryAllPrjInfo(DataOwnEnum.SYS_PRJ.code);
|
return edPrjService.queryAllPrjInfo(PrjQuerySource.PRJ_INTERFACE.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.controller;
|
||||||
|
|
||||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.PrjQuerySource;
|
||||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||||
|
|
@ -33,7 +34,7 @@ public class UserEdFileInfoController {
|
||||||
@UserOperation(value = "查看工程树", modelName =UserOperationModuleEnum.USER_PRJ)
|
@UserOperation(value = "查看工程树", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||||
@RequestMapping("tree")
|
@RequestMapping("tree")
|
||||||
public ElectromagneticResult<?> tree() {
|
public ElectromagneticResult<?> tree() {
|
||||||
return edFileInfoService.tree(DataOwnEnum.USER_FILE.code);
|
return edFileInfoService.tree(PrjQuerySource.USER_INTERFACE.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "创建文件夹", modelName =UserOperationModuleEnum.USER_PRJ)
|
@UserOperation(value = "创建文件夹", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.controller;
|
||||||
|
|
||||||
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
import com.electromagnetic.industry.software.common.annotations.UserOperation;
|
||||||
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
import com.electromagnetic.industry.software.common.enums.DataOwnEnum;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.PrjQuerySource;
|
||||||
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
||||||
|
|
@ -43,7 +44,7 @@ public class UserPrjController {
|
||||||
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.USER_PRJ)
|
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||||
@RequestMapping("queryAll")
|
@RequestMapping("queryAll")
|
||||||
public ElectromagneticResult<?> queryAll() {
|
public ElectromagneticResult<?> queryAll() {
|
||||||
return edPrjService.queryAllPrjInfo(DataOwnEnum.USER_PRJ.code);
|
return edPrjService.queryAllPrjInfo(PrjQuerySource.USER_INTERFACE.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.USER_PRJ)
|
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ public interface EdFileInfoService {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ElectromagneticResult<?> tree(int dataOwnCode);
|
ElectromagneticResult<?> tree(int querySource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除目录
|
* 删除目录
|
||||||
|
|
|
||||||
|
|
@ -204,42 +204,95 @@ public class CommonService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> queryAllPrjInfo(List<String> prjIds, int dataOwnCode) {
|
|
||||||
|
|
||||||
|
public Map<Integer, List<String>> querySysPrjTree(int querySource, List<String> accessibleIds, Object obj) {
|
||||||
|
Map<Integer, List<String>> map = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
|
// 首先查出所有的工程id
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo::getId)
|
.select(EdFileInfo::getId)
|
||||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
|
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
|
||||||
|
// 如果不是数据库界面查询,此处需要进行权限筛选
|
||||||
if (dataOwnCode == DataOwnEnum.SYS_FILE.code) {
|
if (querySource == PrjQuerySource.USER_INTERFACE.value) {
|
||||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code);
|
queryWrapper.in(EdFileInfo::getId, accessibleIds);
|
||||||
} else if (dataOwnCode == DataOwnEnum.USER_FILE.code) {
|
|
||||||
queryWrapper.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code);
|
|
||||||
queryWrapper.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId());
|
|
||||||
}
|
}
|
||||||
|
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
if (DataOwnEnum.isPrjCode(dataOwnCode)) {
|
for (String id : prjIds) {
|
||||||
queryWrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code);
|
LambdaQueryWrapper<EdFileInfo> prjQueryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
if (CollUtil.isNotEmpty(prjIds)) {
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
queryWrapper.in(EdFileInfo::getId, prjIds);
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||||
}
|
.likeRight(EdFileInfo::getFilePath, id);
|
||||||
}
|
|
||||||
List<String> ids = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
|
||||||
List<String> projectVOS = new ArrayList<>();
|
|
||||||
|
|
||||||
for (String id : ids) {
|
if (querySource == PrjQuerySource.USER_INTERFACE.value) {
|
||||||
List<EdFileInfo> edFileInfos = selectAllAdminFolder(id, prjIds, dataOwnCode);
|
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
if (DataOwnEnum.isPrjCode(dataOwnCode)) {
|
.or()
|
||||||
edFileInfos = edFileInfos.stream().filter(e -> e.getDataStatus().equals(EleDataStatusEnum.PUBLISHED.code)
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
|
||||||
|| e.getDataStatus().equals(EleDataStatusEnum.DELETED.code))
|
prjQueryWrapper.in(EdFileInfo::getId, accessibleIds);
|
||||||
.collect(Collectors.toList());
|
|
||||||
} else {
|
} else {
|
||||||
edFileInfos = edFileInfos.stream().filter(e -> !e.getDataStatus().equals(EleDataStatusEnum.DELETED.code)).collect(Collectors.toList());
|
prjQueryWrapper.ne(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code);
|
||||||
}
|
}
|
||||||
// 转换为树
|
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(prjQueryWrapper);
|
||||||
if (DataOwnEnum.isPrjCode(dataOwnCode)) {
|
String jsonTree = createTree(edFileInfos, obj);
|
||||||
|
List<String> list = map.getOrDefault(querySource, new ArrayList<>());
|
||||||
|
list.add(jsonTree);
|
||||||
|
map.put(querySource, list);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
String info = "查询系统层级信息失败";
|
||||||
|
log.error(info, e);
|
||||||
|
throw new BizException(info);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, List<String>> queryUserPrjTree(int querySource, Object object) {
|
||||||
|
|
||||||
|
Map<Integer, List<String>> map = new HashMap<>();
|
||||||
|
try {
|
||||||
|
// 首先查出所有的工程id
|
||||||
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
|
.select(EdFileInfo::getId)
|
||||||
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
|
.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId())
|
||||||
|
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
|
||||||
|
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (String id : prjIds) {
|
||||||
|
LambdaQueryWrapper<EdFileInfo> prjQueryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
|
.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code)
|
||||||
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||||
|
.likeRight(EdFileInfo::getFilePath, id);
|
||||||
|
|
||||||
|
if (querySource == PrjQuerySource.USER_INTERFACE.value) {
|
||||||
|
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
|
.or()
|
||||||
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
|
||||||
|
} else {
|
||||||
|
prjQueryWrapper.ne(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(prjQueryWrapper);
|
||||||
|
String jsonTree = createTree(edFileInfos, object);
|
||||||
|
List<String> list = map.getOrDefault(querySource, new ArrayList<>());
|
||||||
|
list.add(jsonTree);
|
||||||
|
map.put(querySource, list);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
String info = "查询用户层级信息失败";
|
||||||
|
log.error(info, e);
|
||||||
|
throw new BizException(info);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String createTree(List<EdFileInfo> edFileInfos, Object object) {
|
||||||
|
|
||||||
TreeNodeConfig config = new TreeNodeConfig();
|
TreeNodeConfig config = new TreeNodeConfig();
|
||||||
|
if (object instanceof ProjectVO) {
|
||||||
|
// 转换为树
|
||||||
config.setIdKey(EdFileInfo.Fields.id);
|
config.setIdKey(EdFileInfo.Fields.id);
|
||||||
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
||||||
config.setWeightKey(EdFileInfo.Fields.sort);
|
config.setWeightKey(EdFileInfo.Fields.sort);
|
||||||
|
|
@ -251,32 +304,24 @@ public class CommonService {
|
||||||
treeNode.putExtra(ProjectVO.Fields.title, obj.getFileName());
|
treeNode.putExtra(ProjectVO.Fields.title, obj.getFileName());
|
||||||
treeNode.putExtra(ProjectVO.Fields.dataStatus, obj.getDataStatus());
|
treeNode.putExtra(ProjectVO.Fields.dataStatus, obj.getDataStatus());
|
||||||
}));
|
}));
|
||||||
String jsonStr = JSONUtil.toJsonStr(trees);
|
return JSONUtil.toJsonStr(trees);
|
||||||
projectVOS.add(jsonStr);
|
}
|
||||||
} else {
|
|
||||||
TreeNodeConfig config = new TreeNodeConfig();
|
|
||||||
config.setIdKey(FileProjectVO.Fields.categoryId);
|
config.setIdKey(FileProjectVO.Fields.categoryId);
|
||||||
config.setParentIdKey(FileProjectVO.Fields.parentId);
|
config.setParentIdKey(FileProjectVO.Fields.parentId);
|
||||||
config.setWeightKey(FileProjectVO.Fields.sort);
|
config.setWeightKey(FileProjectVO.Fields.sort);
|
||||||
List<Tree<String>> trees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
|
List<Tree<String>> fileTrees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
|
||||||
treeNode.putExtra(FileProjectVO.Fields.categoryId, obj.getId());
|
treeNode.putExtra(FileProjectVO.Fields.categoryId, obj.getId());
|
||||||
treeNode.putExtra(FileProjectVO.Fields.parentId, obj.getParentId());
|
treeNode.putExtra(FileProjectVO.Fields.parentId, obj.getParentId());
|
||||||
treeNode.putExtra(FileProjectVO.Fields.sort, obj.getSort());
|
treeNode.putExtra(FileProjectVO.Fields.sort, obj.getSort());
|
||||||
treeNode.putExtra(FileProjectVO.Fields.categoryName, obj.getFileName());
|
treeNode.putExtra(FileProjectVO.Fields.categoryName, obj.getFileName());
|
||||||
treeNode.putExtra(FileProjectVO.Fields.dataStatus, obj.getDataStatus());
|
treeNode.putExtra(FileProjectVO.Fields.dataStatus, obj.getDataStatus());
|
||||||
}));
|
}));
|
||||||
String jsonStr = JSONUtil.toJsonStr(trees);
|
return JSONUtil.toJsonStr(fileTrees);
|
||||||
projectVOS.add(jsonStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return projectVOS;
|
|
||||||
} catch (Exception e) {
|
|
||||||
String info = "查询项目失败";
|
|
||||||
log.error(info, e);
|
|
||||||
throw new BizException(info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ElectromagneticResult<?> deleteFolder(String id, int dataOwnCode) {
|
public ElectromagneticResult<?> deleteFolder(String id, int dataOwnCode) {
|
||||||
// 如果文件夹下存在文件(包括文件夹和已经逻辑删除的文件),则不允许删除。后面管理员选择会有物理删除文件夹和文件的功能,此时MySQL和文件系统则会进行物理删除该文件。
|
// 如果文件夹下存在文件(包括文件夹和已经逻辑删除的文件),则不允许删除。后面管理员选择会有物理删除文件夹和文件的功能,此时MySQL和文件系统则会进行物理删除该文件。
|
||||||
EdFileInfo srcFileInfo = edFileInfoMapper.selectById(id);
|
EdFileInfo srcFileInfo = edFileInfoMapper.selectById(id);
|
||||||
|
|
@ -300,12 +345,12 @@ public class CommonService {
|
||||||
edFileInfoMapper.update(new EdFileInfo(), Wrappers.<EdFileInfo>lambdaUpdate()
|
edFileInfoMapper.update(new EdFileInfo(), Wrappers.<EdFileInfo>lambdaUpdate()
|
||||||
.like(EdFileInfo::getFilePath, id)
|
.like(EdFileInfo::getFilePath, id)
|
||||||
.set(EdFileInfo::getSort, -1)
|
.set(EdFileInfo::getSort, -1)
|
||||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code));
|
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code));
|
||||||
// 层级文件夹重排序
|
// 层级文件夹重排序
|
||||||
List<EdFileInfo> edFileInfos1 = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
List<EdFileInfo> edFileInfos1 = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo::getId, EdFileInfo::getSort)
|
.select(EdFileInfo::getId, EdFileInfo::getSort)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.ne(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)
|
.ne(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
.eq(EdFileInfo::getParentId, parentId)
|
.eq(EdFileInfo::getParentId, parentId)
|
||||||
.orderByAsc(EdFileInfo::getSort));
|
.orderByAsc(EdFileInfo::getSort));
|
||||||
|
|
||||||
|
|
@ -361,18 +406,21 @@ public class CommonService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> selectPrjLeafs(int dataOwnCode) {
|
public Set<String> selectPrjLeafs(int dataOwnCode) {
|
||||||
List<String> prjInfo = queryAllPrjInfo( null, dataOwnCode);
|
|
||||||
|
List<String> prjInfo = (dataOwnCode == DataOwnEnum.SYS_FILE.code) ?
|
||||||
|
querySysPrjTree(PrjQuerySource.USER_INTERFACE.value, null, new FileProjectVO()).get(PrjQuerySource.USER_INTERFACE.value):
|
||||||
|
queryUserPrjTree(PrjQuerySource.USER_INTERFACE.value, new FileProjectVO()).get(PrjQuerySource.USER_INTERFACE.value);
|
||||||
Set<String> res = new HashSet<>();
|
Set<String> res = new HashSet<>();
|
||||||
prjInfo.forEach(e -> {
|
prjInfo.forEach(e -> {
|
||||||
ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0);
|
FileProjectVO projectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
|
||||||
Set<String> leafIds = getLeafNodes(projectVO).stream().map(ProjectVO::getId).collect(Collectors.toSet());
|
Set<String> leafIds = getLeafNodes(projectVO).stream().map(FileProjectVO::getCategoryId).collect(Collectors.toSet());
|
||||||
res.addAll(leafIds);
|
res.addAll(leafIds);
|
||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ProjectVO> getLeafNodes(ProjectVO root) {
|
private static List<FileProjectVO> getLeafNodes(FileProjectVO root) {
|
||||||
List<ProjectVO> leafNodes = new ArrayList<>();
|
List<FileProjectVO> leafNodes = new ArrayList<>();
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
return leafNodes;
|
return leafNodes;
|
||||||
}
|
}
|
||||||
|
|
@ -380,11 +428,11 @@ public class CommonService {
|
||||||
return leafNodes;
|
return leafNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void findLeafNodes(ProjectVO node, List<ProjectVO> leafNodes) {
|
private static void findLeafNodes(FileProjectVO node, List<FileProjectVO> leafNodes) {
|
||||||
if (node.getChildren().isEmpty()) {
|
if (node.getChildren().isEmpty()) {
|
||||||
leafNodes.add(node);
|
leafNodes.add(node);
|
||||||
} else {
|
} else {
|
||||||
for (ProjectVO child : node.getChildren()) {
|
for (FileProjectVO child : node.getChildren()) {
|
||||||
findLeafNodes(child, leafNodes);
|
findLeafNodes(child, leafNodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
|
|
||||||
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.NOT_PUBLISHED.code), EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
|
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.NOT_PUBLISHED.code), EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||||
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.PUBLISHED.code), EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.PUBLISHED.code), EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
||||||
.eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.OCCUPY.code), EdFileInfo::getDataStatus, EleDataStatusEnum.OCCUPY.code)
|
// .eq(ObjUtil.equals(pars.getDataStatus(), EleDataStatusEnum.OCCUPY.code), EdFileInfo::getDataStatus, EleDataStatusEnum.OCCUPY.code)
|
||||||
|
|
||||||
.eq(StrUtil.isNotEmpty(pars.getFileType()), EdFileInfo::getFileType, pars.getFileType())
|
.eq(StrUtil.isNotEmpty(pars.getFileType()), EdFileInfo::getFileType, pars.getFileType())
|
||||||
.orderByAsc(ObjUtil.equals(pars.getCreatedTime(), 0), EdFileInfo::getCreatedTime)
|
.orderByAsc(ObjUtil.equals(pars.getCreatedTime(), 0), EdFileInfo::getCreatedTime)
|
||||||
|
|
@ -185,24 +185,31 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> tree(int dataOwnCode) {
|
public ElectromagneticResult<?> tree(int querySource) {
|
||||||
|
|
||||||
List<String> prjIds;
|
List<String> accessibleIds;
|
||||||
|
|
||||||
if (dataOwnCode != DataOwnEnum.USER_FILE.code) {
|
if (querySource == PrjQuerySource.PRJ_INTERFACE.value) {
|
||||||
prjIds = permissionService.getAccessibleTree();
|
accessibleIds = permissionService.getAccessibleTree();
|
||||||
if (CollUtil.isEmpty(prjIds) && dataOwnCode != DataOwnEnum.USER_FILE.code ) {
|
if (CollUtil.isEmpty(accessibleIds)) {
|
||||||
return ElectromagneticResultUtil.success(new ArrayList<>());
|
return ElectromagneticResultUtil.success(new ArrayList<>());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prjIds = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
accessibleIds = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code)
|
.eq(EdFileInfo::getDataOwn, DataOwnEnum.USER_PRJ.code)
|
||||||
.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId())
|
.eq(EdFileInfo::getCreatedBy, UserThreadLocal.getUserId())
|
||||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> strings = commonService.queryAllPrjInfo(prjIds, dataOwnCode);
|
Map<Integer, List<String>> map = (querySource == PrjQuerySource.PRJ_INTERFACE.value) ?
|
||||||
|
commonService.querySysPrjTree(querySource, accessibleIds, new FileProjectVO()) :
|
||||||
|
commonService.queryUserPrjTree(querySource, new FileProjectVO());
|
||||||
|
log.info("#################################################");
|
||||||
|
log.info("map is {}", JSONUtil.toJsonStr(map));
|
||||||
|
log.info("accessible ids is {}", accessibleIds);
|
||||||
|
log.info("#################################################");
|
||||||
|
List<String> strings = map.getOrDefault(querySource, new ArrayList<>());
|
||||||
List<FileProjectVO> res = new ArrayList<>();
|
List<FileProjectVO> res = new ArrayList<>();
|
||||||
strings.forEach(e -> {
|
strings.forEach(e -> {
|
||||||
FileProjectVO fileProjectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
|
FileProjectVO fileProjectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
|
||||||
|
|
@ -211,6 +218,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
res.sort(Comparator.comparing(FileProjectVO::getSort));
|
res.sort(Comparator.comparing(FileProjectVO::getSort));
|
||||||
UserThreadLocal.setSuccessInfo("", "", "查询项目层级结构成功");
|
UserThreadLocal.setSuccessInfo("", "", "查询项目层级结构成功");
|
||||||
return ElectromagneticResultUtil.success(res);
|
return ElectromagneticResultUtil.success(res);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -229,8 +229,13 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> queryAllPrjInfo(int dataOwnCode) {
|
public ElectromagneticResult<?> queryAllPrjInfo(int querySource) {
|
||||||
List<String> res = commonService.queryAllPrjInfo(null, dataOwnCode);
|
|
||||||
|
Map<Integer, List<String>> map = (querySource == PrjQuerySource.PRJ_INTERFACE.value) ?
|
||||||
|
commonService.querySysPrjTree(querySource, null, new ProjectVO()) :
|
||||||
|
commonService.queryUserPrjTree(querySource, new ProjectVO());
|
||||||
|
|
||||||
|
List<String> res = map.getOrDefault(querySource, new ArrayList<>());
|
||||||
List<ProjectVO> projectVOS = new ArrayList<>();
|
List<ProjectVO> projectVOS = new ArrayList<>();
|
||||||
res.forEach(e -> {
|
res.forEach(e -> {
|
||||||
ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0);
|
ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0);
|
||||||
|
|
@ -282,7 +287,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
// 将已经处于删除状态设置成逻辑删除
|
// 将已经处于删除状态设置成逻辑删除
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
|
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
|
||||||
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
.likeRight(EdFileInfo::getFilePath, prjId);
|
.likeRight(EdFileInfo::getFilePath, prjId);
|
||||||
List<String> paths = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getFilePath).collect(Collectors.toList());
|
List<String> paths = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getFilePath).collect(Collectors.toList());
|
||||||
List<String> fileSysPaths = new ArrayList<>();
|
List<String> fileSysPaths = new ArrayList<>();
|
||||||
|
|
@ -292,7 +297,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
});
|
});
|
||||||
|
|
||||||
this.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
|
this.update(new EdFileInfo(), Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||||
.likeRight(EdFileInfo::getFilePath, prjId));
|
.likeRight(EdFileInfo::getFilePath, prjId));
|
||||||
// 其余置为发布状态
|
// 其余置为发布状态
|
||||||
|
|
@ -462,7 +467,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
.and(qr -> qr
|
.and(qr -> qr
|
||||||
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||||
.or()
|
.or()
|
||||||
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)));
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)));
|
||||||
Set<String> unpublishFiles = new HashSet<>();
|
Set<String> unpublishFiles = new HashSet<>();
|
||||||
for (EdFileInfo edFileInfo : edFileInfos) {
|
for (EdFileInfo edFileInfo : edFileInfos) {
|
||||||
String filePath = edFileInfo.getFilePath();
|
String filePath = edFileInfo.getFilePath();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||||
|
|
||||||
import cn.hutool.core.text.StrFormatter;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.electromagnetic.industry.software.common.enums.*;
|
import com.electromagnetic.industry.software.common.enums.*;
|
||||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||||
|
|
@ -189,7 +188,7 @@ public class PermissionServiceImpl implements PermissionService {
|
||||||
|
|
||||||
// 获取当前项目所有已逻辑删除的节点,删除其权限
|
// 获取当前项目所有已逻辑删除的节点,删除其权限
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)
|
queryWrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
|
||||||
.likeRight(EdFileInfo::getFilePath, prjId);
|
.likeRight(EdFileInfo::getFilePath, prjId);
|
||||||
List<String> deletedIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
List<String> deletedIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
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;
|
||||||
import com.electromagnetic.industry.software.common.enums.*;
|
import com.electromagnetic.industry.software.common.enums.*;
|
||||||
import com.electromagnetic.industry.software.common.util.EleLog;
|
|
||||||
import com.electromagnetic.industry.software.common.util.IdWorker;
|
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||||
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||||
|
|
@ -376,7 +375,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||||
.eq(EdFileInfo::getDataOwn, dataOwnCode)
|
.eq(EdFileInfo::getDataOwn, dataOwnCode)
|
||||||
.and(wrapper -> wrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
.and(wrapper -> wrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
||||||
.or()
|
.or()
|
||||||
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)));
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ public enum DataOwnEnum {
|
||||||
REPO_FILE(3, "库文件"),
|
REPO_FILE(3, "库文件"),
|
||||||
REPO_PRJ(5, "库工程");
|
REPO_PRJ(5, "库工程");
|
||||||
|
|
||||||
public int code;
|
public final int code;
|
||||||
public String desc;
|
public final String desc;
|
||||||
|
|
||||||
|
|
||||||
public static boolean isPrjCode(int code) {
|
public static boolean isPrjCode(int code) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ public enum EleDataStatusEnum {
|
||||||
NOT_PUBLISHED(0, "未发布"),
|
NOT_PUBLISHED(0, "未发布"),
|
||||||
PUBLISHED(1, "已发布"),
|
PUBLISHED(1, "已发布"),
|
||||||
OCCUPY(2, "占用"),
|
OCCUPY(2, "占用"),
|
||||||
DELETED(3, "待删除");
|
WAIT_DELETED(3, "待删除");
|
||||||
|
|
||||||
public final int code;
|
public final int code;
|
||||||
public final String desc;
|
public final String desc;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.electromagnetic.industry.software.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum PrjQuerySource {
|
||||||
|
|
||||||
|
PRJ_INTERFACE(0),
|
||||||
|
USER_INTERFACE(1);
|
||||||
|
|
||||||
|
public final int value;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue