refactor(文件管理): 兼容历史数据处理

This commit is contained in:
fit2-zhao 2022-08-17 18:45:08 +08:00 committed by fit2-zhao
parent dc42319401
commit 6916b2d8c5
1 changed files with 5 additions and 2 deletions

View File

@ -253,9 +253,11 @@ public class FileMetadataService {
if (fileMetadataMapper.selectByPrimaryKey(fileMetadata.getId()) != null) {
fileMetadata.setUpdateTime(System.currentTimeMillis());
fileMetadata.setUpdateUser(SessionUtils.getUserId());
// 历史数据的路径不做更新
if (StringUtils.isNotEmpty(fileMetadata.getStorage()) && StringUtils.isEmpty(fileMetadata.getResourceType())) {
fileMetadata.setPath(FileUtils.getFilePath(fileMetadata));
}
fileMetadataMapper.updateByPrimaryKeySelective(fileMetadata);
}
}
@ -343,6 +345,7 @@ public class FileMetadataService {
FileMetadataExample fileMetadata = new FileMetadataExample();
fileMetadata.createCriteria().andProjectIdIn(projectIds).andLoadJarEqualTo(true);
List<FileMetadata> files = fileMetadataMapper.selectByExample(fileMetadata);
files = files.stream().filter(s -> StringUtils.isNotEmpty(s.getPath())).collect(Collectors.toList());
return files.stream().map(FileMetadata::getPath).collect(Collectors.toList());
}
return new LinkedList<>();