fix 修复 OssFactory 在程序启动未调用api 没有初始化 导致无法订阅配置更改问题

feature/model
疯狂的狮子li 3 years ago
parent 81d04fb31f
commit eb844e3260

@ -24,18 +24,22 @@ import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class OssFactory {
static {
RedisUtils.subscribe(CloudConstant.CACHE_CONFIG_KEY, String.class, msg -> {
refreshService(msg);
log.info("订阅刷新OSS配置 => " + msg);
});
}
/**
*
*/
private static final Map<String, ICloudStorageStrategy> SERVICES = new ConcurrentHashMap<>();
/**
*
*/
public static void init() {
log.info("初始化OSS工厂");
RedisUtils.subscribe(CloudConstant.CACHE_CONFIG_KEY, String.class, msg -> {
refreshService(msg);
log.info("订阅刷新OSS配置 => " + msg);
});
}
/**
*
*/

@ -16,6 +16,7 @@ import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.RedisUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.oss.constant.CloudConstant;
import com.ruoyi.oss.factory.OssFactory;
import com.ruoyi.system.domain.SysOssConfig;
import com.ruoyi.system.domain.bo.SysOssConfigBo;
import com.ruoyi.system.domain.vo.SysOssConfigVo;
@ -49,6 +50,7 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
@PostConstruct
public void init() {
List<SysOssConfig> list = list();
// 加载OSS初始化配置
for (SysOssConfig config : list) {
String configKey = config.getConfigKey();
if ("0".equals(config.getStatus())) {
@ -56,6 +58,8 @@ public class SysOssConfigServiceImpl extends ServicePlusImpl<SysOssConfigMapper,
}
setConfigCache(true, config);
}
// 初始化OSS工厂
OssFactory.init();
}
@Override

Loading…
Cancel
Save