mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-11-13 04:33:44 +08:00
update 使用 策略+工厂 重写OSS模块
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.ruoyi.oss.factory;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.oss.constant.CloudConstant;
|
||||
import com.ruoyi.oss.service.ICloudStorageService;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 文件上传Factory
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class OssFactory {
|
||||
|
||||
private static ISysConfigService sysConfigService;
|
||||
|
||||
static {
|
||||
OssFactory.sysConfigService = SpringUtils.getBean(ISysConfigService.class);
|
||||
}
|
||||
|
||||
private static final Map<String, ICloudStorageService> SERVICES = new ConcurrentHashMap<>();
|
||||
|
||||
public static ICloudStorageService instance() {
|
||||
String type = sysConfigService.selectConfigByKey(CloudConstant.CLOUD_STORAGE_CONFIG_KEY);
|
||||
return SERVICES.get(type);
|
||||
}
|
||||
|
||||
public static ICloudStorageService instance(String type) {
|
||||
return SERVICES.get(type);
|
||||
}
|
||||
|
||||
public static void register(String type, ICloudStorageService iCloudStorageService) {
|
||||
Assert.notNull(type, "type can't be null");
|
||||
SERVICES.put(type, iCloudStorageService);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user