fix: 防止文件夹建立关系
This commit is contained in:
parent
38fcdcb859
commit
2bd7795002
|
|
@ -198,4 +198,10 @@ public interface EdFileInfoService {
|
|||
*/
|
||||
void resetFileInfoName(EdFileInfo fileInfo);
|
||||
|
||||
/**
|
||||
* 判断是否是文件夹
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean isFolder(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1303,4 +1303,16 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
public IPage<FileInfoVO> queryFileList (Page<FileInfoVO> page, List<String> ids, FileInfoQueryDTO queryDTO, int saveStatus, int effectFlag) {
|
||||
return this.baseMapper.queryFileList(page, ids, queryDTO, saveStatus, effectFlag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是文件夹
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isFolder(String id) {
|
||||
EdFileInfo fileInfo = this.baseMapper.selectById(id);
|
||||
Assert.notNull(fileInfo, StrFormatter.format("文件不存在,ID为{}", id));
|
||||
return fileInfo.getDataType().equals(EleDataTypeEnum.FOLDER.code);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,11 @@ public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper,
|
|||
// 无法建立已建立的关系
|
||||
String queryId1 = edFileRelation.getId1();
|
||||
String queryId2 = edFileRelation.getId2();
|
||||
|
||||
if (edFileInfoService.isFolder(queryId1) || edFileInfoService.isFolder(queryId2)) {
|
||||
throw new BizException("文件夹无法建立关系");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<EdFileRelation> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(EdFileRelation::getId1, queryId1).eq(EdFileRelation::getId2, queryId2)
|
||||
.or()
|
||||
|
|
|
|||
Loading…
Reference in New Issue