云存储配置文件
This commit is contained in:
parent
fae70a623f
commit
f54b582ce8
|
@ -1,10 +1,8 @@
|
|||
package net.maku.storage.config;
|
||||
|
||||
import net.maku.api.module.storage.StorageService;
|
||||
import net.maku.storage.enums.StorageTypeEnum;
|
||||
import net.maku.storage.properties.StorageProperties;
|
||||
import net.maku.storage.service.AliyunStorageService;
|
||||
import net.maku.storage.service.LocalStorageService;
|
||||
import net.maku.storage.service.*;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -26,6 +24,14 @@ public class StorageConfiguration {
|
|||
return new LocalStorageService(properties);
|
||||
} else if (properties.getConfig().getType() == StorageTypeEnum.ALIYUN) {
|
||||
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;
|
||||
|
|
|
@ -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 net.maku.storage.enums.StorageTypeEnum;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* 存储配置项
|
||||
|
@ -28,6 +29,22 @@ public class StorageProperties {
|
|||
* 阿里云配置项
|
||||
*/
|
||||
private AliyunStorageProperties aliyun;
|
||||
/**
|
||||
* 七牛云配置项
|
||||
*/
|
||||
private QiniuStorageProperties qiniu;
|
||||
/**
|
||||
* 华为云配置项
|
||||
*/
|
||||
private HuaweiStorageProperties huawei;
|
||||
/**
|
||||
* Minio配置项
|
||||
*/
|
||||
private MinioStorageProperties minio;
|
||||
/**
|
||||
* 腾讯云配置项
|
||||
*/
|
||||
private TencentStorageProperties tencent;
|
||||
|
||||
@Data
|
||||
public static class StorageConfig {
|
||||
|
@ -44,4 +61,41 @@ public class StorageProperties {
|
|||
*/
|
||||
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