forked from github/dataease
fix: 缓存引擎信息
This commit is contained in:
parent
b731e5998b
commit
c613c9278b
@ -13,15 +13,14 @@ import io.dataease.commons.utils.HttpClientConfig;
|
||||
import io.dataease.commons.utils.HttpClientUtil;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.controller.request.datasource.DatasourceRequest;
|
||||
import io.dataease.dto.DatasourceDTO;
|
||||
import io.dataease.dto.datasource.DorisConfiguration;
|
||||
import io.dataease.dto.datasource.MysqlConfiguration;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.provider.datasource.DatasourceProvider;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -152,16 +151,12 @@ public class EngineService {
|
||||
}
|
||||
|
||||
private void setDs(DeEngine engine) {
|
||||
Datasource datasource = new Datasource();
|
||||
BeanUtils.copyBean(datasource, engine);
|
||||
CacheUtils.put("ENGINE", "engine", datasource, null, null);
|
||||
CacheUtils.remove("ENGINE", "SimpleKey []");
|
||||
}
|
||||
|
||||
@Cacheable(value = "ENGINE")
|
||||
public Datasource getDeEngine() throws Exception {
|
||||
Object catcheEngine = CacheUtils.get("ENGINE", "engine");
|
||||
if (catcheEngine != null) {
|
||||
return (Datasource) catcheEngine;
|
||||
}
|
||||
Datasource datasource = new Datasource();
|
||||
|
||||
if (isLocalMode()) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@ -179,7 +174,7 @@ public class EngineService {
|
||||
engine.setDesc("doris");
|
||||
engine.setType("engine_doris");
|
||||
engine.setConfiguration(jsonObject.toJSONString());
|
||||
setDs(engine);
|
||||
BeanUtils.copyBean(datasource, engine);
|
||||
}
|
||||
if (isClusterMode()) {
|
||||
DeEngineExample engineExample = new DeEngineExample();
|
||||
@ -188,7 +183,7 @@ public class EngineService {
|
||||
if (CollectionUtils.isEmpty(deEngines)) {
|
||||
throw new Exception("未设置数据引擎");
|
||||
}
|
||||
setDs(deEngines.get(0));
|
||||
BeanUtils.copyBean(datasource, deEngines.get(0));
|
||||
}
|
||||
if (isSimpleMode()) {
|
||||
DeEngineExample engineExample = new DeEngineExample();
|
||||
@ -197,9 +192,9 @@ public class EngineService {
|
||||
if (CollectionUtils.isEmpty(deEngines)) {
|
||||
throw new Exception("未设置数据引擎");
|
||||
}
|
||||
setDs(deEngines.get(0));
|
||||
BeanUtils.copyBean(datasource, deEngines.get(0));
|
||||
}
|
||||
return getDeEngine();
|
||||
return datasource;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user