Эх сурвалжийг харах

试验-规范文件-批量更新时对旧文件进行删除

LHB 2 сар өмнө
parent
commit
a72cf2c990

+ 5 - 4
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/PrivateStandardServiceImpl.java

@@ -192,7 +192,7 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public boolean updateTypeByTwo(List<PrivateStandardDTO> data,
                                    List<Long> delIds,
                                    List<Long> delFileIds,
@@ -235,15 +235,16 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe
                     if(dto.getFile() != null){
                         //再去查询当前规范文件是否在数据库中存在未删除的文件
                         List<StandardFile> list = standardFileService.list(Wrappers.<StandardFile>lambdaQuery()
-                                .eq(StandardFile::getStandardId, dto.getId()));
+                                .eq(StandardFile::getStandardId, dto.getId())
+                                .eq(StandardFile::getIsDeleted, 0));
                         if(CollectionUtils.isNotEmpty(list)){
                             //删除文件
-                            for (StandardFile standardFile : standardFiles) {
+                            for (StandardFile standardFile : list) {
                                 String pdfName = standardFile.getStandardFileUrl().split("upload")[1];
                                 this.newIOSSClient.removeFile("upload" + pdfName);
                                 standardFile.setIsDeleted(1);
                             }
-                            standardFileService.saveOrUpdateBatch(standardFiles);
+                            standardFileService.saveOrUpdateBatch(list);
                         }
                         MultipartFile file = dto.getFile();
                         StandardFile standardFile = new StandardFile();