调通了层级定义树和用户界面树的相关查询。

This commit is contained in:
chenxudong 2025-03-07 10:13:37 +08:00
parent 7f9d2cf3bf
commit 959433bbe7
8 changed files with 56 additions and 25 deletions

View File

@ -33,7 +33,7 @@ public class EdFileInfoController {
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.DATABASE)
@RequestMapping("tree")
public ElectromagneticResult<?> tree() {
return edFileInfoService.tree(PrjQuerySource.PRJ_INTERFACE.value);
return edFileInfoService.tree(PrjQuerySource.SYS_DB.value);
}
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.DATABASE)

View File

@ -49,7 +49,7 @@ public class ProjectController {
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.PRJ_SETTING)
@RequestMapping("queryAll")
public ElectromagneticResult<?> queryAll() {
return edPrjService.queryAllPrjInfo(PrjQuerySource.PRJ_INTERFACE.value);
return edPrjService.queryAllPrjInfo(PrjQuerySource.SYS_PRJ.value);
}
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.PRJ_SETTING)

View File

@ -34,7 +34,7 @@ public class UserEdFileInfoController {
@UserOperation(value = "查看工程树", modelName =UserOperationModuleEnum.USER_PRJ)
@RequestMapping("tree")
public ElectromagneticResult<?> tree() {
return edFileInfoService.tree(PrjQuerySource.USER_INTERFACE.value);
return edFileInfoService.tree(PrjQuerySource.USER_DB.value);
}
@UserOperation(value = "创建文件夹", modelName =UserOperationModuleEnum.USER_PRJ)

View File

@ -44,7 +44,7 @@ public class UserPrjController {
@UserOperation(value = "查询所有层级", modelName = UserOperationModuleEnum.USER_PRJ)
@RequestMapping("queryAll")
public ElectromagneticResult<?> queryAll() {
return edPrjService.queryAllPrjInfo(PrjQuerySource.USER_INTERFACE.value);
return edPrjService.queryAllPrjInfo(PrjQuerySource.USER_PRJ.value);
}
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.USER_PRJ)

View File

@ -205,7 +205,19 @@ public class CommonService {
}
/**
* 1.询管理员从层级定义处查2.用户从数据库管理界面查询
* @param querySource 0询管理员从层级定义处查 2.用户从数据库管理界面查询
* @param accessibleIds
* @param obj
* @return
*/
public Map<Integer, List<String>> querySysPrjTree(int querySource, List<String> accessibleIds, Object obj) {
/**
* querySource=SYS_PRJ从层级定义处查询 querySource=SYS_DB从数据库界面处查询
*/
Map<Integer, List<String>> map = new HashMap<>();
try {
// 首先查出所有的工程id
@ -214,8 +226,17 @@ public class CommonService {
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code)
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
// 如果不是数据库界面查询此处需要进行权限筛选
if (querySource == PrjQuerySource.USER_INTERFACE.value) {
if (querySource == PrjQuerySource.SYS_DB.value) {
queryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
.or()
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
} else {
queryWrapper.ne(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code);
}
// 如果是数据库界面查询此处需要进行权限筛选
if (querySource == PrjQuerySource.SYS_DB.value) {
queryWrapper.in(EdFileInfo::getId, accessibleIds);
}
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
@ -226,7 +247,7 @@ public class CommonService {
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
.likeRight(EdFileInfo::getFilePath, id);
if (querySource == PrjQuerySource.USER_INTERFACE.value) {
if (querySource == PrjQuerySource.SYS_DB.value) {
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
.or()
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
@ -267,7 +288,7 @@ public class CommonService {
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
.likeRight(EdFileInfo::getFilePath, id);
if (querySource == PrjQuerySource.USER_INTERFACE.value) {
if (querySource == PrjQuerySource.USER_DB.value) {
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
.or()
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
@ -408,15 +429,17 @@ public class CommonService {
public Set<String> selectPrjLeafs(int 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<>();
prjInfo.forEach(e -> {
FileProjectVO projectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
Set<String> leafIds = getLeafNodes(projectVO).stream().map(FileProjectVO::getCategoryId).collect(Collectors.toSet());
res.addAll(leafIds);
});
// 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);
//
// prjInfo.forEach(e -> {
// FileProjectVO projectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
// Set<String> leafIds = getLeafNodes(projectVO).stream().map(FileProjectVO::getCategoryId).collect(Collectors.toSet());
// res.addAll(leafIds);
// });
return res;
}

View File

@ -180,6 +180,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
}
/**
*
* 项目层级结构查询
*
* @return
@ -187,9 +188,13 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
@Override
public ElectromagneticResult<?> tree(int querySource) {
/**
* 都是从用户界面处进来一个是从数据库的用户界面SYS_DB一个是从用户自己的工程界面处USER_DB
*/
List<String> accessibleIds;
if (querySource == PrjQuerySource.PRJ_INTERFACE.value) {
if (querySource == PrjQuerySource.SYS_DB.value) {
accessibleIds = permissionService.getAccessibleTree();
if (CollUtil.isEmpty(accessibleIds)) {
return ElectromagneticResultUtil.success(new ArrayList<>());
@ -202,13 +207,10 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)).stream().map(EdFileInfo::getId).collect(Collectors.toList());
}
Map<Integer, List<String>> map = (querySource == PrjQuerySource.PRJ_INTERFACE.value) ?
Map<Integer, List<String>> map = (querySource == PrjQuerySource.SYS_DB.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<>();
strings.forEach(e -> {

View File

@ -231,7 +231,11 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
@Override
public ElectromagneticResult<?> queryAllPrjInfo(int querySource) {
Map<Integer, List<String>> map = (querySource == PrjQuerySource.PRJ_INTERFACE.value) ?
/**
* querySource=SYS_PRJ管理员从层级定义处查询 querySource=USER_PRJ用户从自定义层级结构处查询
*/
Map<Integer, List<String>> map = (querySource == PrjQuerySource.SYS_PRJ.value) ?
commonService.querySysPrjTree(querySource, null, new ProjectVO()) :
commonService.queryUserPrjTree(querySource, new ProjectVO());

View File

@ -5,8 +5,10 @@ import lombok.AllArgsConstructor;
@AllArgsConstructor
public enum PrjQuerySource {
PRJ_INTERFACE(0),
USER_INTERFACE(1);
SYS_PRJ(0),
SYS_DB(1),
USER_PRJ(2),
USER_DB(3);
public final int value;