From 7cc4f67b515cff777ebb9dfda633658addbcbd12 Mon Sep 17 00:00:00 2001 From: smallchill Date: Tue, 28 May 2024 18:31:48 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E6=96=B0=E5=A2=9Eoss=E5=86=85=E7=BD=91?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=90=8E=E8=BD=AC=E6=8D=A2=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=A4=96=E7=BD=91=E5=9C=B0=E5=9D=80=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/controller.java.vm | 2 +- .../springblade/core/oss/AliossTemplate.java | 18 +++++++++++++++-- .../springblade/core/oss/MinioTemplate.java | 20 ++++++++++++++++--- .../springblade/core/oss/QiniuTemplate.java | 20 ++++++++++++++++--- .../core/oss/props/OssProperties.java | 5 +++++ 5 files changed, 56 insertions(+), 9 deletions(-) diff --git a/blade-core-develop/src/main/resources/templates/controller.java.vm b/blade-core-develop/src/main/resources/templates/controller.java.vm index 9471288..e479ef9 100644 --- a/blade-core-develop/src/main/resources/templates/controller.java.vm +++ b/blade-core-develop/src/main/resources/templates/controller.java.vm @@ -54,7 +54,7 @@ import $!{superControllerClassPackage}; @RestController @AllArgsConstructor @RequestMapping("#if($!{hasServiceName})/$!{serviceName}#end/$!{entityKey}") -@Tag(name = "$!{table.comment}", tags = "$!{table.comment}接口") +@Tag(name = "$!{table.comment}", description = "$!{table.comment}接口") #if($!{superControllerClass}) public class $!{table.controllerName} extends $!{superControllerClass} { #else diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/AliossTemplate.java b/blade-core-oss/src/main/java/org/springblade/core/oss/AliossTemplate.java index fded6c8..b273f9f 100644 --- a/blade-core-oss/src/main/java/org/springblade/core/oss/AliossTemplate.java +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/AliossTemplate.java @@ -29,6 +29,7 @@ import org.springblade.core.oss.props.OssProperties; import org.springblade.core.oss.rule.OssRule; import org.springblade.core.tool.jackson.JsonUtil; import org.springblade.core.tool.utils.StringPool; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; @@ -281,8 +282,8 @@ public class AliossTemplate implements OssTemplate { * @return String */ public String getOssHost(String bucketName) { - String prefix = ossProperties.getEndpoint().contains("https://") ? "https://" : "http://"; - return prefix + getBucketName(bucketName) + StringPool.DOT + ossProperties.getEndpoint().replaceFirst(prefix, StringPool.EMPTY); + String prefix = getEndpoint().contains("https://") ? "https://" : "http://"; + return prefix + getBucketName(bucketName) + StringPool.DOT + getEndpoint().replaceFirst(prefix, StringPool.EMPTY); } /** @@ -294,4 +295,17 @@ public class AliossTemplate implements OssTemplate { return getOssHost(ossProperties.getBucketName()); } + /** + * 获取服务地址 + * + * @return String + */ + public String getEndpoint() { + if (StringUtil.isBlank(ossProperties.getTransformEndpoint())) { + return ossProperties.getEndpoint(); + } + return ossProperties.getTransformEndpoint(); + } + + } diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/MinioTemplate.java b/blade-core-oss/src/main/java/org/springblade/core/oss/MinioTemplate.java index c9023cc..386d303 100644 --- a/blade-core-oss/src/main/java/org/springblade/core/oss/MinioTemplate.java +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/MinioTemplate.java @@ -29,6 +29,7 @@ import org.springblade.core.oss.rule.OssRule; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.web.multipart.MultipartFile; import java.io.InputStream; @@ -162,13 +163,13 @@ public class MinioTemplate implements OssTemplate { @Override @SneakyThrows public String fileLink(String fileName) { - return ossProperties.getEndpoint().concat(StringPool.SLASH).concat(getBucketName()).concat(StringPool.SLASH).concat(fileName); + return getEndpoint().concat(StringPool.SLASH).concat(getBucketName()).concat(StringPool.SLASH).concat(fileName); } @Override @SneakyThrows public String fileLink(String bucketName, String fileName) { - return ossProperties.getEndpoint().concat(StringPool.SLASH).concat(getBucketName(bucketName)).concat(StringPool.SLASH).concat(fileName); + return getEndpoint().concat(StringPool.SLASH).concat(getBucketName(bucketName)).concat(StringPool.SLASH).concat(fileName); } @Override @@ -402,7 +403,7 @@ public class MinioTemplate implements OssTemplate { * @return String */ public String getOssHost(String bucketName) { - return ossProperties.getEndpoint() + StringPool.SLASH + getBucketName(bucketName); + return getEndpoint() + StringPool.SLASH + getBucketName(bucketName); } /** @@ -414,4 +415,17 @@ public class MinioTemplate implements OssTemplate { return getOssHost(ossProperties.getBucketName()); } + /** + * 获取服务地址 + * + * @return String + */ + public String getEndpoint() { + if (StringUtil.isBlank(ossProperties.getTransformEndpoint())) { + return ossProperties.getEndpoint(); + } + return ossProperties.getTransformEndpoint(); + } + + } diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/QiniuTemplate.java b/blade-core-oss/src/main/java/org/springblade/core/oss/QiniuTemplate.java index 57392d9..941d9e6 100644 --- a/blade-core-oss/src/main/java/org/springblade/core/oss/QiniuTemplate.java +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/QiniuTemplate.java @@ -30,6 +30,7 @@ import org.springblade.core.oss.rule.OssRule; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.web.multipart.MultipartFile; import java.io.InputStream; @@ -116,13 +117,13 @@ public class QiniuTemplate implements OssTemplate { @Override @SneakyThrows public String fileLink(String fileName) { - return ossProperties.getEndpoint().concat(StringPool.SLASH).concat(fileName); + return getEndpoint().concat(StringPool.SLASH).concat(fileName); } @Override @SneakyThrows public String fileLink(String bucketName, String fileName) { - return ossProperties.getEndpoint().concat(StringPool.SLASH).concat(fileName); + return getEndpoint().concat(StringPool.SLASH).concat(fileName); } @Override @@ -260,7 +261,20 @@ public class QiniuTemplate implements OssTemplate { * @return String */ public String getOssHost() { - return ossProperties.getEndpoint(); + return getEndpoint(); } + /** + * 获取服务地址 + * + * @return String + */ + public String getEndpoint() { + if (StringUtil.isBlank(ossProperties.getTransformEndpoint())) { + return ossProperties.getEndpoint(); + } + return ossProperties.getTransformEndpoint(); + } + + } diff --git a/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java b/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java index f02049e..e035e4f 100644 --- a/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java +++ b/blade-core-oss/src/main/java/org/springblade/core/oss/props/OssProperties.java @@ -48,6 +48,11 @@ public class OssProperties { */ private String endpoint; + /** + * 转换外网地址的URL + */ + private String transformEndpoint; + /** * Access key就像用户ID,可以唯一标识你的账户 */