Avoid process being occupied and optimize database initialization speed

This commit is contained in:
SwallowGG
2024-01-02 19:54:08 +08:00
parent 09f04f7651
commit 7ed715a4e4
5 changed files with 37 additions and 28 deletions

View File

@ -15,6 +15,7 @@ import ai.chat2db.server.domain.api.service.DlTemplateService;
import ai.chat2db.server.tools.base.enums.DataSourceTypeEnum;
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
import ai.chat2db.server.tools.base.wrapper.result.ListResult;
import ai.chat2db.server.tools.common.util.ConfigUtils;
import ai.chat2db.server.web.api.aspect.ConnectionInfoAspect;
import ai.chat2db.server.web.api.controller.ai.chat2db.client.Chat2dbAIClient;
import ai.chat2db.server.web.api.controller.rdb.converter.RdbWebConverter;
@ -70,7 +71,7 @@ public class RdbDmlController {
ListResult<ExecuteResult> resultDTOListResult = dlTemplateService.execute(param);
List<ExecuteResultVO> resultVOS = rdbWebConverter.dto2vo(resultDTOListResult.getData());
String type = Chat2DBContext.getConnectInfo().getDbType();
String clientId = getClientId(request.getClientId());
String clientId = getClientId();
String sqlContent = request.getSql();
executorService.submit(() -> {
try {
@ -102,11 +103,11 @@ public class RdbDmlController {
*
* @return
*/
private String getClientId(String clientId) {
private String getClientId() {
ConfigService configService = ApplicationContextUtil.getBean(ConfigService.class);
Config keyConfig = configService.find(Chat2dbAIClient.CHAT2DB_OPENAI_KEY).getData();
if (Objects.isNull(keyConfig) || StringUtils.isBlank(keyConfig.getContent())) {
return clientId;
return ConfigUtils.getClientId();
}
return keyConfig.getContent();
}
@ -149,7 +150,7 @@ public class RdbDmlController {
ExecuteResultVO executeResultVO = rdbWebConverter.dto2vo(result.getData());
String type = Chat2DBContext.getConnectInfo().getDbType();
String sqlContent = request.getSql();
String clientId = getClientId(request.getClientId());
String clientId = getClientId();
executorService.submit(() -> {
try {
addOperationLog(clientId, type, sqlContent, result.getErrorMessage(), result.getSuccess(), Lists.newArrayList(executeResultVO));

View File

@ -45,8 +45,4 @@ public class DmlRequest extends DataSourceBaseRequest implements DataSourceConso
*/
private Boolean pageSizeAll;
/**
* 客户端id
*/
private String clientId;
}