| 
					
				 | 
			
			
				@@ -1,5 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package org.springblade.business.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.core.util.ReflectUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springblade.business.entity.StandardFile; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -19,11 +20,13 @@ import org.springblade.core.secure.BladeUser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springblade.core.secure.utils.SecureUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springblade.core.tool.utils.BeanUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springblade.resource.feign.NewIOSSClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.mock.web.MockMultipartFile; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.multipart.MultipartFile; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.InputStream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -68,6 +71,7 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (MultipartFile file : files) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     StandardFile standardFile = new StandardFile(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     standardFile.setId(SnowFlakeUtil.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     standardFile.setStandardId(uWbsPrivateStandard.getId()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -76,12 +80,15 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     String originalFilename = file.getOriginalFilename(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     standardFile.setFileName(originalFilename); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    originalFilename = "standard/" + uWbsPrivateStandard.getId() + "|" + originalFilename; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    originalFilename = "standard/" + uWbsPrivateStandard.getId() + "|" + originalFilename; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    ReflectUtil.setFieldValue(file,"filename",originalFilename); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    MockMultipartFile multipartFile = new MockMultipartFile("file", originalFilename, "application/pdf", file.getInputStream()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //Oss上传 传特殊文件名 在oss中做特殊路径处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    BladeFile bladeFile = this.newIOSSClient.uploadFileByInputStream2(file.getOriginalFilename(), file.getInputStream()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BladeFile bladeFile = newIOSSClient.uploadFileByInputStream(multipartFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     standardFile.setStandardFileUrl(bladeFile.getLink()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     standardFiles.add(standardFile); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -89,7 +96,8 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //删除之前上传的文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (StandardFile standardFile : standardFiles) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.newIOSSClient.removeFile(standardFile.getStandardFileUrl()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String pdfName = standardFile.getStandardFileUrl().split("upload")[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    this.newIOSSClient.removeFile("upload" + pdfName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new ServiceException("文件上传失败!请检查Oss"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -136,7 +144,8 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //删除之前上传的文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (StandardFile standardFile : standardFiles) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.newIOSSClient.removeFile(standardFile.getStandardFileUrl()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String pdfName = standardFile.getStandardFileUrl().split("upload")[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    this.newIOSSClient.removeFile("upload" + pdfName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new ServiceException("文件上传失败!请检查Oss"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -192,7 +201,8 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         StandardFile byId = standardFileService.getById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (byId != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.newIOSSClient.removeFile(byId.getStandardFileUrl()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String pdfName = byId.getStandardFileUrl().split("upload")[1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.newIOSSClient.removeFile("upload" + pdfName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new ServiceException("文件删除失败,Oss异常"); 
			 |