|  |  | 
 |  |  | package com.zy.crm.common.utils; | 
 |  |  |  | 
 |  |  | import java.io.*; | 
 |  |  |  | 
 |  |  | import com.zy.crm.manager.entity.PlanUrl; | 
 |  |  | import org.springframework.core.io.Resource; | 
 |  |  |  | 
 |  |  | import java.net.URLEncoder; | 
 |  |  | 
 |  |  | //        } | 
 |  |  | //    } | 
 |  |  |  | 
 |  |  |     public static void saveFile(MultipartFile file, String savePath) throws IOException { | 
 |  |  |         // 创建保存文件的目录(如果不存在) | 
 |  |  |         File directory = new File(savePath); | 
 |  |  |         if (!directory.exists()) { | 
 |  |  |             directory.mkdirs(); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         // 保存文件 | 
 |  |  |         String fileName = file.getOriginalFilename(); | 
 |  |  |         String filePath = savePath + fileName; | 
 |  |  |         File dest = new File(filePath); | 
 |  |  |         file.transferTo(dest); | 
 |  |  |     } | 
 |  |  | //    public static void saveFile(MultipartFile file, String savePath) throws IOException { | 
 |  |  | //        // 创建保存文件的目录(如果不存在) | 
 |  |  | //        File directory = new File(savePath); | 
 |  |  | //        if (!directory.exists()) { | 
 |  |  | //            directory.mkdirs(); | 
 |  |  | //        } | 
 |  |  | // | 
 |  |  | //        // 保存文件 | 
 |  |  | //        String fileName = file.getOriginalFilename(); | 
 |  |  | //        String filePath = savePath + fileName; | 
 |  |  | //        File dest = new File(filePath); | 
 |  |  | //        file.transferTo(dest); | 
 |  |  | //    } | 
 |  |  |  | 
 |  |  |     public static void deleteFilesInDirectory(String directoryPath) { | 
 |  |  |         File directory = new File(directoryPath); | 
 |  |  | 
 |  |  |         private String name; | 
 |  |  |         private long size; | 
 |  |  |         private String path; | 
 |  |  |         private String userName; | 
 |  |  |         private boolean success; | 
 |  |  |         private String errorMessage; | 
 |  |  |  | 
 |  |  | 
 |  |  |             this.path = path; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public FileDTO(String name, long size, String path,String userName) { | 
 |  |  |             this.name = name; | 
 |  |  |             this.size = size; | 
 |  |  |             this.path = path; | 
 |  |  |             this.userName = userName; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public FileDTO(String name, long size) { | 
 |  |  |             this.name = name; | 
 |  |  |             this.size = size; | 
 |  |  | //            this.path = path; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public FileDTO(PlanUrl planUrl) { | 
 |  |  |             this.name = planUrl.getName(); | 
 |  |  |             this.size = planUrl.getFileSize(); | 
 |  |  |             this.path = planUrl.getUrl(); | 
 |  |  |             this.userName = planUrl.getUserName(); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public FileDTO(boolean success, String name, String errorMessage) { | 
 |  |  |             this.success = success; | 
 |  |  |             this.name = name; |