|
@@ -216,34 +216,39 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe
|
|
|
throw new ServiceException("Oss删除文件失败");
|
|
|
}
|
|
|
try {
|
|
|
+
|
|
|
// 文件索引计数器
|
|
|
int fileIndex = 0;
|
|
|
for (PrivateStandardDTO dto : data) {
|
|
|
// 获取当前对象需要的文件数量
|
|
|
int fileCount = dto.getFilesCount();
|
|
|
- if(fileCount > 0){
|
|
|
- dto.setFile(allFiles[fileIndex++]);
|
|
|
+ if(allFiles != null && allFiles.length > 0){
|
|
|
+ if(fileCount > 0 && fileIndex < allFiles.length){
|
|
|
+ dto.setFile(allFiles[fileIndex++]);
|
|
|
+ }
|
|
|
+ //先上传文件,上传成功在执行添加
|
|
|
+ if(dto.getFiles() != null){
|
|
|
+ MultipartFile file = dto.getFile();
|
|
|
+ StandardFile standardFile = new StandardFile();
|
|
|
+ standardFile.setId(SnowFlakeUtil.getId());
|
|
|
+ standardFile.setStandardId(dto.getId());
|
|
|
+ standardFile.setCreateUser(user.getUserId());
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ standardFile.setFileName(originalFilename);
|
|
|
+ originalFilename = "standard/" + dto.getId() + "|" + originalFilename;
|
|
|
+ MockMultipartFile multipartFile = new MockMultipartFile("file", originalFilename, "application/pdf", file.getInputStream());
|
|
|
+
|
|
|
+ //Oss上传 传特殊文件名 在oss中做特殊路径处理
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFileByInputStream(multipartFile);
|
|
|
+ standardFile.setStandardFileUrl(bladeFile.getLink());
|
|
|
+
|
|
|
+ //添加新文件
|
|
|
+ standardFileService.save(standardFile);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //先上传文件,上传成功在执行添加
|
|
|
- if(dto.getFiles() != null){
|
|
|
- MultipartFile file = dto.getFile();
|
|
|
- StandardFile standardFile = new StandardFile();
|
|
|
- standardFile.setId(SnowFlakeUtil.getId());
|
|
|
- standardFile.setStandardId(dto.getId());
|
|
|
- standardFile.setCreateUser(user.getUserId());
|
|
|
- String originalFilename = file.getOriginalFilename();
|
|
|
- standardFile.setFileName(originalFilename);
|
|
|
- originalFilename = "standard/" + dto.getId() + "|" + originalFilename;
|
|
|
- MockMultipartFile multipartFile = new MockMultipartFile("file", originalFilename, "application/pdf", file.getInputStream());
|
|
|
|
|
|
- //Oss上传 传特殊文件名 在oss中做特殊路径处理
|
|
|
- BladeFile bladeFile = newIOSSClient.uploadFileByInputStream(multipartFile);
|
|
|
- standardFile.setStandardFileUrl(bladeFile.getLink());
|
|
|
|
|
|
- //添加新文件
|
|
|
- standardFileService.save(standardFile);
|
|
|
- }
|
|
|
//创建数据
|
|
|
PrivateStandard privateStandard = BeanUtil.copyProperties(dto, PrivateStandard.class);
|
|
|
//修改
|