mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	统一 FileApi 的封装,与 yudao-cloud~
This commit is contained in:
		| @@ -13,7 +13,7 @@ public interface FileApi { | |||||||
|      * @param content 文件内容 |      * @param content 文件内容 | ||||||
|      * @return 文件路径 |      * @return 文件路径 | ||||||
|      */ |      */ | ||||||
|     default String createFile(byte[] content) throws Exception { |     default String createFile(byte[] content) { | ||||||
|         return createFile(null, null, content); |         return createFile(null, null, content); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -24,18 +24,18 @@ public interface FileApi { | |||||||
|      * @param content 文件内容 |      * @param content 文件内容 | ||||||
|      * @return 文件路径 |      * @return 文件路径 | ||||||
|      */ |      */ | ||||||
|     default String createFile(String path, byte[] content) throws Exception { |     default String createFile(String path, byte[] content) { | ||||||
|         return createFile(null, path, content); |         return createFile(null, path, content); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 保存文件,并返回文件的访问路径 |      * 保存文件,并返回文件的访问路径 | ||||||
|      * |      * | ||||||
|      * @param name 原文件名称 |      * @param name 文件名称 | ||||||
|      * @param path 文件路径 |      * @param path 文件路径 | ||||||
|      * @param content 文件内容 |      * @param content 文件内容 | ||||||
|      * @return 文件路径 |      * @return 文件路径 | ||||||
|      */ |      */ | ||||||
|     String createFile(String name, String path, byte[] content) throws Exception; |     String createFile(String name, String path, byte[] content); | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ public class FileApiImpl implements FileApi { | |||||||
|     private FileService fileService; |     private FileService fileService; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public String createFile(String name, String path, byte[] content) throws Exception { |     public String createFile(String name, String path, byte[] content) { | ||||||
|         return fileService.createFile(name, path, content); |         return fileService.createFile(name, path, content); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,12 +22,12 @@ public interface FileService { | |||||||
|     /** |     /** | ||||||
|      * 保存文件,并返回文件的访问路径 |      * 保存文件,并返回文件的访问路径 | ||||||
|      * |      * | ||||||
|      * @param name 原文件名称 |      * @param name 文件名称 | ||||||
|      * @param path 文件路径 |      * @param path 文件路径 | ||||||
|      * @param content 文件内容 |      * @param content 文件内容 | ||||||
|      * @return 文件路径 |      * @return 文件路径 | ||||||
|      */ |      */ | ||||||
|     String createFile(String name, String path, byte[] content) throws Exception; |     String createFile(String name, String path, byte[] content); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 删除文件 |      * 删除文件 | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.file.core.client.FileClient; | |||||||
| import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; | ||||||
| import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; | import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; | ||||||
| import cn.iocoder.yudao.module.infra.dal.mysql.file.FileMapper; | import cn.iocoder.yudao.module.infra.dal.mysql.file.FileMapper; | ||||||
|  | import lombok.SneakyThrows; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  |  | ||||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||||
| @@ -37,7 +38,8 @@ public class FileServiceImpl implements FileService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public String createFile(String name, String path, byte[] content) throws Exception { |     @SneakyThrows | ||||||
|  |     public String createFile(String name, String path, byte[] content) { | ||||||
|         // 计算默认的 path 名 |         // 计算默认的 path 名 | ||||||
|         String type = FileTypeUtil.getType(new ByteArrayInputStream(content), name); |         String type = FileTypeUtil.getType(new ByteArrayInputStream(content), name); | ||||||
|         if (StrUtil.isEmpty(path)) { |         if (StrUtil.isEmpty(path)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV