Commit 77d634038c796215aeb531790068012bdf73b900
1 parent
067ff6cc
✨ 全局:简化 file 组件,融合到 infra 模块
Showing
45 changed files
with
207 additions
and
274 deletions
yudao-dependencies/pom.xml
| ... | ... | @@ -567,11 +567,6 @@ |
| 567 | 567 | <version>${okhttp3.version}</version> |
| 568 | 568 | </dependency> |
| 569 | 569 | <dependency> |
| 570 | - <groupId>cn.iocoder.boot</groupId> | |
| 571 | - <artifactId>yudao-spring-boot-starter-file</artifactId> | |
| 572 | - <version>${revision}</version> | |
| 573 | - </dependency> | |
| 574 | - <dependency> | |
| 575 | 570 | <groupId>io.minio</groupId> |
| 576 | 571 | <artifactId>minio</artifactId> |
| 577 | 572 | <version>${minio.version}</version> | ... | ... |
yudao-framework/pom.xml
| ... | ... | @@ -16,7 +16,6 @@ |
| 16 | 16 | <module>yudao-spring-boot-starter-web</module> |
| 17 | 17 | <module>yudao-spring-boot-starter-security</module> |
| 18 | 18 | |
| 19 | - <module>yudao-spring-boot-starter-file</module> | |
| 20 | 19 | <module>yudao-spring-boot-starter-monitor</module> |
| 21 | 20 | <module>yudao-spring-boot-starter-protection</module> |
| 22 | 21 | <module>yudao-spring-boot-starter-job</module> | ... | ... |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java
| ... | ... | @@ -136,6 +136,21 @@ public class JsonUtils { |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | + /** | |
| 140 | + * 解析 JSON 字符串成指定类型的对象,如果解析失败,则返回 null | |
| 141 | + * | |
| 142 | + * @param text 字符串 | |
| 143 | + * @param typeReference 类型引用 | |
| 144 | + * @return 指定类型的对象 | |
| 145 | + */ | |
| 146 | + public static <T> T parseObjectQuietly(String text, TypeReference<T> typeReference) { | |
| 147 | + try { | |
| 148 | + return objectMapper.readValue(text, typeReference); | |
| 149 | + } catch (IOException e) { | |
| 150 | + return null; | |
| 151 | + } | |
| 152 | + } | |
| 153 | + | |
| 139 | 154 | public static <T> List<T> parseArray(String text, Class<T> clazz) { |
| 140 | 155 | if (StrUtil.isEmpty(text)) { |
| 141 | 156 | return new ArrayList<>(); | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/pom.xml deleted
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | |
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 5 | - <parent> | |
| 6 | - <artifactId>yudao-framework</artifactId> | |
| 7 | - <groupId>cn.iocoder.boot</groupId> | |
| 8 | - <version>${revision}</version> | |
| 9 | - </parent> | |
| 10 | - <modelVersion>4.0.0</modelVersion> | |
| 11 | - <artifactId>yudao-spring-boot-starter-file</artifactId> | |
| 12 | - | |
| 13 | - <name>${project.artifactId}</name> | |
| 14 | - <description>文件客户端,支持多种存储器 | |
| 15 | - 1. file:本地磁盘 | |
| 16 | - 2. ftp:FTP 服务器 | |
| 17 | - 2. sftp:SFTP 服务器 | |
| 18 | - 4. db:数据库 | |
| 19 | - 5. s3:支持 S3 协议的云存储服务,例如说 MinIO、阿里云、华为云、腾讯云、七牛云等等 | |
| 20 | - </description> | |
| 21 | - <url>https://github.com/YunaiV/ruoyi-vue-pro</url> | |
| 22 | - | |
| 23 | - <dependencies> | |
| 24 | - <dependency> | |
| 25 | - <groupId>cn.iocoder.boot</groupId> | |
| 26 | - <artifactId>yudao-common</artifactId> | |
| 27 | - </dependency> | |
| 28 | - | |
| 29 | - <!-- Spring 核心 --> | |
| 30 | - <dependency> | |
| 31 | - <groupId>org.springframework.boot</groupId> | |
| 32 | - <artifactId>spring-boot-starter</artifactId> | |
| 33 | - </dependency> | |
| 34 | - | |
| 35 | - <!-- 工具类相关 --> | |
| 36 | - <dependency> | |
| 37 | - <groupId>org.springframework.boot</groupId> | |
| 38 | - <artifactId>spring-boot-starter-validation</artifactId> | |
| 39 | - </dependency> | |
| 40 | - | |
| 41 | - <dependency> | |
| 42 | - <groupId>org.slf4j</groupId> | |
| 43 | - <artifactId>slf4j-api</artifactId> | |
| 44 | - </dependency> | |
| 45 | - | |
| 46 | - <dependency> | |
| 47 | - <groupId>com.fasterxml.jackson.core</groupId> | |
| 48 | - <artifactId>jackson-databind</artifactId> | |
| 49 | - </dependency> | |
| 50 | - <dependency> | |
| 51 | - <groupId>com.fasterxml.jackson.core</groupId> | |
| 52 | - <artifactId>jackson-core</artifactId> | |
| 53 | - </dependency> | |
| 54 | - | |
| 55 | - <dependency> | |
| 56 | - <groupId>commons-net</groupId> | |
| 57 | - <artifactId>commons-net</artifactId> <!-- 解决 ftp 连接 --> | |
| 58 | - </dependency> | |
| 59 | - <dependency> | |
| 60 | - <groupId>com.jcraft</groupId> | |
| 61 | - <artifactId>jsch</artifactId> <!-- 解决 sftp 连接 --> | |
| 62 | - </dependency> | |
| 63 | - | |
| 64 | - <dependency> | |
| 65 | - <groupId>org.apache.tika</groupId> | |
| 66 | - <artifactId>tika-core</artifactId> <!-- 文件类型的识别 --> | |
| 67 | - </dependency> | |
| 68 | - | |
| 69 | - <!-- 三方云服务相关 --> | |
| 70 | - <dependency> | |
| 71 | - <groupId>io.minio</groupId> | |
| 72 | - <artifactId>minio</artifactId> | |
| 73 | - </dependency> | |
| 74 | - | |
| 75 | - <!-- Test 测试相关 --> | |
| 76 | - <dependency> | |
| 77 | - <groupId>cn.iocoder.boot</groupId> | |
| 78 | - <artifactId>yudao-spring-boot-starter-test</artifactId> | |
| 79 | - <scope>test</scope> | |
| 80 | - </dependency> | |
| 81 | - </dependencies> | |
| 82 | - | |
| 83 | -</project> |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/db/DBFileContentFrameworkDAO.java deleted
| 1 | -package cn.iocoder.yudao.framework.file.core.client.db; | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * 文件内容 Framework DAO 接口 | |
| 5 | - * | |
| 6 | - * @author 芋道源码 | |
| 7 | - */ | |
| 8 | -public interface DBFileContentFrameworkDAO { | |
| 9 | - | |
| 10 | - /** | |
| 11 | - * 插入文件内容 | |
| 12 | - * | |
| 13 | - * @param configId 配置编号 | |
| 14 | - * @param path 路径 | |
| 15 | - * @param content 内容 | |
| 16 | - */ | |
| 17 | - void insert(Long configId, String path, byte[] content); | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * 删除文件内容 | |
| 21 | - * | |
| 22 | - * @param configId 配置编号 | |
| 23 | - * @param path 路径 | |
| 24 | - */ | |
| 25 | - void delete(Long configId, String path); | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * 获得文件内容 | |
| 29 | - * | |
| 30 | - * @param configId 配置编号 | |
| 31 | - * @param path 路径 | |
| 32 | - * @return 内容 | |
| 33 | - */ | |
| 34 | - byte[] selectContent(Long configId, String path); | |
| 35 | - | |
| 36 | -} |
yudao-framework/yudao-spring-boot-starter-file/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/config/package-info.java deleted
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/enums/package-info.java deleted
yudao-framework/yudao-spring-boot-starter-file/src/test/resources/file/erweima.jpg deleted
18 KB
yudao-module-infra/yudao-module-infra-biz/pom.xml
| ... | ... | @@ -117,8 +117,21 @@ |
| 117 | 117 | |
| 118 | 118 | <!-- 三方云服务相关 --> |
| 119 | 119 | <dependency> |
| 120 | - <groupId>cn.iocoder.boot</groupId> | |
| 121 | - <artifactId>yudao-spring-boot-starter-file</artifactId> | |
| 120 | + <groupId>commons-net</groupId> | |
| 121 | + <artifactId>commons-net</artifactId> <!-- 文件客户端:解决 ftp 连接 --> | |
| 122 | + </dependency> | |
| 123 | + <dependency> | |
| 124 | + <groupId>com.jcraft</groupId> | |
| 125 | + <artifactId>jsch</artifactId> <!-- 文件客户端:解决 sftp 连接 --> | |
| 126 | + </dependency> | |
| 127 | + <dependency> | |
| 128 | + <groupId>io.minio</groupId> | |
| 129 | + <artifactId>minio</artifactId> <!-- 文件客户端:解决阿里云、腾讯云、minio 等 S3 连接 --> | |
| 130 | + </dependency> | |
| 131 | + | |
| 132 | + <dependency> | |
| 133 | + <groupId>org.apache.tika</groupId> | |
| 134 | + <artifactId>tika-core</artifactId> <!-- 文件客户端:文件类型的识别 --> | |
| 122 | 135 | </dependency> |
| 123 | 136 | |
| 124 | 137 | </dependencies> | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/config/FileConfigRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.infra.controller.admin.file.vo.config; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 3 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileConfigDO.java
| 1 | 1 | package cn.iocoder.yudao.module.infra.dal.dataobject.file; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 4 | -import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum; | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 7 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.db.DBFileClientConfig; | |
| 8 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.ftp.FtpFileClientConfig; | |
| 9 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClientConfig; | |
| 10 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClientConfig; | |
| 11 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.sftp.SftpFileClientConfig; | |
| 12 | +import cn.iocoder.yudao.module.infra.framework.file.core.enums.FileStorageEnum; | |
| 6 | 13 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 7 | 14 | import com.baomidou.mybatisplus.annotation.TableField; |
| 8 | 15 | import com.baomidou.mybatisplus.annotation.TableName; |
| 9 | -import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | |
| 16 | +import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; | |
| 17 | +import com.fasterxml.jackson.core.type.TypeReference; | |
| 10 | 18 | import lombok.*; |
| 11 | 19 | |
| 12 | 20 | /** |
| ... | ... | @@ -52,7 +60,42 @@ public class FileConfigDO extends BaseDO { |
| 52 | 60 | /** |
| 53 | 61 | * 支付渠道配置 |
| 54 | 62 | */ |
| 55 | - @TableField(typeHandler = JacksonTypeHandler.class) | |
| 63 | + @TableField(typeHandler = FileClientConfigTypeHandler.class) | |
| 56 | 64 | private FileClientConfig config; |
| 57 | 65 | |
| 66 | + public static class FileClientConfigTypeHandler extends AbstractJsonTypeHandler<Object> { | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + protected Object parse(String json) { | |
| 70 | + FileClientConfig config = JsonUtils.parseObjectQuietly(json, new TypeReference<>() {}); | |
| 71 | + if (config != null) { | |
| 72 | + return config; | |
| 73 | + } | |
| 74 | + | |
| 75 | + // 兼容老版本的包路径 | |
| 76 | + String className = JsonUtils.parseObject(json, "@class", String.class); | |
| 77 | + className = StrUtil.subAfter(className, ".", true); | |
| 78 | + switch (className) { | |
| 79 | + case "DBFileClientConfig": | |
| 80 | + return JsonUtils.parseObject2(json, DBFileClientConfig.class); | |
| 81 | + case "FtpFileClientConfig": | |
| 82 | + return JsonUtils.parseObject2(json, FtpFileClientConfig.class); | |
| 83 | + case "LocalFileClientConfig": | |
| 84 | + return JsonUtils.parseObject2(json, LocalFileClientConfig.class); | |
| 85 | + case "SftpFileClientConfig": | |
| 86 | + return JsonUtils.parseObject2(json, SftpFileClientConfig.class); | |
| 87 | + case "S3FileClientConfig": | |
| 88 | + return JsonUtils.parseObject2(json, S3FileClientConfig.class); | |
| 89 | + default: | |
| 90 | + throw new IllegalArgumentException("未知的 FileClientConfig 类型:" + json); | |
| 91 | + } | |
| 92 | + } | |
| 93 | + | |
| 94 | + @Override | |
| 95 | + protected String toJson(Object obj) { | |
| 96 | + return JsonUtils.toJsonString(obj); | |
| 97 | + } | |
| 98 | + | |
| 99 | + } | |
| 100 | + | |
| 58 | 101 | } | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/file/FileContentDO.java
| 1 | 1 | package cn.iocoder.yudao.module.infra.dal.dataobject.file; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.db.DBFileClient; | |
| 4 | 5 | import com.baomidou.mybatisplus.annotation.IdType; |
| 5 | 6 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 6 | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| ... | ... | @@ -10,7 +11,7 @@ import lombok.*; |
| 10 | 11 | /** |
| 11 | 12 | * 文件内容表 |
| 12 | 13 | * |
| 13 | - * 专门用于存储 {@link cn.iocoder.yudao.framework.file.core.client.db.DBFileClient} 的文件内容 | |
| 14 | + * 专门用于存储 {@link DBFileClient} 的文件内容 | |
| 14 | 15 | * |
| 15 | 16 | * @author 芋道源码 |
| 16 | 17 | */ | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/file/FileContentDAOImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.infra.dal.mysql.file; | |
| 2 | - | |
| 3 | -import cn.hutool.core.collection.CollUtil; | |
| 4 | -import cn.iocoder.yudao.framework.file.core.client.db.DBFileContentFrameworkDAO; | |
| 5 | -import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO; | |
| 6 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 7 | -import org.springframework.stereotype.Repository; | |
| 8 | - | |
| 9 | -import jakarta.annotation.Resource; | |
| 10 | -import java.util.List; | |
| 11 | -import java.util.Optional; | |
| 12 | - | |
| 13 | -@Repository | |
| 14 | -public class FileContentDAOImpl implements DBFileContentFrameworkDAO { | |
| 15 | - | |
| 16 | - @Resource | |
| 17 | - private FileContentMapper fileContentMapper; | |
| 18 | - | |
| 19 | - @Override | |
| 20 | - public void insert(Long configId, String path, byte[] content) { | |
| 21 | - FileContentDO entity = new FileContentDO().setConfigId(configId) | |
| 22 | - .setPath(path).setContent(content); | |
| 23 | - fileContentMapper.insert(entity); | |
| 24 | - } | |
| 25 | - | |
| 26 | - @Override | |
| 27 | - public void delete(Long configId, String path) { | |
| 28 | - fileContentMapper.delete(buildQuery(configId, path)); | |
| 29 | - } | |
| 30 | - | |
| 31 | - @Override | |
| 32 | - public byte[] selectContent(Long configId, String path) { | |
| 33 | - List<FileContentDO> list = fileContentMapper.selectList( | |
| 34 | - buildQuery(configId, path).select(FileContentDO::getContent).orderByDesc(FileContentDO::getId)); | |
| 35 | - return Optional.ofNullable(CollUtil.getFirst(list)) | |
| 36 | - .map(FileContentDO::getContent) | |
| 37 | - .orElse(null); | |
| 38 | - } | |
| 39 | - | |
| 40 | - private LambdaQueryWrapper<FileContentDO> buildQuery(Long configId, String path) { | |
| 41 | - return new LambdaQueryWrapper<FileContentDO>() | |
| 42 | - .eq(FileContentDO::getConfigId, configId) | |
| 43 | - .eq(FileContentDO::getPath, path); | |
| 44 | - } | |
| 45 | - | |
| 46 | -} |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/file/FileContentMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.infra.dal.mysql.file; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO; |
| 4 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 4 | 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 5 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 7 | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 7 | 10 | @Mapper |
| 8 | 11 | public interface FileContentMapper extends BaseMapper<FileContentDO> { |
| 12 | + | |
| 13 | + default void deleteByConfigIdAndPath(Long configId, String path) { | |
| 14 | + this.delete(new LambdaQueryWrapper<FileContentDO>() | |
| 15 | + .eq(FileContentDO::getConfigId, configId) | |
| 16 | + .eq(FileContentDO::getPath, path)); | |
| 17 | + } | |
| 18 | + | |
| 19 | + default List<FileContentDO> selectListByConfigIdAndPath(Long configId, String path) { | |
| 20 | + return selectList(new LambdaQueryWrapper<FileContentDO>() | |
| 21 | + .eq(FileContentDO::getConfigId, configId) | |
| 22 | + .eq(FileContentDO::getPath, path)); | |
| 23 | + } | |
| 24 | + | |
| 9 | 25 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/config/YudaoFileAutoConfiguration.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/config/YudaoFileAutoConfiguration.java
| 1 | -package cn.iocoder.yudao.framework.file.config; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.config; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.file.core.client.FileClientFactory; | |
| 4 | -import cn.iocoder.yudao.framework.file.core.client.FileClientFactoryImpl; | |
| 5 | -import org.springframework.boot.autoconfigure.AutoConfiguration; | |
| 3 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientFactory; | |
| 4 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientFactoryImpl; | |
| 6 | 5 | import org.springframework.context.annotation.Bean; |
| 6 | +import org.springframework.context.annotation.Configuration; | |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * 文件配置类 |
| 10 | 10 | * |
| 11 | 11 | * @author 芋道源码 |
| 12 | 12 | */ |
| 13 | -@AutoConfiguration | |
| 13 | +@Configuration(proxyBeanMethods = false) | |
| 14 | 14 | public class YudaoFileAutoConfiguration { |
| 15 | 15 | |
| 16 | 16 | @Bean | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/AbstractFileClient.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/AbstractFileClient.java
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/FileClient.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/FileClient.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.file.core.client.s3.FilePresignedUrlRespDTO; | |
| 3 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO; | |
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * 文件客户端 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/FileClientConfig.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/FileClientConfig.java
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/FileClientFactory.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/FileClientFactory.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.infra.framework.file.core.enums.FileStorageEnum; | |
| 2 | 4 | |
| 3 | 5 | public interface FileClientFactory { |
| 4 | 6 | |
| ... | ... | @@ -14,7 +16,7 @@ public interface FileClientFactory { |
| 14 | 16 | * 创建文件客户端 |
| 15 | 17 | * |
| 16 | 18 | * @param configId 配置编号 |
| 17 | - * @param storage 存储器的枚举 {@link cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum} | |
| 19 | + * @param storage 存储器的枚举 {@link FileStorageEnum} | |
| 18 | 20 | * @param config 文件配置 |
| 19 | 21 | */ |
| 20 | 22 | <Config extends FileClientConfig> void createOrUpdateFileClient(Long configId, Integer storage, Config config); | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/FileClientFactoryImpl.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/FileClientFactoryImpl.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.lang.Assert; |
| 4 | 4 | import cn.hutool.core.util.ReflectUtil; |
| 5 | -import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum; | |
| 5 | +import cn.iocoder.yudao.module.infra.framework.file.core.enums.FileStorageEnum; | |
| 6 | 6 | import lombok.extern.slf4j.Slf4j; |
| 7 | 7 | |
| 8 | 8 | import java.util.concurrent.ConcurrentHashMap; | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/db/DBFileClient.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/db/DBFileClient.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.db; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.db; | |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.hutool.extra.spring.SpringUtil; |
| 4 | -import cn.iocoder.yudao.framework.file.core.client.AbstractFileClient; | |
| 5 | +import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileContentDO; | |
| 6 | +import cn.iocoder.yudao.module.infra.dal.mysql.file.FileContentMapper; | |
| 7 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClient; | |
| 8 | + | |
| 9 | +import java.util.Comparator; | |
| 10 | +import java.util.List; | |
| 5 | 11 | |
| 6 | 12 | /** |
| 7 | 13 | * 基于 DB 存储的文件客户端的配置类 |
| ... | ... | @@ -10,7 +16,7 @@ import cn.iocoder.yudao.framework.file.core.client.AbstractFileClient; |
| 10 | 16 | */ |
| 11 | 17 | public class DBFileClient extends AbstractFileClient<DBFileClientConfig> { |
| 12 | 18 | |
| 13 | - private DBFileContentFrameworkDAO dao; | |
| 19 | + private FileContentMapper fileContentMapper; | |
| 14 | 20 | |
| 15 | 21 | public DBFileClient(Long id, DBFileClientConfig config) { |
| 16 | 22 | super(id, config); |
| ... | ... | @@ -18,31 +24,32 @@ public class DBFileClient extends AbstractFileClient<DBFileClientConfig> { |
| 18 | 24 | |
| 19 | 25 | @Override |
| 20 | 26 | protected void doInit() { |
| 27 | + fileContentMapper = SpringUtil.getBean(FileContentMapper.class); | |
| 21 | 28 | } |
| 22 | 29 | |
| 23 | 30 | @Override |
| 24 | 31 | public String upload(byte[] content, String path, String type) { |
| 25 | - getDao().insert(getId(), path, content); | |
| 32 | + FileContentDO contentDO = new FileContentDO().setConfigId(getId()) | |
| 33 | + .setPath(path).setContent(content); | |
| 34 | + fileContentMapper.insert(contentDO); | |
| 26 | 35 | // 拼接返回路径 |
| 27 | 36 | return super.formatFileUrl(config.getDomain(), path); |
| 28 | 37 | } |
| 29 | 38 | |
| 30 | 39 | @Override |
| 31 | 40 | public void delete(String path) { |
| 32 | - getDao().delete(getId(), path); | |
| 41 | + fileContentMapper.deleteByConfigIdAndPath(getId(), path); | |
| 33 | 42 | } |
| 34 | 43 | |
| 35 | 44 | @Override |
| 36 | 45 | public byte[] getContent(String path) { |
| 37 | - return getDao().selectContent(getId(), path); | |
| 38 | - } | |
| 39 | - | |
| 40 | - private DBFileContentFrameworkDAO getDao() { | |
| 41 | - // 延迟获取,因为 SpringUtil 初始化太慢 | |
| 42 | - if (dao == null) { | |
| 43 | - dao = SpringUtil.getBean(DBFileContentFrameworkDAO.class); | |
| 46 | + List<FileContentDO> list = fileContentMapper.selectListByConfigIdAndPath(getId(), path); | |
| 47 | + if (CollUtil.isEmpty(list)) { | |
| 48 | + return null; | |
| 44 | 49 | } |
| 45 | - return dao; | |
| 50 | + // 排序后,拿 id 最大的,即最后上传的 | |
| 51 | + list.sort(Comparator.comparing(FileContentDO::getId)); | |
| 52 | + return CollUtil.getLast(list).getContent(); | |
| 46 | 53 | } |
| 47 | 54 | |
| 48 | 55 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/db/DBFileClientConfig.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/db/DBFileClientConfig.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.db; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.db; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 3 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | import org.hibernate.validator.constraints.URL; |
| 6 | 6 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClient.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/ftp/FtpFileClient.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.ftp; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.ftp; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.FileUtil; |
| 4 | 4 | import cn.hutool.core.util.CharsetUtil; |
| ... | ... | @@ -6,7 +6,7 @@ import cn.hutool.core.util.StrUtil; |
| 6 | 6 | import cn.hutool.extra.ftp.Ftp; |
| 7 | 7 | import cn.hutool.extra.ftp.FtpException; |
| 8 | 8 | import cn.hutool.extra.ftp.FtpMode; |
| 9 | -import cn.iocoder.yudao.framework.file.core.client.AbstractFileClient; | |
| 9 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClient; | |
| 10 | 10 | |
| 11 | 11 | import java.io.ByteArrayInputStream; |
| 12 | 12 | import java.io.ByteArrayOutputStream; | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClientConfig.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/ftp/FtpFileClientConfig.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.ftp; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.ftp; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 3 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | import org.hibernate.validator.constraints.URL; |
| 6 | 6 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/local/LocalFileClient.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/local/LocalFileClient.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.local; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.local; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.FileUtil; |
| 4 | -import cn.iocoder.yudao.framework.file.core.client.AbstractFileClient; | |
| 4 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClient; | |
| 5 | 5 | |
| 6 | 6 | import java.io.File; |
| 7 | 7 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/local/LocalFileClientConfig.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/local/LocalFileClientConfig.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.local; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.local; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 3 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | import org.hibernate.validator.constraints.URL; |
| 6 | 6 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/s3/FilePresignedUrlRespDTO.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/FilePresignedUrlRespDTO.java
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClient.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.s3; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.s3; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.IoUtil; |
| 4 | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | 5 | import cn.hutool.http.HttpUtil; |
| 6 | -import cn.iocoder.yudao.framework.file.core.client.AbstractFileClient; | |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClient; | |
| 7 | 7 | import io.minio.*; |
| 8 | 8 | import io.minio.http.Method; |
| 9 | 9 | |
| 10 | 10 | import java.io.ByteArrayInputStream; |
| 11 | 11 | import java.util.concurrent.TimeUnit; |
| 12 | 12 | |
| 13 | -import static cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_ALIYUN; | |
| 14 | -import static cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_TENCENT; | |
| 15 | - | |
| 16 | 13 | /** |
| 17 | 14 | * 基于 S3 协议的文件客户端,实现 MinIO、阿里云、腾讯云、七牛云、华为云等云服务 |
| 18 | 15 | * <p> |
| ... | ... | @@ -76,15 +73,15 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> { |
| 76 | 73 | */ |
| 77 | 74 | private String buildRegion() { |
| 78 | 75 | // 阿里云必须有 region,否则会报错 |
| 79 | - if (config.getEndpoint().contains(ENDPOINT_ALIYUN)) { | |
| 76 | + if (config.getEndpoint().contains(S3FileClientConfig.ENDPOINT_ALIYUN)) { | |
| 80 | 77 | return StrUtil.subBefore(config.getEndpoint(), '.', false) |
| 81 | 78 | .replaceAll("-internal", "")// 去除内网 Endpoint 的后缀 |
| 82 | 79 | .replaceAll("https://", ""); |
| 83 | 80 | } |
| 84 | 81 | // 腾讯云必须有 region,否则会报错 |
| 85 | - if (config.getEndpoint().contains(ENDPOINT_TENCENT)) { | |
| 82 | + if (config.getEndpoint().contains(S3FileClientConfig.ENDPOINT_TENCENT)) { | |
| 86 | 83 | return StrUtil.subAfter(config.getEndpoint(), "cos.", false) |
| 87 | - .replaceAll("." + ENDPOINT_TENCENT, ""); // 去除 Endpoint | |
| 84 | + .replaceAll("." + S3FileClientConfig.ENDPOINT_TENCENT, ""); // 去除 Endpoint | |
| 88 | 85 | } |
| 89 | 86 | return null; |
| 90 | 87 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientConfig.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.s3; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.s3; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 4 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 5 | 5 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 6 | 6 | import lombok.Data; |
| 7 | 7 | import org.hibernate.validator.constraints.URL; | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/sftp/SftpFileClient.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/sftp/SftpFileClient.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.sftp; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.sftp; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.FileUtil; |
| 4 | 4 | import cn.hutool.extra.ssh.Sftp; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.io.FileUtils; |
| 6 | -import cn.iocoder.yudao.framework.file.core.client.AbstractFileClient; | |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.AbstractFileClient; | |
| 7 | 7 | |
| 8 | 8 | import java.io.File; |
| 9 | 9 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/sftp/SftpFileClientConfig.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/sftp/SftpFileClientConfig.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.sftp; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.client.sftp; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 3 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | import org.hibernate.validator.constraints.URL; |
| 6 | 6 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/enums/FileStorageEnum.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/enums/FileStorageEnum.java
| 1 | -package cn.iocoder.yudao.framework.file.core.enums; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.enums; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ArrayUtil; |
| 4 | -import cn.iocoder.yudao.framework.file.core.client.FileClient; | |
| 5 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 6 | -import cn.iocoder.yudao.framework.file.core.client.db.DBFileClient; | |
| 7 | -import cn.iocoder.yudao.framework.file.core.client.db.DBFileClientConfig; | |
| 8 | -import cn.iocoder.yudao.framework.file.core.client.ftp.FtpFileClient; | |
| 9 | -import cn.iocoder.yudao.framework.file.core.client.ftp.FtpFileClientConfig; | |
| 10 | -import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClient; | |
| 11 | -import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClientConfig; | |
| 12 | -import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClient; | |
| 13 | -import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig; | |
| 14 | -import cn.iocoder.yudao.framework.file.core.client.sftp.SftpFileClient; | |
| 15 | -import cn.iocoder.yudao.framework.file.core.client.sftp.SftpFileClientConfig; | |
| 4 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; | |
| 5 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.db.DBFileClient; | |
| 7 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.db.DBFileClientConfig; | |
| 8 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.ftp.FtpFileClient; | |
| 9 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.ftp.FtpFileClientConfig; | |
| 10 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClient; | |
| 11 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClientConfig; | |
| 12 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClient; | |
| 13 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClientConfig; | |
| 14 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.sftp.SftpFileClient; | |
| 15 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.sftp.SftpFileClientConfig; | |
| 16 | 16 | import lombok.AllArgsConstructor; |
| 17 | 17 | import lombok.Getter; |
| 18 | 18 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/utils/FileTypeUtils.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/utils/FileTypeUtils.java
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/package-info.java
0 → 100644
| 1 | +/** | |
| 2 | + * 文件客户端,支持多种存储器 | |
| 3 | + * | |
| 4 | + * 1. local:本地磁盘 | |
| 5 | + * 2. ftp:FTP 服务器 | |
| 6 | + * 3. sftp:SFTP 服务器 | |
| 7 | + * 4. db:数据库 | |
| 8 | + * 5. s3:支持 S3 协议的云存储服务,例如说 MinIO、阿里云、华为云、腾讯云、七牛云等等 | |
| 9 | + * | |
| 10 | + * @author 芋道源码 | |
| 11 | + */ | |
| 12 | +package cn.iocoder.yudao.module.infra.framework.file; | |
| 0 | 13 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigService.java
| 1 | 1 | package cn.iocoder.yudao.module.infra.service.file; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.framework.file.core.client.FileClient; | |
| 4 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; | |
| 5 | 5 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO; | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImpl.java
| ... | ... | @@ -5,10 +5,10 @@ import cn.hutool.core.util.IdUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| 8 | -import cn.iocoder.yudao.framework.file.core.client.FileClient; | |
| 9 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 10 | -import cn.iocoder.yudao.framework.file.core.client.FileClientFactory; | |
| 11 | -import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum; | |
| 8 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; | |
| 9 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 10 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientFactory; | |
| 11 | +import cn.iocoder.yudao.module.infra.framework.file.core.enums.FileStorageEnum; | |
| 12 | 12 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO; |
| 13 | 13 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO; |
| 14 | 14 | import cn.iocoder.yudao.module.infra.convert.file.FileConfigConvert; | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java
| ... | ... | @@ -5,9 +5,9 @@ import cn.hutool.core.util.StrUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.io.FileUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | -import cn.iocoder.yudao.framework.file.core.client.FileClient; | |
| 9 | -import cn.iocoder.yudao.framework.file.core.client.s3.FilePresignedUrlRespDTO; | |
| 10 | -import cn.iocoder.yudao.framework.file.core.utils.FileTypeUtils; | |
| 8 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; | |
| 9 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO; | |
| 10 | +import cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils; | |
| 11 | 11 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileCreateReqVO; |
| 12 | 12 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; |
| 13 | 13 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO; | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/file/erweima.jpg
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClientTest.java renamed to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/ftp/FtpFileClientTest.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.ftp; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.ftp; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.resource.ResourceUtil; |
| 4 | 4 | import cn.hutool.core.util.IdUtil; |
| 5 | 5 | import cn.hutool.extra.ftp.FtpMode; |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.ftp.FtpFileClient; | |
| 7 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.ftp.FtpFileClientConfig; | |
| 6 | 8 | import org.junit.jupiter.api.Disabled; |
| 7 | 9 | import org.junit.jupiter.api.Test; |
| 8 | 10 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/local/LocalFileClientTest.java renamed to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/local/LocalFileClientTest.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.local; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.local; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.resource.ResourceUtil; |
| 4 | 4 | import cn.hutool.core.util.IdUtil; |
| 5 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClient; | |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClientConfig; | |
| 5 | 7 | import org.junit.jupiter.api.Disabled; |
| 6 | 8 | import org.junit.jupiter.api.Test; |
| 7 | 9 | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java renamed to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/s3/S3FileClientTest.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.s3; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.s3; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.resource.ResourceUtil; |
| 4 | 4 | import cn.hutool.core.util.IdUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClient; | |
| 7 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClientConfig; | |
| 8 | +import jakarta.validation.Validation; | |
| 6 | 9 | import org.junit.jupiter.api.Disabled; |
| 7 | 10 | import org.junit.jupiter.api.Test; |
| 8 | 11 | |
| 9 | -import jakarta.validation.Validation; | |
| 10 | - | |
| 11 | 12 | public class S3FileClientTest { |
| 12 | 13 | |
| 13 | 14 | @Test | ... | ... |
yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/sftp/SftpFileClientTest.java renamed to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/framework/file/core/sftp/SftpFileClientTest.java
| 1 | -package cn.iocoder.yudao.framework.file.core.client.sftp; | |
| 1 | +package cn.iocoder.yudao.module.infra.framework.file.core.sftp; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.resource.ResourceUtil; |
| 4 | 4 | import cn.hutool.core.util.IdUtil; |
| 5 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.sftp.SftpFileClient; | |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.sftp.SftpFileClientConfig; | |
| 5 | 7 | import org.junit.jupiter.api.Disabled; |
| 6 | 8 | import org.junit.jupiter.api.Test; |
| 7 | 9 | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java
| ... | ... | @@ -4,12 +4,12 @@ import cn.hutool.core.date.DatePattern; |
| 4 | 4 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 5 | 5 | import cn.hutool.core.map.MapUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | -import cn.iocoder.yudao.framework.file.core.client.FileClient; | |
| 8 | -import cn.iocoder.yudao.framework.file.core.client.FileClientConfig; | |
| 9 | -import cn.iocoder.yudao.framework.file.core.client.FileClientFactory; | |
| 10 | -import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClient; | |
| 11 | -import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClientConfig; | |
| 12 | -import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum; | |
| 7 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; | |
| 8 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientConfig; | |
| 9 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClientFactory; | |
| 10 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClient; | |
| 11 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.local.LocalFileClientConfig; | |
| 12 | +import cn.iocoder.yudao.module.infra.framework.file.core.enums.FileStorageEnum; | |
| 13 | 13 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 14 | 14 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO; |
| 15 | 15 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO; | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.infra.service.file; |
| 3 | 3 | import cn.hutool.core.io.resource.ResourceUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 6 | -import cn.iocoder.yudao.framework.file.core.client.FileClient; | |
| 6 | +import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; | |
| 7 | 7 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 8 | 8 | import cn.iocoder.yudao.framework.test.core.util.AssertUtils; |
| 9 | 9 | import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; | ... | ... |