|
4 | 4 | import ai.chat2db.server.domain.repository.entity.DataSourceDO; |
5 | 5 | import ai.chat2db.server.domain.repository.mapper.DataSourceMapper; |
6 | 6 | import ai.chat2db.server.tools.common.util.ConfigUtils; |
| 7 | +import ai.chat2db.server.tools.common.util.ContextUtils; |
7 | 8 | import ai.chat2db.server.web.api.controller.ncx.cipher.CommonCipher; |
8 | 9 | import ai.chat2db.server.web.api.controller.ncx.dbeaver.DefaultValueEncryptor; |
9 | 10 | import ai.chat2db.server.web.api.controller.ncx.enums.DataBaseType; |
@@ -210,10 +211,16 @@ public UploadVO dbpUploadFile(File file) { |
210 | 211 | Date dateTime = new Date(); |
211 | 212 | dataSourceDO.setGmtCreate(dateTime); |
212 | 213 | dataSourceDO.setGmtModified(dateTime); |
| 214 | + //插入用户id |
| 215 | + dataSourceDO.setUserId(ContextUtils.getUserId()); |
213 | 216 | dataSourceDO.setAlias(configurations.getString("name")); |
214 | 217 | dataSourceDO.setHost(configuration.getString("host")); |
215 | 218 | dataSourceDO.setPort(configuration.getString("port")); |
216 | 219 | dataSourceDO.setUrl(configuration.getString("url")); |
| 220 | + //ssh设置为false |
| 221 | + SSHInfo sshInfo = new SSHInfo(); |
| 222 | + sshInfo.setUse(false); |
| 223 | + dataSourceDO.setSsh(JSON.toJSONString(sshInfo)); |
217 | 224 | if (null != credentialsJson) { |
218 | 225 | JSONObject userInfo = credentialsJson.getJSONObject(key); |
219 | 226 | JSONObject userPassword = userInfo.getJSONObject(connection); |
@@ -291,6 +298,8 @@ public UploadVO datagripUploadFile(String text) { |
291 | 298 | dataSourceDO.setGmtCreate(dateTime); |
292 | 299 | dataSourceDO.setGmtModified(dateTime); |
293 | 300 | dataSourceDO.setAlias(rootElement.getAttribute("name")); |
| 301 | + //插入用户id |
| 302 | + dataSourceDO.setUserId(ContextUtils.getUserId()); |
294 | 303 | // 获取子元素 database-info |
295 | 304 | Element databaseInfoElement = (Element) rootElement.getElementsByTagName("database-info").item(0); |
296 | 305 |
|
@@ -319,6 +328,10 @@ public UploadVO datagripUploadFile(String text) { |
319 | 328 |
|
320 | 329 | } |
321 | 330 | } |
| 331 | + //ssh设置为false |
| 332 | + SSHInfo sshInfo = new SSHInfo(); |
| 333 | + sshInfo.setUse(false); |
| 334 | + dataSourceDO.setSsh(JSON.toJSONString(sshInfo)); |
322 | 335 | dataSourceDO.setHost(host); |
323 | 336 | dataSourceDO.setPort(port); |
324 | 337 | dataSourceDO.setUrl(jdbcUrl); |
@@ -361,6 +374,8 @@ public void insertDBConfig(List<Map<String, Map<String, String>>> list) { |
361 | 374 | dataSourceDO.setAlias(resultMap.get("ConnectionName")); |
362 | 375 | dataSourceDO.setUserName(resultMap.get("UserName")); |
363 | 376 | dataSourceDO.setType(resultMap.get("ConnType")); |
| 377 | + //插入用户id |
| 378 | + dataSourceDO.setUserId(ContextUtils.getUserId()); |
364 | 379 | //password 为解密出来的密文,再使用chat2db的加密 |
365 | 380 | DesUtil desUtil = new DesUtil(DesUtil.DES_KEY); |
366 | 381 | String encryptStr = desUtil.encrypt(password, "CBC"); |
|
0 commit comments