|
@@ -39,6 +39,19 @@ public class SystemProperties {
|
|
@Value("${examcloud.web.sys.tempDataDir:tempDataDir}")
|
|
@Value("${examcloud.web.sys.tempDataDir:tempDataDir}")
|
|
private String tempDataDir;
|
|
private String tempDataDir;
|
|
|
|
|
|
|
|
+ @Value("${$aliyun.site.1.bucket}")
|
|
|
|
+ private String aliyunBucketName;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 正式环境,此地址默认为阿里云内网域名(阿里云环境时,推荐使用)
|
|
|
|
+ * 其它环境:非阿里云内网域名
|
|
|
|
+ */
|
|
|
|
+ @Value("${$aliyun.site.1.ossEndpoint}")
|
|
|
|
+ private String aliyunOssEndpoint;
|
|
|
|
+
|
|
|
|
+ @Value("${$aliyun.site.1.domain}")
|
|
|
|
+ private String aliyunDomain;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 应用ID
|
|
* 应用ID
|
|
*/
|
|
*/
|
|
@@ -94,6 +107,45 @@ public class SystemProperties {
|
|
this.tempDataDir = tempDataDir;
|
|
this.tempDataDir = tempDataDir;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public String getAliyunBucketName() {
|
|
|
|
+ return aliyunBucketName;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setAliyunBucketName(String aliyunBucketName) {
|
|
|
|
+ this.aliyunBucketName = aliyunBucketName;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getAliyunOssEndpoint() {
|
|
|
|
+ return aliyunOssEndpoint;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setAliyunOssEndpoint(String aliyunOssEndpoint) {
|
|
|
|
+ this.aliyunOssEndpoint = aliyunOssEndpoint;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getAliyunDomain() {
|
|
|
|
+ return aliyunDomain;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setAliyunDomain(String aliyunDomain) {
|
|
|
|
+ this.aliyunDomain = aliyunDomain;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 将文件存储环境的 公网域名 替换为 阿里云内网域名
|
|
|
|
+ */
|
|
|
|
+ public String replaceFileUrlInternalDomain(String fileUrl) {
|
|
|
|
+ if (fileUrl == null || !fileUrl.contains(getAliyunDomain())) {
|
|
|
|
+ return fileUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String[] values = getAliyunOssEndpoint().split("\\/\\/");
|
|
|
|
+ String newDomain = values[0] + "//" + getAliyunBucketName() + "." + values[1];
|
|
|
|
+
|
|
|
|
+ fileUrl = fileUrl.replace(getAliyunDomain(), newDomain);
|
|
|
|
+ return fileUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
@PostConstruct
|
|
@PostConstruct
|
|
public void init() {
|
|
public void init() {
|
|
if (StringUtils.isNotEmpty(dataDir)) {
|
|
if (StringUtils.isNotEmpty(dataDir)) {
|