cf-framework:file移到cf-module-infra-biz

This commit is contained in:
gaoqr
2025-07-17 15:32:47 +08:00
parent 66b42db3c6
commit b978b895d3
43 changed files with 146 additions and 470 deletions
-5
View File
@@ -638,11 +638,6 @@
<artifactId>okhttp</artifactId>
<version>${okhttp3.version}</version>
</dependency>
<dependency>
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-file</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
@@ -1,82 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cf-framework</artifactId>
<groupId>com.cf.imes</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cf-spring-boot-starter-file</artifactId>
<name>${project.artifactId}</name>
<description>文件客户端,支持多种存储器
1. file:本地磁盘
2. ftpFTP 服务器
2. sftpSFTP 服务器
4. db:数据库
5. s3:支持 S3 协议的云存储服务,例如说 MinIO、阿里云、华为云、腾讯云、七牛云等等
</description>
<dependencies>
<dependency>
<groupId>com.cf.imes</groupId>
<artifactId>cf-common</artifactId>
</dependency>
<!-- Spring 核心 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId> <!-- 解决 ftp 连接 -->
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId> <!-- 解决 sftp 连接 -->
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId> <!-- 文件类型的识别 -->
</dependency>
<!-- 三方云服务相关 -->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -1,21 +0,0 @@
package com.cf.imes.framework.file.config;
import com.cf.imes.framework.file.core.client.FileClientFactory;
import com.cf.imes.framework.file.core.client.FileClientFactoryImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
/**
* 文件配置类
*
* @author 晨丰科技
*/
@AutoConfiguration
public class ChenfengFileAutoConfiguration {
@Bean
public FileClientFactory fileClientFactory() {
return new FileClientFactoryImpl();
}
}
@@ -1,55 +0,0 @@
package com.cf.imes.framework.file.core.enums;
import cn.hutool.core.util.ArrayUtil;
import com.cf.imes.framework.file.core.client.FileClient;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.framework.file.core.client.db.DBFileClient;
import com.cf.imes.framework.file.core.client.db.DBFileClientConfig;
import com.cf.imes.framework.file.core.client.ftp.FtpFileClient;
import com.cf.imes.framework.file.core.client.ftp.FtpFileClientConfig;
import com.cf.imes.framework.file.core.client.local.LocalFileClient;
import com.cf.imes.framework.file.core.client.local.LocalFileClientConfig;
import com.cf.imes.framework.file.core.client.s3.S3FileClient;
import com.cf.imes.framework.file.core.client.s3.S3FileClientConfig;
import com.cf.imes.framework.file.core.client.sftp.SftpFileClient;
import com.cf.imes.framework.file.core.client.sftp.SftpFileClientConfig;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 文件存储器枚举
*
* @author 晨丰科技
*/
@AllArgsConstructor
@Getter
public enum FileStorageEnum {
DB(1, DBFileClientConfig.class, DBFileClient.class),
LOCAL(10, LocalFileClientConfig.class, LocalFileClient.class),
FTP(11, FtpFileClientConfig.class, FtpFileClient.class),
SFTP(12, SftpFileClientConfig.class, SftpFileClient.class),
S3(20, S3FileClientConfig.class, S3FileClient.class),
;
/**
* 存储器
*/
private final Integer storage;
/**
* 配置类
*/
private final Class<? extends FileClientConfig> configClass;
/**
* 客户端类
*/
private final Class<? extends FileClient> clientClass;
public static FileStorageEnum getByStorage(Integer storage) {
return ArrayUtil.firstMatch(o -> o.getStorage().equals(storage), values());
}
}
@@ -1 +0,0 @@
com.cf.imes.framework.file.config.ChenfengFileAutoConfiguration
@@ -1,4 +0,0 @@
/**
* 占位,避免 package 无法提交到 Git 仓库
*/
package com.cf.imes.framework.file.config;
@@ -1,43 +0,0 @@
package com.cf.imes.framework.file.core.client.ftp;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.extra.ftp.FtpMode;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class FtpFileClientTest {
@Test
@Disabled
public void test() {
// 创建客户端
FtpFileClientConfig config = new FtpFileClientConfig();
config.setDomain("http://127.0.0.1:48080");
config.setBasePath("/home/ftp");
config.setHost("kanchai.club");
config.setPort(221);
config.setUsername("");
config.setPassword("");
config.setMode(FtpMode.Passive.name());
FtpFileClient client = new FtpFileClient(0L, config);
assertNotNull(client);
client.init();
// 上传文件
String path = IdUtil.fastSimpleUUID() + ".jpg";
byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
String fullPath = client.upload(content, path, "image/jpeg");
assertNotNull(fullPath);
System.out.println("访问地址:" + fullPath);
if (false) {
byte[] bytes = client.getContent(path);
System.out.println("文件内容:" + bytes);
}
if (false) {
client.delete(path);
}
}
}
@@ -1,31 +0,0 @@
package com.cf.imes.framework.file.core.client.local;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.IdUtil;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class LocalFileClientTest {
@Test
@Disabled
public void test() {
// 创建客户端
LocalFileClientConfig config = new LocalFileClientConfig();
config.setDomain("http://127.0.0.1:48080");
config.setBasePath("/Users/yunai/file_test");
LocalFileClient client = new LocalFileClient(0L, config);
assertNotNull(client);
client.init();
// 上传文件
String path = IdUtil.fastSimpleUUID() + ".jpg";
byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
String fullPath = client.upload(content, path, "image/jpeg");
assertNotNull(fullPath);
System.out.println("访问地址:" + fullPath);
client.delete(path);
}
}
@@ -1,117 +0,0 @@
package com.cf.imes.framework.file.core.client.s3;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.IdUtil;
import com.cf.imes.framework.common.util.validation.ValidationUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import javax.validation.Validation;
public class S3FileClientTest {
@Test
@Disabled // MinIO,如果要集成测试,可以注释本行
public void testMinIO() throws Exception {
S3FileClientConfig config = new S3FileClientConfig();
// 配置成你自己的
config.setAccessKey("admin");
config.setAccessSecret("password");
config.setBucket("chenfengyuanma");
config.setDomain(null);
// 默认 9000 endpoint
config.setEndpoint("http://127.0.0.1:9000");
// 执行上传
testExecuteUpload(config);
}
@Test
@Disabled // 阿里云 OSS,如果要集成测试,可以注释本行
public void testAliyun() throws Exception {
S3FileClientConfig config = new S3FileClientConfig();
// 配置成你自己的
config.setAccessKey(System.getenv("ALIYUN_ACCESS_KEY"));
config.setAccessSecret(System.getenv("ALIYUN_SECRET_KEY"));
config.setBucket("yunai-aoteman");
config.setDomain(null); // 如果有自定义域名,则可以设置。http://ali-oss.iocoder.cn
// 默认北京的 endpoint
config.setEndpoint("oss-cn-beijing.aliyuncs.com");
// 执行上传
testExecuteUpload(config);
}
@Test
@Disabled // 腾讯云 COS,如果要集成测试,可以注释本行
public void testQCloud() throws Exception {
S3FileClientConfig config = new S3FileClientConfig();
// 配置成你自己的
config.setAccessKey(System.getenv("QCLOUD_ACCESS_KEY"));
config.setAccessSecret(System.getenv("QCLOUD_SECRET_KEY"));
config.setBucket("aoteman-1255880240");
config.setDomain(null); // 如果有自定义域名,则可以设置。http://tengxun-oss.iocoder.cn
// 默认上海的 endpoint
config.setEndpoint("cos.ap-shanghai.myqcloud.com");
// 执行上传
testExecuteUpload(config);
}
@Test
@Disabled // 七牛云存储,如果要集成测试,可以注释本行
public void testQiniu() throws Exception {
S3FileClientConfig config = new S3FileClientConfig();
// 配置成你自己的
// config.setAccessKey(System.getenv("QINIU_ACCESS_KEY"));
// config.setAccessSecret(System.getenv("QINIU_SECRET_KEY"));
config.setAccessKey("b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8");
config.setAccessSecret("kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP");
config.setBucket("ruoyi-vue-pro");
config.setDomain("http://test.chenfeng.iocoder.cn"); // 如果有自定义域名,则可以设置。http://static.chenfeng.iocoder.cn
// 默认上海的 endpoint
config.setEndpoint("s3-cn-south-1.qiniucs.com");
// 执行上传
testExecuteUpload(config);
}
@Test
@Disabled // 华为云存储,如果要集成测试,可以注释本行
public void testHuaweiCloud() throws Exception {
S3FileClientConfig config = new S3FileClientConfig();
// 配置成你自己的
// config.setAccessKey(System.getenv("HUAWEI_CLOUD_ACCESS_KEY"));
// config.setAccessSecret(System.getenv("HUAWEI_CLOUD_SECRET_KEY"));
config.setBucket("chenfeng");
config.setDomain(null); // 如果有自定义域名,则可以设置。
// 默认上海的 endpoint
config.setEndpoint("obs.cn-east-3.myhuaweicloud.com");
// 执行上传
testExecuteUpload(config);
}
private void testExecuteUpload(S3FileClientConfig config) throws Exception {
// 校验配置
ValidationUtils.validate(Validation.buildDefaultValidatorFactory().getValidator(), config);
// 创建 Client
S3FileClient client = new S3FileClient(0L, config);
client.init();
// 上传文件
String path = IdUtil.fastSimpleUUID() + ".jpg";
byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
String fullPath = client.upload(content, path, "image/jpeg");
System.out.println("访问地址:" + fullPath);
// 读取文件
if (true) {
byte[] bytes = client.getContent(path);
System.out.println("文件内容:" + bytes.length);
}
// 删除文件
if (false) {
client.delete(path);
}
}
}
@@ -1,41 +0,0 @@
package com.cf.imes.framework.file.core.client.sftp;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.IdUtil;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class SftpFileClientTest {
@Test
@Disabled
public void test() {
// 创建客户端
SftpFileClientConfig config = new SftpFileClientConfig();
config.setDomain("http://127.0.0.1:48080");
config.setBasePath("/home/ftp");
config.setHost("kanchai.club");
config.setPort(222);
config.setUsername("");
config.setPassword("");
SftpFileClient client = new SftpFileClient(0L, config);
assertNotNull(client);
client.init();
// 上传文件
String path = IdUtil.fastSimpleUUID() + ".jpg";
byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
String fullPath = client.upload(content, path, "image/jpeg");
assertNotNull(fullPath);
System.out.println("访问地址:" + fullPath);
if (false) {
byte[] bytes = client.getContent(path);
System.out.println("文件内容:" + bytes);
}
if (false) {
client.delete(path);
}
}
}
@@ -1,4 +0,0 @@
/**
* 占位,避免 package 无法提交到 Git 仓库
*/
package com.cf.imes.framework.file.core.enums;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

