调通了层级定义树和用户界面树的相关查询。
This commit is contained in:
parent
7f9d2cf3bf
commit
959433bbe7
|
|
@ -33,7 +33,7 @@ public class EdFileInfoController {
|
||||||
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
@RequestMapping("tree")
|
@RequestMapping("tree")
|
||||||
public ElectromagneticResult<?> tree() {
|
public ElectromagneticResult<?> tree() {
|
||||||
return edFileInfoService.tree(PrjQuerySource.PRJ_INTERFACE.value);
|
return edFileInfoService.tree(PrjQuerySource.SYS_DB.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
@UserOperation(value = "创建文件夹", modelName = UserOperationModuleEnum.DATABASE)
|
||||||
|
|
|
||||||
|
|
@ -49,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(PrjQuerySource.PRJ_INTERFACE.value);
|
return edPrjService.queryAllPrjInfo(PrjQuerySource.SYS_PRJ.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.PRJ_SETTING)
|
||||||
|
|
|
||||||
|
|
@ -34,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(PrjQuerySource.USER_INTERFACE.value);
|
return edFileInfoService.tree(PrjQuerySource.USER_DB.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "创建文件夹", modelName =UserOperationModuleEnum.USER_PRJ)
|
@UserOperation(value = "创建文件夹", modelName =UserOperationModuleEnum.USER_PRJ)
|
||||||
|
|
|
||||||
|
|
@ -44,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(PrjQuerySource.USER_INTERFACE.value);
|
return edPrjService.queryAllPrjInfo(PrjQuerySource.USER_PRJ.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.USER_PRJ)
|
@UserOperation(value = "添加子集", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
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<>();
|
Map<Integer, List<String>> map = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
// 首先查出所有的工程id
|
// 首先查出所有的工程id
|
||||||
|
|
@ -214,8 +226,17 @@ public class CommonService {
|
||||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
|
||||||
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code)
|
.eq(EdFileInfo::getDataOwn, DataOwnEnum.SYS_PRJ.code)
|
||||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID);
|
.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);
|
queryWrapper.in(EdFileInfo::getId, accessibleIds);
|
||||||
}
|
}
|
||||||
List<String> prjIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
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)
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||||
.likeRight(EdFileInfo::getFilePath, id);
|
.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)
|
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
.or()
|
.or()
|
||||||
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
|
||||||
|
|
@ -267,7 +288,7 @@ public class CommonService {
|
||||||
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
|
||||||
.likeRight(EdFileInfo::getFilePath, id);
|
.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)
|
prjQueryWrapper.and(qr -> qr.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.WAIT_DELETED.code)
|
||||||
.or()
|
.or()
|
||||||
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
|
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code));
|
||||||
|
|
@ -408,15 +429,17 @@ public class CommonService {
|
||||||
|
|
||||||
public Set<String> selectPrjLeafs(int dataOwnCode) {
|
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<>();
|
Set<String> res = new HashSet<>();
|
||||||
prjInfo.forEach(e -> {
|
|
||||||
FileProjectVO projectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
|
// List<String> prjInfo = (dataOwnCode == DataOwnEnum.SYS_FILE.code) ?
|
||||||
Set<String> leafIds = getLeafNodes(projectVO).stream().map(FileProjectVO::getCategoryId).collect(Collectors.toSet());
|
// querySysPrjTree(PrjQuerySource.USER_INTERFACE.value, null, new FileProjectVO()).get(PrjQuerySource.USER_INTERFACE.value):
|
||||||
res.addAll(leafIds);
|
// 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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* 项目层级结构查询
|
* 项目层级结构查询
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -187,9 +188,13 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> tree(int querySource) {
|
public ElectromagneticResult<?> tree(int querySource) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 都是从用户界面处进来,一个是从数据库的用户界面(SYS_DB),一个是从用户自己的工程界面处(USER_DB)。
|
||||||
|
*/
|
||||||
|
|
||||||
List<String> accessibleIds;
|
List<String> accessibleIds;
|
||||||
|
|
||||||
if (querySource == PrjQuerySource.PRJ_INTERFACE.value) {
|
if (querySource == PrjQuerySource.SYS_DB.value) {
|
||||||
accessibleIds = permissionService.getAccessibleTree();
|
accessibleIds = permissionService.getAccessibleTree();
|
||||||
if (CollUtil.isEmpty(accessibleIds)) {
|
if (CollUtil.isEmpty(accessibleIds)) {
|
||||||
return ElectromagneticResultUtil.success(new ArrayList<>());
|
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());
|
.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.querySysPrjTree(querySource, accessibleIds, new FileProjectVO()) :
|
||||||
commonService.queryUserPrjTree(querySource, 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<String> strings = map.getOrDefault(querySource, new ArrayList<>());
|
||||||
List<FileProjectVO> res = new ArrayList<>();
|
List<FileProjectVO> res = new ArrayList<>();
|
||||||
strings.forEach(e -> {
|
strings.forEach(e -> {
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,11 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
|
||||||
@Override
|
@Override
|
||||||
public ElectromagneticResult<?> queryAllPrjInfo(int querySource) {
|
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.querySysPrjTree(querySource, null, new ProjectVO()) :
|
||||||
commonService.queryUserPrjTree(querySource, new ProjectVO());
|
commonService.queryUserPrjTree(querySource, new ProjectVO());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@ import lombok.AllArgsConstructor;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum PrjQuerySource {
|
public enum PrjQuerySource {
|
||||||
|
|
||||||
PRJ_INTERFACE(0),
|
SYS_PRJ(0),
|
||||||
USER_INTERFACE(1);
|
SYS_DB(1),
|
||||||
|
USER_PRJ(2),
|
||||||
|
USER_DB(3);
|
||||||
|
|
||||||
public final int value;
|
public final int value;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue