From 27912dfb1b8b70eab508e81631c63e519d7bfa15 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Mon, 30 Oct 2023 11:58:04 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E6=A0=A1=E9=AA=8C=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=B1=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/provider/CalciteProvider.java | 25 ++++++++----------- .../io/dataease/datasource/type/Mysql.java | 3 ++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java index 070e3c0e6c..a6a421b4a3 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/CalciteProvider.java @@ -47,7 +47,6 @@ import java.util.stream.Collectors; @Component("calciteProvider") public class CalciteProvider { - //TODO mongo impala es hive @Resource protected CoreDatasourceMapper coreDatasourceMapper; @Resource @@ -93,7 +92,7 @@ public class CalciteProvider { schemas.add(resultSet.getString(1)); } } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } return schemas; } @@ -107,7 +106,7 @@ public class CalciteProvider { tables.add(getTableDesc(datasourceRequest, resultSet)); } } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } } return tables; @@ -145,15 +144,11 @@ public class CalciteProvider { String querySql = getTablesSql(datasourceRequest).get(0); try (Connection con = getConnection(datasourceRequest.getDatasource()); Statement statement = getStatement(con, 30); ResultSet resultSet = statement.executeQuery(querySql)) { } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } return "Success"; } - public List getTableFields(DatasourceRequest datasourceRequest) throws Exception { - return null; - } - public Map fetchResultField(DatasourceRequest datasourceRequest) throws DEException { List datasetTableFields = new ArrayList<>(); List list = new LinkedList<>(); @@ -242,7 +237,7 @@ public class CalciteProvider { Class.forName("org.apache.calcite.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:calcite:", info); } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } return connection; } @@ -433,7 +428,7 @@ public class CalciteProvider { list.add(row); } } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } return list; } @@ -573,7 +568,7 @@ public class CalciteProvider { Driver driverClass = (Driver) jdbcClassLoader.loadClass(driverClassName).newInstance(); conn = driverClass.connect(configuration.getJdbc(), props); } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } return conn; } @@ -587,7 +582,7 @@ public class CalciteProvider { stat = connection.createStatement(); stat.setQueryTimeout(queryTimeout); } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } return stat; } @@ -640,7 +635,7 @@ public class CalciteProvider { customJdbcClassLoaders.put(coreDriver.getId(), customJdbcClassLoader); return customJdbcClassLoader; } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } return null; } @@ -691,7 +686,7 @@ public class CalciteProvider { SchemaPlus rootSchema = buildSchema(datasourceRequest, calciteConnection); addCustomFunctions(rootSchema); } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } } @@ -709,7 +704,7 @@ public class CalciteProvider { rootSchema.removeSubSchema(datasourceSchemaDTO.getSchemaAlias()); } } catch (Exception e) { - DEException.throwException(e); + DEException.throwException(e.getMessage()); } } diff --git a/core/core-backend/src/main/java/io/dataease/datasource/type/Mysql.java b/core/core-backend/src/main/java/io/dataease/datasource/type/Mysql.java index aa4290a444..fad120d167 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/type/Mysql.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/type/Mysql.java @@ -1,6 +1,7 @@ package io.dataease.datasource.type; import io.dataease.api.ds.vo.DatasourceConfiguration; +import io.dataease.exception.DEException; import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; @@ -25,7 +26,7 @@ public class Mysql extends DatasourceConfiguration { } else { for (String illegalParameter : illegalParameters) { if (getExtraParams().toLowerCase().contains(illegalParameter.toLowerCase())) { - throw new RuntimeException("Illegal parameter: " + illegalParameter); + DEException.throwException("Illegal parameter: " + illegalParameter); } } From cb9d94639aefe04d6dc54b0dfe50d79cde1e5d21 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Mon, 30 Oct 2023 13:00:25 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20API=E6=95=B0=E6=8D=AE=E6=BA=90API?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/server/DatasourceServer.java | 10 ++-- .../io/dataease/utils/HttpClientUtil.java | 52 +++++++++++-------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java index b66e6e2ae8..91a8a00ab3 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/server/DatasourceServer.java @@ -125,10 +125,12 @@ public class DatasourceServer implements DatasourceApi { if (Objects.equals(dataSourceDTO.getId(), dataSourceDTO.getPid())) { DEException.throwException(Translator.get("i18n_pid_not_eq_id")); } - List ids = new ArrayList<>(); - getParents(dataSourceDTO.getPid(), ids); - if (ids.contains(dataSourceDTO.getId())) { - DEException.throwException(Translator.get("i18n_pid_not_eq_id")); + if (dataSourceDTO.getPid() != 0) { + List ids = new ArrayList<>(); + getParents(dataSourceDTO.getPid(), ids); + if (ids.contains(dataSourceDTO.getId())) { + DEException.throwException(Translator.get("i18n_pid_not_eq_id")); + } } dataSourceManage.move(dataSourceDTO); } diff --git a/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java b/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java index 9cb38b703a..ee0f649c01 100755 --- a/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java +++ b/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java @@ -78,13 +78,14 @@ public class HttpClientUtil { * @return 响应结果字符串 */ public static String get(String url, HttpClientConfig config) { - CloseableHttpClient httpClient = buildHttpClient(url); - HttpGet httpGet = new HttpGet(url); - - if (config == null) { - config = new HttpClientConfig(); - } + CloseableHttpClient httpClient = null; try { + httpClient = buildHttpClient(url); + HttpGet httpGet = new HttpGet(url); + + if (config == null) { + config = new HttpClientConfig(); + } httpGet.setConfig(config.buildRequestConfig()); Map header = config.getHeader(); @@ -98,7 +99,9 @@ public class HttpClientUtil { throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage()); } finally { try { - httpClient.close(); + if(httpClient != null){ + httpClient.close(); + } } catch (Exception e) { logger.error("HttpClient关闭连接失败", e); } @@ -143,14 +146,14 @@ public class HttpClientUtil { * @return 响应结果字符串 */ public static String post(String url, String json, HttpClientConfig config) { - CloseableHttpClient httpClient = buildHttpClient(url); - HttpPost httpPost = new HttpPost(url); - if (config == null) { - config = new HttpClientConfig(); - } + CloseableHttpClient httpClient = null; try { + buildHttpClient(url); + HttpPost httpPost = new HttpPost(url); + if (config == null) { + config = new HttpClientConfig(); + } httpPost.setConfig(config.buildRequestConfig()); - Map header = config.getHeader(); for (String key : header.keySet()) { httpPost.addHeader(key, header.get(key)); @@ -168,7 +171,9 @@ public class HttpClientUtil { throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage()); } finally { try { - httpClient.close(); + if(httpClient != null){ + httpClient.close(); + } } catch (Exception e) { logger.error("HttpClient关闭连接失败", e); } @@ -195,14 +200,15 @@ public class HttpClientUtil { * @return 响应结果字符串 */ public static String post(String url, Map body, HttpClientConfig config) { - CloseableHttpClient httpClient = buildHttpClient(url); - HttpPost httpPost = new HttpPost(url); - if (config == null) { - config = new HttpClientConfig(); - } - try { - httpPost.setConfig(config.buildRequestConfig()); + CloseableHttpClient httpClient = null; + try { + buildHttpClient(url); + HttpPost httpPost = new HttpPost(url); + if (config == null) { + config = new HttpClientConfig(); + } + httpPost.setConfig(config.buildRequestConfig()); Map header = config.getHeader(); for (String key : header.keySet()) { httpPost.addHeader(key, header.get(key)); @@ -227,7 +233,9 @@ public class HttpClientUtil { throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage()); } finally { try { - httpClient.close(); + if(httpClient != null){ + httpClient.close(); + } } catch (Exception e) { logger.error("HttpClient关闭连接失败", e); } From f75c57077eb56551eb59cd8d9a79ca21972041f6 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Mon, 30 Oct 2023 15:26:39 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E6=9D=BF=E6=89=B9=E9=87=8F=E5=A4=8D=E5=88=B6=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E9=87=8D=E5=90=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/dashboard/DbToolbar.vue | 13 +++++++++---- .../src/store/modules/data-visualization/copy.ts | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/core-frontend/src/components/dashboard/DbToolbar.vue b/core/core-frontend/src/components/dashboard/DbToolbar.vue index c6fe4756f4..9449b6f512 100644 --- a/core/core-frontend/src/components/dashboard/DbToolbar.vue +++ b/core/core-frontend/src/components/dashboard/DbToolbar.vue @@ -75,13 +75,17 @@ const closeEditCanvasName = () => { } const undo = () => { - snapshotStore.undo() - eventBus.emit('matrix-canvasInit', false) + if (snapshotIndex.value > 0) { + snapshotStore.undo() + eventBus.emit('matrix-canvasInit', false) + } } const redo = () => { - snapshotStore.redo() - eventBus.emit('matrix-canvasInit', false) + if (snapshotIndex.value !== snapshotStore.snapshotData.length - 1) { + snapshotStore.redo() + eventBus.emit('matrix-canvasInit', false) + } } const previewInner = () => { @@ -333,6 +337,7 @@ onMounted(() => { diff --git a/core/core-frontend/src/store/modules/data-visualization/copy.ts b/core/core-frontend/src/store/modules/data-visualization/copy.ts index 7bf6d6f98e..26bd184484 100644 --- a/core/core-frontend/src/store/modules/data-visualization/copy.ts +++ b/core/core-frontend/src/store/modules/data-visualization/copy.ts @@ -107,9 +107,11 @@ export const copyStore = defineStore('copy', { eventBus.emit('addDashboardItem-' + newComponent.canvasId, newComponent) } }) - if (dvInfo.value.type === 'dashboard') { + if (dvInfo.value.type === 'dashboard' && dataArray.length > 1) { //占位优化 整合定位 - eventBus.emit('doCanvasInit-canvas-main') + setTimeout(() => { + eventBus.emit('doCanvasInit-canvas-main') + }, 1000) } snapshotStore.recordSnapshotCache() }, From e5747ba8f53a3f73f3986ddd70787c3bf79b0154 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Mon, 30 Oct 2023 15:37:08 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=E8=A7=A3=E6=9E=90API=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/dataease/datasource/provider/ApiUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java index 6d3bcb0781..3dbc242a17 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java @@ -319,7 +319,7 @@ public class ApiUtils { } } for (JsonNode node : jsonArray) { - handleStr(apiDefinition, node.toString(), childrenField, rootPath + "." + fieldName + "[*]"); + handleStr(apiDefinition, node.toString(), childrenField, rootPath + "." + String.format(path, fieldName) + "[*]"); } o.put("children", childrenField); o.put("childrenDataType", "LIST"); From a699d0b6a0eb8f52af8af718c8c6cdf87357c610 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Mon, 30 Oct 2023 15:49:04 +0800 Subject: [PATCH 5/5] =?UTF-8?q?refactor:=20=E7=9F=A9=E9=98=B5=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=AE=9A=E4=BD=8D=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/modules/data-visualization/copy.ts | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/core/core-frontend/src/store/modules/data-visualization/copy.ts b/core/core-frontend/src/store/modules/data-visualization/copy.ts index 26bd184484..904013c629 100644 --- a/core/core-frontend/src/store/modules/data-visualization/copy.ts +++ b/core/core-frontend/src/store/modules/data-visualization/copy.ts @@ -83,36 +83,40 @@ export const copyStore = defineStore('copy', { return } const dataArray = this.copyData.data - dataArray.forEach(data => { - if (dvInfo.value.type === 'dataV') { - if (isMouse) { - data.style.top = menuTop - data.style.left = menuLeft - } else { - data.style.top += 10 - data.style.left += 10 - } + + let i = 0 + const copyDataTemp = this.copyData + const moveTime = dataArray.length > 1 ? 300 : 10 + const timeId = setInterval(function () { + if (i >= dataArray.length) { + clearInterval(timeId) } else { - // 向下移动一个高度矩阵单位 - data.y = data.y + data.sizeY - } - // 旧-新ID映射关系 - const idMap = {} - const newComponent = deepCopyHelper(data, idMap) - dvMainStore.addCopyComponent(newComponent, idMap, this.copyData.copyCanvasViewInfo) - if (dvInfo.value.type === 'dashboard') { - if (dvMainStore.multiplexingStyleAdapt && this.copyData.copyFrom === 'multiplexing') { - adaptCurThemeCommonStyle(newComponent) + const data = dataArray[i] + if (dvInfo.value.type === 'dataV') { + if (isMouse) { + data.style.top = menuTop + data.style.left = menuLeft + } else { + data.style.top += 10 + data.style.left += 10 + } + } else { + // 向下移动一个高度矩阵单位 + data.y = data.y + data.sizeY } - eventBus.emit('addDashboardItem-' + newComponent.canvasId, newComponent) + // 旧-新ID映射关系 + const idMap = {} + const newComponent = deepCopyHelper(data, idMap) + dvMainStore.addCopyComponent(newComponent, idMap, copyDataTemp.copyCanvasViewInfo) + if (dvInfo.value.type === 'dashboard') { + if (dvMainStore.multiplexingStyleAdapt && copyDataTemp.copyFrom === 'multiplexing') { + adaptCurThemeCommonStyle(newComponent) + } + eventBus.emit('addDashboardItem-' + newComponent.canvasId, newComponent) + } + i++ } - }) - if (dvInfo.value.type === 'dashboard' && dataArray.length > 1) { - //占位优化 整合定位 - setTimeout(() => { - eventBus.emit('doCanvasInit-canvas-main') - }, 1000) - } + }, moveTime) snapshotStore.recordSnapshotCache() }, cut() {