-1
View File
@@ -17,7 +17,6 @@
<module>cf-spring-boot-starter-web</module>
<module>cf-spring-boot-starter-security</module>
<module>cf-spring-boot-starter-file</module>
<module>cf-spring-boot-starter-monitor</module>
<module>cf-spring-boot-starter-protection</module>
<!-- <module>cf-spring-boot-starter-config</module>-->
+15 -6
View File
@@ -139,8 +139,21 @@
<!-- 三方云服务相关 -->
<dependency>
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-file</artifactId>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId> <!-- 文件客户端:解决 ftp 连接 -->
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId> <!-- 文件客户端:解决 sftp 连接 -->
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId> <!-- 文件客户端:解决阿里云、腾讯云、minio 等 S3 连接 -->
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId> <!-- 文件客户端:文件类型的识别 -->
</dependency>
</dependencies>
@@ -180,10 +193,6 @@
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-excel</artifactId>
</include>
<include>
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-file</artifactId>
</include>
<include>
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-monitor</artifactId>
@@ -1,6 +1,6 @@
package com.cf.imes.module.infra.controller.admin.file.vo.config;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -1,7 +1,7 @@
package com.cf.imes.module.infra.dal.dataobject.file;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.framework.file.core.enums.FileStorageEnum;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.enums.FileStorageEnum;
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cf.imes.framework.file.core.client.db.DBFileClient;
import com.cf.imes.module.infra.framework.file.core.client.db.DBFileClient;
import lombok.*;
/**
@@ -1,7 +1,7 @@
package com.cf.imes.module.infra.dal.mysql.file;
import cn.hutool.core.collection.CollUtil;
import com.cf.imes.framework.file.core.client.db.DBFileContentFrameworkDAO;
import com.cf.imes.module.infra.framework.file.core.client.db.DBFileContentFrameworkDAO;
import com.cf.imes.module.infra.dal.dataobject.file.FileContentDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Repository;
@@ -0,0 +1,21 @@
package com.cf.imes.module.infra.framework.file.config;
import com.cf.imes.module.infra.framework.file.core.client.FileClientFactory;
import com.cf.imes.module.infra.framework.file.core.client.FileClientFactoryImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* 文件配置类
*
* @author 晨丰科技
*/
@Configuration(proxyBeanMethods = false)
public class ChenfengFileAutoConfiguration {
@Bean
public FileClientFactory fileClientFactory() {
return new FileClientFactoryImpl();
}
}
@@ -1,4 +1,4 @@
package com.cf.imes.framework.file.core.client;
package com.cf.imes.module.infra.framework.file.core.client;
import cn.hutool.core.text.CharSequenceUtil;
import lombok.extern.slf4j.Slf4j;
@@ -1,4 +1,4 @@
package com.cf.imes.framework.file.core.client;
package com.cf.imes.module.infra.framework.file.core.client;
/**
* 文件客户端
@@ -1,4 +1,4 @@
package com.cf.imes.framework.file.core.client;
package com.cf.imes.module.infra.framework.file.core.client;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@@ -1,6 +1,6 @@
package com.cf.imes.framework.file.core.client;
package com.cf.imes.module.infra.framework.file.core.client;
import com.cf.imes.framework.file.core.enums.FileStorageEnum;
import com.cf.imes.module.infra.framework.file.core.enums.FileStorageEnum;
public interface FileClientFactory {
@@ -1,8 +1,8 @@
package com.cf.imes.framework.file.core.client;
package com.cf.imes.module.infra.framework.file.core.client;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ReflectUtil;
import com.cf.imes.framework.file.core.enums.FileStorageEnum;
import com.cf.imes.module.infra.framework.file.core.enums.FileStorageEnum;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ConcurrentHashMap;
@@ -1,7 +1,7 @@
package com.cf.imes.framework.file.core.client.db;
package com.cf.imes.module.infra.framework.file.core.client.db;
import cn.hutool.extra.spring.SpringUtil;
import com.cf.imes.framework.file.core.client.AbstractFileClient;
import com.cf.imes.module.infra.framework.file.core.client.AbstractFileClient;
/**
* 基于 DB 存储的文件客户端的配置类
@@ -1,6 +1,6 @@
package com.cf.imes.framework.file.core.client.db;
package com.cf.imes.module.infra.framework.file.core.client.db;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
@@ -1,4 +1,4 @@
package com.cf.imes.framework.file.core.client.db;
package com.cf.imes.module.infra.framework.file.core.client.db;
/**
* 文件内容 Framework DAO 接口
@@ -1,4 +1,4 @@
package com.cf.imes.framework.file.core.client.ftp;
package com.cf.imes.module.infra.framework.file.core.client.ftp;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.CharSequenceUtil;
@@ -7,7 +7,7 @@ import cn.hutool.core.util.CharsetUtil;
import cn.hutool.extra.ftp.Ftp;
import cn.hutool.extra.ftp.FtpException;
import cn.hutool.extra.ftp.FtpMode;
import com.cf.imes.framework.file.core.client.AbstractFileClient;
import com.cf.imes.module.infra.framework.file.core.client.AbstractFileClient;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -1,6 +1,6 @@
package com.cf.imes.framework.file.core.client.ftp;
package com.cf.imes.module.infra.framework.file.core.client.ftp;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
@@ -1,7 +1,7 @@
package com.cf.imes.framework.file.core.client.local;
package com.cf.imes.module.infra.framework.file.core.client.local;
import cn.hutool.core.io.FileUtil;
import com.cf.imes.framework.file.core.client.AbstractFileClient;
import com.cf.imes.module.infra.framework.file.core.client.AbstractFileClient;
import java.io.File;
@@ -1,6 +1,6 @@
package com.cf.imes.framework.file.core.client.local;
package com.cf.imes.module.infra.framework.file.core.client.local;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
@@ -1,15 +1,19 @@
package com.cf.imes.framework.file.core.client.s3;
package com.cf.imes.module.infra.framework.file.core.client.s3;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.http.HttpUtil;
import com.cf.imes.framework.file.core.client.AbstractFileClient;
import io.minio.*;
import com.cf.imes.module.infra.framework.file.core.client.AbstractFileClient;
import io.minio.GetObjectArgs;
import io.minio.GetObjectResponse;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import io.minio.RemoveObjectArgs;
import java.io.ByteArrayInputStream;
import static com.cf.imes.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_ALIYUN;
import static com.cf.imes.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_TENCENT;
import static com.cf.imes.module.infra.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_ALIYUN;
import static com.cf.imes.module.infra.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_TENCENT;
/**
* 基于 S3 协议的文件客户端实现 MinIO阿里云腾讯云七牛云华为云等云服务
@@ -1,7 +1,7 @@
package com.cf.imes.framework.file.core.client.s3;
package com.cf.imes.module.infra.framework.file.core.client.s3;
import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
@@ -1,9 +1,9 @@
package com.cf.imes.framework.file.core.client.sftp;
package com.cf.imes.module.infra.framework.file.core.client.sftp;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.ssh.Sftp;
import com.cf.imes.framework.common.util.io.FileUtils;
import com.cf.imes.framework.file.core.client.AbstractFileClient;
import com.cf.imes.module.infra.framework.file.core.client.AbstractFileClient;
import java.io.File;
@@ -1,6 +1,6 @@
package com.cf.imes.framework.file.core.client.sftp;
package com.cf.imes.module.infra.framework.file.core.client.sftp;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
@@ -0,0 +1,55 @@
package com.cf.imes.module.infra.framework.file.core.enums;
import cn.hutool.core.util.ArrayUtil;
import com.cf.imes.module.infra.framework.file.core.client.FileClient;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.db.DBFileClient;
import com.cf.imes.module.infra.framework.file.core.client.db.DBFileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.ftp.FtpFileClient;
import com.cf.imes.module.infra.framework.file.core.client.ftp.FtpFileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.local.LocalFileClient;
import com.cf.imes.module.infra.framework.file.core.client.local.LocalFileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.s3.S3FileClient;
import com.cf.imes.module.infra.framework.file.core.client.s3.S3FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.sftp.SftpFileClient;
import com.cf.imes.module.infra.framework.file.core.client.sftp.SftpFileClientConfig;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 文件存储器枚举
*
* @author 晨丰科技
*/
@AllArgsConstructor
@Getter
public enum FileStorageEnum {
DB(1, DBFileClientConfig.class, DBFileClient.class),
LOCAL(10, LocalFileClientConfig.class, LocalFileClient.class),
FTP(11, FtpFileClientConfig.class, FtpFileClient.class),
SFTP(12, SftpFileClientConfig.class, SftpFileClient.class),
S3(20, S3FileClientConfig.class, S3FileClient.class),
;
/**
* 存储器
*/
private final Integer storage;
/**
* 配置类
*/
private final Class<? extends FileClientConfig> configClass;
/**
* 客户端类
*/
private final Class<? extends FileClient> clientClass;
public static FileStorageEnum getByStorage(Integer storage) {
return ArrayUtil.firstMatch(o -> o.getStorage().equals(storage), values());
}
}
@@ -1,4 +1,4 @@
package com.cf.imes.framework.file.core.utils;
package com.cf.imes.module.infra.framework.file.core.utils;
import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.SneakyThrows;
@@ -1,7 +1,7 @@
package com.cf.imes.module.infra.service.file;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.file.core.client.FileClient;
import com.cf.imes.module.infra.framework.file.core.client.FileClient;
import com.cf.imes.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.cf.imes.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.cf.imes.module.infra.dal.dataobject.file.FileConfigDO;
@@ -5,10 +5,10 @@ import cn.hutool.core.util.IdUtil;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.json.JsonUtils;
import com.cf.imes.framework.common.util.validation.ValidationUtils;
import com.cf.imes.framework.file.core.client.FileClient;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.framework.file.core.client.FileClientFactory;
import com.cf.imes.framework.file.core.enums.FileStorageEnum;
import com.cf.imes.module.infra.framework.file.core.client.FileClient;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.FileClientFactory;
import com.cf.imes.module.infra.framework.file.core.enums.FileStorageEnum;
import com.cf.imes.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.cf.imes.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
import com.cf.imes.module.infra.convert.file.FileConfigConvert;
@@ -4,8 +4,8 @@ import cn.hutool.core.lang.Assert;
import cn.hutool.core.text.CharSequenceUtil;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.io.FileUtils;
import com.cf.imes.framework.file.core.client.FileClient;
import com.cf.imes.framework.file.core.utils.FileTypeUtils;
import com.cf.imes.module.infra.framework.file.core.client.FileClient;
import com.cf.imes.module.infra.framework.file.core.utils.FileTypeUtils;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.infra.controller.admin.file.vo.file.FilePageReqVO;
import com.cf.imes.module.infra.dal.dataobject.file.FileDO;
@@ -4,12 +4,12 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.map.MapUtil;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.file.core.client.FileClient;
import com.cf.imes.framework.file.core.client.FileClientConfig;
import com.cf.imes.framework.file.core.client.FileClientFactory;
import com.cf.imes.framework.file.core.client.local.LocalFileClient;
import com.cf.imes.framework.file.core.client.local.LocalFileClientConfig;
import com.cf.imes.framework.file.core.enums.FileStorageEnum;
import com.cf.imes.module.infra.framework.file.core.client.FileClient;
import com.cf.imes.module.infra.framework.file.core.client.FileClientConfig;
import com.cf.imes.module.infra.framework.file.core.client.FileClientFactory;
import com.cf.imes.module.infra.framework.file.core.client.local.LocalFileClient;
import com.cf.imes.module.infra.framework.file.core.client.local.LocalFileClientConfig;
import com.cf.imes.module.infra.framework.file.core.enums.FileStorageEnum;
import com.cf.imes.framework.test.core.ut.BaseDbUnitTest;
import com.cf.imes.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
import com.cf.imes.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
@@ -3,7 +3,7 @@ package com.cf.imes.module.infra.service.file;
import cn.hutool.core.io.resource.ResourceUtil;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.object.ObjectUtils;
import com.cf.imes.framework.file.core.client.FileClient;
import com.cf.imes.module.infra.framework.file.core.client.FileClient;
import com.cf.imes.framework.test.core.ut.BaseDbUnitTest;
import com.cf.imes.framework.test.core.util.AssertUtils;
import com.cf.imes.module.infra.controller.admin.file.vo.file.FilePageReqVO;
@@ -117,10 +117,6 @@
<!-- 实现 Spring Boot Admin Server 服务端 -->
</dependency>
<!-- 三方云服务相关 -->
<dependency>
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-file</artifactId>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
@@ -240,10 +236,6 @@
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-excel</artifactId>
</include>
<include>
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-file</artifactId>
</include>
<include>
<groupId>com.cf.imes</groupId>
<artifactId>cf-spring-boot-starter-monitor</artifactId>