Compare commits

...

7 Commits

5 changed files with 29 additions and 7 deletions

View File

@ -1,11 +1,11 @@
# Spring # Spring
spring: spring:
application: application:
# 应用名称 # 应用名称
name: bonus-auth name: bonus-auth
profiles: profiles:
# 环境配置 # 环境配置
active: jyy_canteen_local active: jyy_canteen_test
#加密组件 #加密组件
jasypt: jasypt:

View File

@ -5,7 +5,7 @@ spring:
name: bonus-gateway name: bonus-gateway
profiles: profiles:
# 环境配置 # 环境配置
active: jyy_canteen_local active: jyy_canteen_test
#加密组件 #加密组件
jasypt: jasypt:

View File

@ -37,6 +37,11 @@ public class MinioConfig
* 存储桶名称 * 存储桶名称
*/ */
private String bucketName; private String bucketName;
/**
*
* 内网IP地址
*/
private String endpointInter;
@Bean @Bean
public MinioClient getMinioClient() public MinioClient getMinioClient()

View File

@ -18,6 +18,7 @@ import javax.annotation.Resource;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.net.InetAddress;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@ -303,9 +304,25 @@ public class MinioUtil {
if (StringUtils.isNotEmpty(fileUrl)){ if (StringUtils.isNotEmpty(fileUrl)){
if (fileUrl.startsWith("http://")) { if (fileUrl.startsWith("http://")) {
return fileUrl; return fileUrl;
} else {
return minioConfig.getEndpoint() + "/" + minioConfig.getBucketName() + "/" + fileUrl;
} }
// 获取当前访问系统的 IP通过配置或工具方法获取
String currentIp = InetAddress.getLocalHost().getHostAddress();
// 判断访问来源是内网还是外网
boolean isIntranet = currentIp.startsWith("10.");
// 根据来源返回不同的访问地址
String endpoint;
if (isIntranet) {
// 内网访问比如你给的 10.145.136.229
endpoint = minioConfig.getEndpointInter();
} else {
// 外网或局域网访问比如你给的 192.168.20.234
endpoint = minioConfig.getEndpoint();
}
// 拼接完整路径MinIO 地址
return endpoint + "/" + minioConfig.getBucketName() + "/" + fileUrl;
} else { } else {
return ""; return "";
} }

View File

@ -1,11 +1,11 @@
# Spring # Spring
spring: spring:
application: application:
# 应用名称 # 应用名称
name: bonus-system name: bonus-system
profiles: profiles:
# 环境配置 # 环境配置
active: jyy_canteen_local active: jyy_canteen_test
task: task:
scheduling: scheduling:
pool: pool: