From a33b41345608537e4142234233073514e4cbf120 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Sun, 2 Jan 2022 20:56:21 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=907.1.6=E3=80=91=E3=80=90file=E3=80=91?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E5=AD=98=E5=82=A8=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stylefeng/roses/kernel/file/api/FileOperatorApi.java | 9 +++++++++ .../kernel/file/modular/factory/FileInfoFactory.java | 3 +-- .../roses/kernel/file/aliyun/AliyunFileOperator.java | 6 ++++++ .../roses/kernel/file/local/LocalFileOperator.java | 7 +++++++ .../roses/kernel/file/minio/MinIoFileOperator.java | 6 ++++++ .../roses/kernel/file/tencent/TenFileOperator.java | 6 ++++++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/kernel-d-file/file-api/src/main/java/cn/stylefeng/roses/kernel/file/api/FileOperatorApi.java b/kernel-d-file/file-api/src/main/java/cn/stylefeng/roses/kernel/file/api/FileOperatorApi.java index 9f0d5c989..b6d16cb41 100644 --- a/kernel-d-file/file-api/src/main/java/cn/stylefeng/roses/kernel/file/api/FileOperatorApi.java +++ b/kernel-d-file/file-api/src/main/java/cn/stylefeng/roses/kernel/file/api/FileOperatorApi.java @@ -25,6 +25,7 @@ package cn.stylefeng.roses.kernel.file.api; import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum; +import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum; import java.io.InputStream; @@ -188,4 +189,12 @@ public interface FileOperatorApi { */ void deleteFile(String bucketName, String key); + /** + * 获取当前api的文件存储类型 + * + * @author fengshuonan + * @date 2022/1/2 20:50 + */ + FileLocationEnum getFileLocationEnum(); + } diff --git a/kernel-d-file/file-business/src/main/java/cn/stylefeng/roses/kernel/file/modular/factory/FileInfoFactory.java b/kernel-d-file/file-business/src/main/java/cn/stylefeng/roses/kernel/file/modular/factory/FileInfoFactory.java index ae4d33049..af8e095f2 100644 --- a/kernel-d-file/file-business/src/main/java/cn/stylefeng/roses/kernel/file/modular/factory/FileInfoFactory.java +++ b/kernel-d-file/file-business/src/main/java/cn/stylefeng/roses/kernel/file/modular/factory/FileInfoFactory.java @@ -31,7 +31,6 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import cn.stylefeng.roses.kernel.file.api.FileOperatorApi; -import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum; import cn.stylefeng.roses.kernel.file.api.enums.FileStatusEnum; import cn.stylefeng.roses.kernel.file.api.exception.FileException; import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum; @@ -103,7 +102,7 @@ public class FileInfoFactory { // 封装存储文件信息(上传替换公共信息) SysFileInfo sysFileInfo = new SysFileInfo(); sysFileInfo.setFileId(fileId); - sysFileInfo.setFileLocation(FileLocationEnum.LOCAL.getCode()); + sysFileInfo.setFileLocation(fileOperatorApi.getFileLocationEnum().getCode()); sysFileInfo.setFileBucket(fileBucket); sysFileInfo.setFileObjectName(finalFileName); sysFileInfo.setFileOriginName(originalFilename); diff --git a/kernel-d-file/file-sdk-aliyun/src/main/java/cn/stylefeng/roses/kernel/file/aliyun/AliyunFileOperator.java b/kernel-d-file/file-sdk-aliyun/src/main/java/cn/stylefeng/roses/kernel/file/aliyun/AliyunFileOperator.java index 6762d2ac5..5d0b37fe1 100644 --- a/kernel-d-file/file-sdk-aliyun/src/main/java/cn/stylefeng/roses/kernel/file/aliyun/AliyunFileOperator.java +++ b/kernel-d-file/file-sdk-aliyun/src/main/java/cn/stylefeng/roses/kernel/file/aliyun/AliyunFileOperator.java @@ -28,6 +28,7 @@ import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; import cn.stylefeng.roses.kernel.file.api.FileOperatorApi; import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum; +import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum; import cn.stylefeng.roses.kernel.file.api.exception.FileException; import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum; import cn.stylefeng.roses.kernel.file.api.pojo.props.AliyunOssProperties; @@ -209,4 +210,9 @@ public class AliyunFileOperator implements FileOperatorApi { ossClient.deleteObject(bucketName, key); } + @Override + public FileLocationEnum getFileLocationEnum() { + return FileLocationEnum.ALIYUN; + } + } diff --git a/kernel-d-file/file-sdk-local/src/main/java/cn/stylefeng/roses/kernel/file/local/LocalFileOperator.java b/kernel-d-file/file-sdk-local/src/main/java/cn/stylefeng/roses/kernel/file/local/LocalFileOperator.java index af3c94e81..b4f8a846c 100644 --- a/kernel-d-file/file-sdk-local/src/main/java/cn/stylefeng/roses/kernel/file/local/LocalFileOperator.java +++ b/kernel-d-file/file-sdk-local/src/main/java/cn/stylefeng/roses/kernel/file/local/LocalFileOperator.java @@ -31,6 +31,7 @@ import cn.stylefeng.roses.kernel.auth.api.context.LoginContext; import cn.stylefeng.roses.kernel.file.api.FileOperatorApi; import cn.stylefeng.roses.kernel.file.api.constants.FileConstants; import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum; +import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum; import cn.stylefeng.roses.kernel.file.api.exception.FileException; import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum; import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander; @@ -199,4 +200,10 @@ public class LocalFileOperator implements FileOperatorApi { FileUtil.del(file); } + + @Override + public FileLocationEnum getFileLocationEnum() { + return FileLocationEnum.LOCAL; + } + } diff --git a/kernel-d-file/file-sdk-minio/src/main/java/cn/stylefeng/roses/kernel/file/minio/MinIoFileOperator.java b/kernel-d-file/file-sdk-minio/src/main/java/cn/stylefeng/roses/kernel/file/minio/MinIoFileOperator.java index 21a384332..cedd64d2d 100644 --- a/kernel-d-file/file-sdk-minio/src/main/java/cn/stylefeng/roses/kernel/file/minio/MinIoFileOperator.java +++ b/kernel-d-file/file-sdk-minio/src/main/java/cn/stylefeng/roses/kernel/file/minio/MinIoFileOperator.java @@ -31,6 +31,7 @@ import cn.stylefeng.roses.kernel.auth.api.context.LoginContext; import cn.stylefeng.roses.kernel.file.api.FileOperatorApi; import cn.stylefeng.roses.kernel.file.api.constants.FileConstants; import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum; +import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum; import cn.stylefeng.roses.kernel.file.api.exception.FileException; import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum; import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander; @@ -233,6 +234,11 @@ public class MinIoFileOperator implements FileOperatorApi { } + @Override + public FileLocationEnum getFileLocationEnum() { + return FileLocationEnum.MINIO; + } + /** * 获取文件后缀对应的contentType * diff --git a/kernel-d-file/file-sdk-tencent/src/main/java/cn/stylefeng/roses/kernel/file/tencent/TenFileOperator.java b/kernel-d-file/file-sdk-tencent/src/main/java/cn/stylefeng/roses/kernel/file/tencent/TenFileOperator.java index 7160720ec..36240dd8b 100644 --- a/kernel-d-file/file-sdk-tencent/src/main/java/cn/stylefeng/roses/kernel/file/tencent/TenFileOperator.java +++ b/kernel-d-file/file-sdk-tencent/src/main/java/cn/stylefeng/roses/kernel/file/tencent/TenFileOperator.java @@ -28,6 +28,7 @@ import cn.hutool.core.io.IoUtil; import cn.hutool.core.thread.ExecutorBuilder; import cn.stylefeng.roses.kernel.file.api.FileOperatorApi; import cn.stylefeng.roses.kernel.file.api.enums.BucketAuthEnum; +import cn.stylefeng.roses.kernel.file.api.enums.FileLocationEnum; import cn.stylefeng.roses.kernel.file.api.exception.FileException; import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum; import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander; @@ -261,4 +262,9 @@ public class TenFileOperator implements FileOperatorApi { cosClient.deleteObject(bucketName, key); } + @Override + public FileLocationEnum getFileLocationEnum() { + return FileLocationEnum.TENCENT; + } + }