Commit bb6760a5 authored by Menethil's avatar Menethil
Browse files

Merge remote-tracking branch 'origin/master'

parents 4b12f490 ab454046
...@@ -4,7 +4,6 @@ import org.springframework.core.io.Resource; ...@@ -4,7 +4,6 @@ import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
...@@ -13,7 +12,6 @@ import java.util.stream.Stream; ...@@ -13,7 +12,6 @@ import java.util.stream.Stream;
public class StorageService { public class StorageService {
private String active; private String active;
private Storage storage; private Storage storage;
private Map<String, Storage> supportedStorage;
public String getActive() { public String getActive() {
return active; return active;
...@@ -21,15 +19,14 @@ public class StorageService { ...@@ -21,15 +19,14 @@ public class StorageService {
public void setActive(String active) { public void setActive(String active) {
this.active = active; this.active = active;
this.storage = this.supportedStorage.get(active);
} }
public Map<String, Storage> getSupportedStorage() { public Storage getStorage() {
return supportedStorage; return storage;
} }
public void setSupportedStorage(Map<String, Storage> supportedStorage) { public void setStorage(Storage storage) {
this.supportedStorage = supportedStorage; this.storage = storage;
} }
/** /**
......
...@@ -22,12 +22,21 @@ public class StorageAutoConfiguration { ...@@ -22,12 +22,21 @@ public class StorageAutoConfiguration {
public StorageService storageService() { public StorageService storageService() {
StorageService storageService = new StorageService(); StorageService storageService = new StorageService();
Map<String, Storage> supportedStorage = new HashMap<String, Storage>(3); Map<String, Storage> supportedStorage = new HashMap<String, Storage>(3);
supportedStorage.put("local", localStorage());
supportedStorage.put("aliyun", aliyunStorage());
supportedStorage.put("tencent", tencentStorage());
storageService.setSupportedStorage(supportedStorage);
String active = this.properties.getActive(); String active = this.properties.getActive();
storageService.setActive(active); storageService.setActive(active);
if(active.equals("local")){
storageService.setStorage(localStorage());
}
else if(active.equals("aliyun")){
storageService.setStorage(aliyunStorage());
}
else if(active.equals("tencent")){
storageService.setStorage(tencentStorage());
}
else{
throw new RuntimeException("当前存储模式 " + active + " 不支持");
}
return storageService; return storageService;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment