|
@@ -258,12 +258,7 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileInfo> implement
|
|
|
*/
|
|
|
@Override
|
|
|
public List<FileInfo> queryByFileMd5s(Set<String> fileMd5s) {
|
|
|
- LambdaQueryWrapper<FileInfo> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- if (CollUtil.isNotEmpty(fileMd5s)){
|
|
|
- queryWrapper.in(FileInfo::getFileMd5,fileMd5s);
|
|
|
- }
|
|
|
- queryWrapper.eq(FileInfo::getValid,true);
|
|
|
- return this.list(queryWrapper);
|
|
|
+ return fileMapper.getFileInfoByFileMd5s(fileMd5s);
|
|
|
}
|
|
|
|
|
|
* Description: 初始化文件下载
|
|
@@ -354,6 +349,59 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileInfo> implement
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 根据文件md5值批量删除文件
|
|
|
+ * @param fileInfos : 文件信息集合
|
|
|
+ * return : void
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/2/14 10:46
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = BusinessException.class)
|
|
|
+ public void deleteFileByFileMd5s(List<FileInfo> fileInfos) {
|
|
|
+ Set<String> fileMd5s = fileInfos.stream().map(FileInfo::getFileMd5).collect(Collectors.toSet());
|
|
|
+ Set<String> fileIds = fileInfos.stream().map(FileInfo::getId).collect(Collectors.toSet());
|
|
|
+ Map<String, Set<String>> deleteFileMap = fileInfos.stream()
|
|
|
+ .collect(Collectors
|
|
|
+ .groupingBy(FileInfo::getFileBucket, Collectors.mapping(FileInfo::getFilePath, Collectors.toSet())));
|
|
|
+
|
|
|
+ deleteFileByIds(fileIds);
|
|
|
+
|
|
|
+ deleteFileMd5ByMd5s(fileMd5s);
|
|
|
+
|
|
|
+ FileStorageFactory.getService().batchDelete(deleteFileMap);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 根据文件md5删除md5信息
|
|
|
+ * @param fileMd5s : 文件md5集合
|
|
|
+ * return : void
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/2/14 11:05
|
|
|
+ */
|
|
|
+ private void deleteFileMd5ByMd5s(Set<String> fileMd5s) {
|
|
|
+ LambdaQueryWrapper<FileMd5> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(FileMd5::getFileMd5,fileMd5s);
|
|
|
+ FileMd5 fileMd5 = new FileMd5();
|
|
|
+ fileMd5.setValid(0);
|
|
|
+ fileMd5Service.update(fileMd5,queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 根据文件id删除文件
|
|
|
+ * @param fileIds :文件id集合
|
|
|
+ * return : void
|
|
|
+ * @author : lijie
|
|
|
+ * Update By 2022/2/14 11:02
|
|
|
+ */
|
|
|
+ private void deleteFileByIds(Set<String> fileIds) {
|
|
|
+ LambdaQueryWrapper<FileInfo> queryWrapper=new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(FileInfo::getId,fileIds);
|
|
|
+ FileInfo fileInfo = new FileInfo();
|
|
|
+ fileInfo.setValid(0);
|
|
|
+ this.update(fileInfo,queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* Description: 初次上传和已有文件信息但未上传任何分片的情况下则直接生成所有上传url
|
|
|
* @param requestData :
|