Skip to content

Commit eea4f48

Browse files
committed
导入链接增加userId
1 parent 90a93d2 commit eea4f48

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ncx/service/impl

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ncx/service/impl/ConverterServiceImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import ai.chat2db.server.domain.repository.entity.DataSourceDO;
55
import ai.chat2db.server.domain.repository.mapper.DataSourceMapper;
66
import ai.chat2db.server.tools.common.util.ConfigUtils;
7+
import ai.chat2db.server.tools.common.util.ContextUtils;
78
import ai.chat2db.server.web.api.controller.ncx.cipher.CommonCipher;
89
import ai.chat2db.server.web.api.controller.ncx.dbeaver.DefaultValueEncryptor;
910
import ai.chat2db.server.web.api.controller.ncx.enums.DataBaseType;
@@ -210,10 +211,16 @@ public UploadVO dbpUploadFile(File file) {
210211
Date dateTime = new Date();
211212
dataSourceDO.setGmtCreate(dateTime);
212213
dataSourceDO.setGmtModified(dateTime);
214+
//插入用户id
215+
dataSourceDO.setUserId(ContextUtils.getUserId());
213216
dataSourceDO.setAlias(configurations.getString("name"));
214217
dataSourceDO.setHost(configuration.getString("host"));
215218
dataSourceDO.setPort(configuration.getString("port"));
216219
dataSourceDO.setUrl(configuration.getString("url"));
220+
//ssh设置为false
221+
SSHInfo sshInfo = new SSHInfo();
222+
sshInfo.setUse(false);
223+
dataSourceDO.setSsh(JSON.toJSONString(sshInfo));
217224
if (null != credentialsJson) {
218225
JSONObject userInfo = credentialsJson.getJSONObject(key);
219226
JSONObject userPassword = userInfo.getJSONObject(connection);
@@ -291,6 +298,8 @@ public UploadVO datagripUploadFile(String text) {
291298
dataSourceDO.setGmtCreate(dateTime);
292299
dataSourceDO.setGmtModified(dateTime);
293300
dataSourceDO.setAlias(rootElement.getAttribute("name"));
301+
//插入用户id
302+
dataSourceDO.setUserId(ContextUtils.getUserId());
294303
// 获取子元素 database-info
295304
Element databaseInfoElement = (Element) rootElement.getElementsByTagName("database-info").item(0);
296305

@@ -319,6 +328,10 @@ public UploadVO datagripUploadFile(String text) {
319328

320329
}
321330
}
331+
//ssh设置为false
332+
SSHInfo sshInfo = new SSHInfo();
333+
sshInfo.setUse(false);
334+
dataSourceDO.setSsh(JSON.toJSONString(sshInfo));
322335
dataSourceDO.setHost(host);
323336
dataSourceDO.setPort(port);
324337
dataSourceDO.setUrl(jdbcUrl);
@@ -361,6 +374,8 @@ public void insertDBConfig(List<Map<String, Map<String, String>>> list) {
361374
dataSourceDO.setAlias(resultMap.get("ConnectionName"));
362375
dataSourceDO.setUserName(resultMap.get("UserName"));
363376
dataSourceDO.setType(resultMap.get("ConnType"));
377+
//插入用户id
378+
dataSourceDO.setUserId(ContextUtils.getUserId());
364379
//password 为解密出来的密文,再使用chat2db的加密
365380
DesUtil desUtil = new DesUtil(DesUtil.DES_KEY);
366381
String encryptStr = desUtil.encrypt(password, "CBC");

0 commit comments

Comments
 (0)