From 20da336a0cbbe63e84a68c1702d7e9f2b4c064af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B0=8F=E4=B8=8D=E7=8B=BC=E7=8B=88?= <258392906@qq.com> Date: Fri, 15 Mar 2024 17:16:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=B5=84=E6=BA=90=E5=89=8D?= =?UTF-8?q?=E7=BC=80=E6=98=AF=E5=90=A6=E4=B8=BAhttps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.给缓存增加过期时间,并且和第三方存储资源 过期时间保持一致 --- .../file/api/pojo/props/AliyunOssProperties.java | 5 +++++ .../roses/kernel/file/aliyun/AliyunFileOperator.java | 12 ++++++------ .../theme/service/impl/SysThemeServiceImpl.java | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/kernel-d-file/file-api/src/main/java/cn/stylefeng/roses/kernel/file/api/pojo/props/AliyunOssProperties.java b/kernel-d-file/file-api/src/main/java/cn/stylefeng/roses/kernel/file/api/pojo/props/AliyunOssProperties.java index ff00462a1..e9fa2f042 100644 --- a/kernel-d-file/file-api/src/main/java/cn/stylefeng/roses/kernel/file/api/pojo/props/AliyunOssProperties.java +++ b/kernel-d-file/file-api/src/main/java/cn/stylefeng/roses/kernel/file/api/pojo/props/AliyunOssProperties.java @@ -52,4 +52,9 @@ public class AliyunOssProperties { */ private String accessKeySecret; + /** + * 获取资源前缀是否为https + */ + private Boolean isHttps = false; + } 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 ad9a410b6..a5b98d9e9 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 @@ -32,10 +32,8 @@ 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; import cn.stylefeng.roses.kernel.file.api.pojo.props.AliyunOssProperties; -import com.aliyun.oss.ClientException; -import com.aliyun.oss.OSS; -import com.aliyun.oss.OSSClientBuilder; -import com.aliyun.oss.OSSException; +import com.aliyun.oss.*; +import com.aliyun.oss.common.comm.Protocol; import com.aliyun.oss.model.CannedAccessControlList; import com.aliyun.oss.model.OSSObject; import com.aliyun.oss.model.PutObjectRequest; @@ -73,9 +71,11 @@ public class AliyunFileOperator implements FileOperatorApi { String endpoint = aliyunOssProperties.getEndPoint(); String accessKeyId = aliyunOssProperties.getAccessKeyId(); String accessKeySecret = aliyunOssProperties.getAccessKeySecret(); - + Boolean isHttps = aliyunOssProperties.getIsHttps(); + ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration(); + clientBuilderConfiguration.setProtocol(isHttps ? Protocol.HTTPS : Protocol.HTTP); // 创建OSSClient实例。 - ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); + ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret, clientBuilderConfiguration); } @Override diff --git a/kernel-s-system/system-business-portal/src/main/java/cn/stylefeng/roses/kernel/sys/modular/theme/service/impl/SysThemeServiceImpl.java b/kernel-s-system/system-business-portal/src/main/java/cn/stylefeng/roses/kernel/sys/modular/theme/service/impl/SysThemeServiceImpl.java index fbc7c8375..ffff0dedc 100644 --- a/kernel-s-system/system-business-portal/src/main/java/cn/stylefeng/roses/kernel/sys/modular/theme/service/impl/SysThemeServiceImpl.java +++ b/kernel-s-system/system-business-portal/src/main/java/cn/stylefeng/roses/kernel/sys/modular/theme/service/impl/SysThemeServiceImpl.java @@ -10,6 +10,7 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory; import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity; import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; import cn.stylefeng.roses.kernel.file.api.FileInfoApi; +import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander; import cn.stylefeng.roses.kernel.file.api.pojo.AntdvFileInfo; import cn.stylefeng.roses.kernel.file.api.pojo.request.SysFileInfoRequest; import cn.stylefeng.roses.kernel.rule.callback.ConfigUpdateCallback; @@ -247,7 +248,7 @@ public class SysThemeServiceImpl extends ServiceImpl i this.parseFileUrls(result); // 缓存系统中激活的主题 - themeCacheApi.put(ThemeConstants.THEME_GUNS_PLATFORM, result); + themeCacheApi.put(ThemeConstants.THEME_GUNS_PLATFORM, result, FileConfigExpander.getDefaultFileTimeoutSeconds()); return result; }