云存储配置文件
This commit is contained in:
parent
fae70a623f
commit
f54b582ce8
|
@ -1,10 +1,8 @@
|
||||||
package net.maku.storage.config;
|
package net.maku.storage.config;
|
||||||
|
|
||||||
import net.maku.api.module.storage.StorageService;
|
|
||||||
import net.maku.storage.enums.StorageTypeEnum;
|
import net.maku.storage.enums.StorageTypeEnum;
|
||||||
import net.maku.storage.properties.StorageProperties;
|
import net.maku.storage.properties.StorageProperties;
|
||||||
import net.maku.storage.service.AliyunStorageService;
|
import net.maku.storage.service.*;
|
||||||
import net.maku.storage.service.LocalStorageService;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
@ -21,11 +19,19 @@ import org.springframework.context.annotation.Configuration;
|
||||||
public class StorageConfiguration {
|
public class StorageConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public StorageService storageService(StorageProperties properties){
|
public StorageService storageService(StorageProperties properties) {
|
||||||
if(properties.getConfig().getType() == StorageTypeEnum.LOCAL){
|
if (properties.getConfig().getType() == StorageTypeEnum.LOCAL) {
|
||||||
return new LocalStorageService(properties);
|
return new LocalStorageService(properties);
|
||||||
}else if(properties.getConfig().getType() == StorageTypeEnum.ALIYUN){
|
} else if (properties.getConfig().getType() == StorageTypeEnum.ALIYUN) {
|
||||||
return new AliyunStorageService(properties);
|
return new AliyunStorageService(properties);
|
||||||
|
} else if (properties.getConfig().getType() == StorageTypeEnum.TENCENT) {
|
||||||
|
return new TencentStorageService(properties);
|
||||||
|
} else if (properties.getConfig().getType() == StorageTypeEnum.QINIU) {
|
||||||
|
return new QiniuStorageService(properties);
|
||||||
|
} else if (properties.getConfig().getType() == StorageTypeEnum.HUAWEI) {
|
||||||
|
return new HuaweiStorageService(properties);
|
||||||
|
} else if (properties.getConfig().getType() == StorageTypeEnum.MINIO) {
|
||||||
|
return new MinioStorageService(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -13,5 +13,21 @@ public enum StorageTypeEnum {
|
||||||
/**
|
/**
|
||||||
* 阿里云
|
* 阿里云
|
||||||
*/
|
*/
|
||||||
ALIYUN;
|
ALIYUN,
|
||||||
|
/**
|
||||||
|
* 腾讯云
|
||||||
|
*/
|
||||||
|
TENCENT,
|
||||||
|
/**
|
||||||
|
* 七牛云
|
||||||
|
*/
|
||||||
|
QINIU,
|
||||||
|
/**
|
||||||
|
* 华为云
|
||||||
|
*/
|
||||||
|
HUAWEI,
|
||||||
|
/**
|
||||||
|
* Minio
|
||||||
|
*/
|
||||||
|
MINIO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.maku.storage.properties;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.maku.storage.enums.StorageTypeEnum;
|
import net.maku.storage.enums.StorageTypeEnum;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 存储配置项
|
* 存储配置项
|
||||||
|
@ -28,9 +29,25 @@ public class StorageProperties {
|
||||||
* 阿里云配置项
|
* 阿里云配置项
|
||||||
*/
|
*/
|
||||||
private AliyunStorageProperties aliyun;
|
private AliyunStorageProperties aliyun;
|
||||||
|
/**
|
||||||
|
* 七牛云配置项
|
||||||
|
*/
|
||||||
|
private QiniuStorageProperties qiniu;
|
||||||
|
/**
|
||||||
|
* 华为云配置项
|
||||||
|
*/
|
||||||
|
private HuaweiStorageProperties huawei;
|
||||||
|
/**
|
||||||
|
* Minio配置项
|
||||||
|
*/
|
||||||
|
private MinioStorageProperties minio;
|
||||||
|
/**
|
||||||
|
* 腾讯云配置项
|
||||||
|
*/
|
||||||
|
private TencentStorageProperties tencent;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class StorageConfig{
|
public static class StorageConfig {
|
||||||
/**
|
/**
|
||||||
* 访问域名
|
* 访问域名
|
||||||
*/
|
*/
|
||||||
|
@ -44,4 +61,41 @@ public class StorageProperties {
|
||||||
*/
|
*/
|
||||||
private StorageTypeEnum type;
|
private StorageTypeEnum type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "storage.local")
|
||||||
|
public LocalStorageProperties localStorageProperties() {
|
||||||
|
return new LocalStorageProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "storage.aliyun")
|
||||||
|
public AliyunStorageProperties aliyunStorageProperties() {
|
||||||
|
return new AliyunStorageProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "storage.qiniu")
|
||||||
|
public QiniuStorageProperties qiniuStorageProperties() {
|
||||||
|
return new QiniuStorageProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "storage.huawei")
|
||||||
|
public HuaweiStorageProperties huaweiStorageProperties() {
|
||||||
|
return new HuaweiStorageProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "storage.minio")
|
||||||
|
public MinioStorageProperties minioStorageProperties() {
|
||||||
|
return new MinioStorageProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConfigurationProperties(prefix = "storage.tencent")
|
||||||
|
public TencentStorageProperties tencentStorageProperties() {
|
||||||
|
return new TencentStorageProperties();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user