增加用户查询目录树的权限校验

This commit is contained in:
chenxudong 2025-01-08 14:20:33 +08:00
parent 8921286146
commit 8b23fb63d6
3 changed files with 9 additions and 4 deletions

View File

@ -211,7 +211,7 @@ public class CommonService {
}
}
public List<String> queryAllPrjInfo(boolean isAdminQuery) {
public List<String> queryAllPrjInfo(boolean isAdminQuery, List<String> prjIds) {
try {
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
@ -219,7 +219,7 @@ public class CommonService {
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
if (!isAdminQuery) {
queryWrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code);
queryWrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code).in(EdFileInfo::getId, prjIds);
}
List<String> ids = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());

View File

@ -171,7 +171,11 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
*/
@Override
public ElectromagneticResult<?> tree() {
List<String> strings = commonService.queryAllPrjInfo(false);
List<String> prjIds = permissionService.getAccessibleTree();
if (CollUtil.isEmpty(prjIds)) {
return ElectromagneticResultUtil.success(new ArrayList<>());
}
List<String> strings = commonService.queryAllPrjInfo(false, prjIds);
List<FileProjectVO> res = new ArrayList<>();
strings.forEach(e -> {
FileProjectVO fileProjectVO = JSONUtil.toList(e, FileProjectVO.class).get(0);
@ -686,6 +690,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> upload(String parentId, MultipartFile file, Integer strategy) {
Assert.isTrue(!file.isEmpty(), "禁止上传空文件");
Assert.isTrue(EleCommonUtil.isFileNameValid(file.getOriginalFilename()), NAME_VALID_MSG);
// 查找下一层看是否存在顶级定义相关文件如果存在则该层属于管理员层级定义的不允许上传文件
long dirCount = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)

View File

@ -222,7 +222,7 @@ public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo>
*/
@Override
public ElectromagneticResult<?> queryAllPrjInfo() {
List<String> res = commonService.queryAllPrjInfo(true);
List<String> res = commonService.queryAllPrjInfo(true, null);
List<ProjectVO> projectVOS = new ArrayList<>();
res.forEach(e -> {
ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0);