From f337c73c11a47df25903ffabed4e77070a21f0fc Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 29 Nov 2023 12:13:47 +0800 Subject: [PATCH 01/12] =?UTF-8?q?fix:=20=E8=A7=A3=E6=9E=90sql=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/service/dataset/DataSetTableService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index d5561c0148..057f561df7 100644 --- a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -1123,7 +1123,9 @@ public class DataSetTableService { Select subSelectTmp = (Select) CCJSqlParserUtil.parse(removeVariables(selectBody.toString(), dsType)); subSelect.setSelectBody(subSelectTmp.getSelectBody()); if (dsType.equals(DatasourceTypes.oracle.getType())) { - subSelect.setAlias(new Alias(fromItem.getAlias().toString(), false)); + if(fromItem.getAlias() != null){ + subSelect.setAlias(new Alias(fromItem.getAlias().toString(), false)); + } } else { if (fromItem.getAlias() == null) { throw new Exception("Failed to parse sql, Every derived table must have its own alias!"); From 02d678a9b6120cd694430c5757cf31e0ab071c7f Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 29 Nov 2023 12:22:58 +0800 Subject: [PATCH 02/12] =?UTF-8?q?fix:=20=E6=A0=A1=E9=AA=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/src/lang/en.js | 2 +- core/frontend/src/lang/tw.js | 2 +- core/frontend/src/lang/zh.js | 2 +- .../src/views/system/datasource/DsConfiguration.vue | 7 ++++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/frontend/src/lang/en.js b/core/frontend/src/lang/en.js index 19d7844838..187004dd64 100644 --- a/core/frontend/src/lang/en.js +++ b/core/frontend/src/lang/en.js @@ -1944,7 +1944,7 @@ export default { please_input_max_pool_size: 'Please enter the maximum number of connections', please_input_max_idle_time: 'Please enter the maximum idle (seconds)', please_input_acquire_increment: 'Please enter the growth number', - please_input_query_timeout: 'Please enter query timeout', + please_input_query_timeout: 'Please enter query timeout,no less then zero', please_input_connect_timeout: 'Please enter the connection timeout (seconds)', no_less_then_0: 'Parameters in advanced settings cannot be less than zero', port_no_less_then_0: 'Port cannot be less than zero', diff --git a/core/frontend/src/lang/tw.js b/core/frontend/src/lang/tw.js index af5aa0f52d..cf3a0c0a50 100644 --- a/core/frontend/src/lang/tw.js +++ b/core/frontend/src/lang/tw.js @@ -1936,7 +1936,7 @@ export default { please_input_max_pool_size: '請輸入最大連接數', please_input_max_idle_time: '請輸入最大空閑(秒)', please_input_acquire_increment: '請輸入增長數', - please_input_query_timeout: '請輸入查詢超時', + please_input_query_timeout: '請輸入查詢超時,不小于零', please_input_connect_timeout: '請輸輸入連接超時(秒)', no_less_then_0: '高級設置中的參數不能小於零', port_no_less_then_0: '端口不能小於零', diff --git a/core/frontend/src/lang/zh.js b/core/frontend/src/lang/zh.js index dc0ca4b1fd..9a7081548b 100644 --- a/core/frontend/src/lang/zh.js +++ b/core/frontend/src/lang/zh.js @@ -1936,7 +1936,7 @@ export default { please_input_max_pool_size: '请输入最大连接数', please_input_max_idle_time: '请输入最大空闲(秒)', please_input_acquire_increment: '请输入增长数', - please_input_query_timeout: '请输入查询超时', + please_input_query_timeout: '请输入查询超时,不小于零', please_input_connect_timeout: '请输入连接超时(秒)', no_less_then_0: '高级设置中的参数不能小于零', port_no_less_then_0: '端口不能小于零', diff --git a/core/frontend/src/views/system/datasource/DsConfiguration.vue b/core/frontend/src/views/system/datasource/DsConfiguration.vue index 0b59837c3d..1223b9430f 100644 --- a/core/frontend/src/views/system/datasource/DsConfiguration.vue +++ b/core/frontend/src/views/system/datasource/DsConfiguration.vue @@ -999,8 +999,7 @@ export default { { required: true, validator: this.isNumber, - message: i18n.t('datasource.please_input_query_timeout'), - trigger: 'blur' + trigger: ['blur', 'change'] } ], dataPath: [ @@ -1161,6 +1160,7 @@ export default { }, isNumber(rule, value, callback) { console.log(value) + console.log(!value) if (!value) { callback(new Error(i18n.t('datasource.please_input_query_timeout'))) return @@ -1168,8 +1168,9 @@ export default { let isNumber = false var reg = /^\d+$/; isNumber = reg.test(value); + console.log(!isNumber) if (!isNumber) { - callback(new Error(i18n.t('chart.value_error'))) + callback(new Error(i18n.t('datasource.please_input_query_timeout'))) return } callback() From 2062cfd4e6fd3a9623b5c1d4e50ef5e7e4ef32f2 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 29 Nov 2023 12:59:43 +0800 Subject: [PATCH 03/12] =?UTF-8?q?fix:=20SQL=E5=8F=98=E9=87=8F=E8=AF=AF?= =?UTF-8?q?=E6=8A=A5=E9=94=99=20#6624?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 72 +++++++++++++------ 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 057f561df7..8b9adb8d47 100644 --- a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -1115,7 +1115,22 @@ public class DataSetTableService { } } - private String handlePlainSelect(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception { + private void handleSelectItems(PlainSelect plainSelect, String dsType) throws Exception{ + List selectItems = new ArrayList<>(); + for (SelectItem selectItem : plainSelect.getSelectItems()) { + SelectExpressionItem selectExpressionItem = (SelectExpressionItem) selectItem; + if (selectExpressionItem.getExpression() instanceof SubSelect) { + SubSelect subSelect = (SubSelect) selectExpressionItem.getExpression(); + Select select = (Select) CCJSqlParserUtil.parse (removeVariables(subSelect.getSelectBody().toString(), dsType)); + subSelect.setSelectBody(select.getSelectBody()); + ((SelectExpressionItem) selectItem).setExpression(subSelect); + } + selectItems.add(selectItem); + } + plainSelect.setSelectItems(selectItems); + } + + private void handleFromItems(PlainSelect plainSelect, String dsType) throws Exception{ FromItem fromItem = plainSelect.getFromItem(); if (fromItem instanceof SubSelect) { SelectBody selectBody = ((SubSelect) fromItem).getSelectBody(); @@ -1134,6 +1149,8 @@ public class DataSetTableService { } plainSelect.setFromItem(subSelect); } + } + private void handleJoins(PlainSelect plainSelect, String dsType) throws Exception{ List joins = plainSelect.getJoins(); if (joins != null) { List joinsList = new ArrayList<>(); @@ -1159,27 +1176,29 @@ public class DataSetTableService { } plainSelect.setJoins(joinsList); } - Expression expr = plainSelect.getWhere(); - if (expr == null) { - return handleWith(plainSelect, statementSelect, dsType); - } - StringBuilder stringBuilder = new StringBuilder(); - BinaryExpression binaryExpression = null; - try { - binaryExpression = (BinaryExpression) expr; - } catch (Exception e) { - } - if (binaryExpression != null) { - if (!(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && hasVariable(binaryExpression.getRightExpression().toString())) { - stringBuilder.append(SubstitutedSql); - } else { - expr.accept(getExpressionDeParser(stringBuilder)); - } - } else { - expr.accept(getExpressionDeParser(stringBuilder)); - } - plainSelect.setWhere(CCJSqlParserUtil.parseCondExpression(stringBuilder.toString())); - return handleWith(plainSelect, statementSelect, dsType); + } + private String handleWhere(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception{ + Expression expr = plainSelect.getWhere(); + if (expr == null) { + return handleWith(plainSelect, statementSelect, dsType); + } + StringBuilder stringBuilder = new StringBuilder(); + BinaryExpression binaryExpression = null; + try { + binaryExpression = (BinaryExpression) expr; + } catch (Exception e) { + } + if (binaryExpression != null) { + if (!(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && hasVariable(binaryExpression.getRightExpression().toString())) { + stringBuilder.append(SubstitutedSql); + } else { + expr.accept(getExpressionDeParser(stringBuilder)); + } + } else { + expr.accept(getExpressionDeParser(stringBuilder)); + } + plainSelect.setWhere(CCJSqlParserUtil.parseCondExpression(stringBuilder.toString())); + return handleWith(plainSelect, statementSelect, dsType); } private String handleWith(PlainSelect plainSelect, Select select, String dsType) throws Exception { @@ -1200,6 +1219,15 @@ public class DataSetTableService { return builder.toString(); } + private String handlePlainSelect(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception { + handleSelectItems(plainSelect, dsType); + handleFromItems(plainSelect, dsType); + handleJoins(plainSelect, dsType); + return handleWhere(plainSelect, statementSelect, dsType); + } + + + public Map getDBPreview(DataSetTableRequest dataSetTableRequest) throws Exception { Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId()); if (ds == null) { From ed3117af5b05385bca79f86d81d833feab745bb6 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 29 Nov 2023 14:12:36 +0800 Subject: [PATCH 04/12] =?UTF-8?q?perf:=20=E4=B8=8B=E6=8B=89=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=99=A8=E9=A6=96=E9=80=89=E9=A1=B9=E4=BD=9C=E7=94=A8?= =?UTF-8?q?=E4=BA=8Etab=E4=B8=AD=E8=A7=86=E5=9B=BE(=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=8A=B6=E6=80=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/src/utils/conditionUtil.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/frontend/src/utils/conditionUtil.js b/core/frontend/src/utils/conditionUtil.js index 791a9e9d4a..0c960538b9 100644 --- a/core/frontend/src/utils/conditionUtil.js +++ b/core/frontend/src/utils/conditionUtil.js @@ -90,7 +90,13 @@ export const buildCanvasIdMap = panelItems => { const cacheCondition = (cb, obj) => { obj.cb = cb } -export const buildViewKeyFilters = (panelItems, result) => { + +const crossCanvasFilter = (filterEle, viewId) => { + const filterCanvas = filterEle.canvasId + const canvasIdMap = buildCanvasIdMap(store.state.componentData) + return canvasIdMap[viewId] !== filterCanvas +} +export const buildViewKeyFilters = (panelItems, result, isEdit = false) => { if (!(panelItems && panelItems.length > 0)) { return result } @@ -112,7 +118,7 @@ export const buildViewKeyFilters = (panelItems, result) => { // 进行过滤时 如果过滤组件在主画布 则条件适用于所有画布视图 否则需要过滤组件和视图在相同画布 if (element.canvasId === 'canvas-main' || element.canvasId === canvasIdMap[viewId]) { const vidMatch = viewIdMatch(condition.viewIds, viewId) - if (vidMatch && selectFirst) { + if (vidMatch && selectFirst && !(crossCanvasFilter(element, viewId) && isEdit)) { const obj = {} const promise = new Promise(resolve => { cacheCondition(cbParam => { @@ -139,10 +145,9 @@ export const buildViewKeyFilters = (panelItems, result) => { }) return result } -export const buildFilterMap = panelItems => { +export const buildFilterMap = (panelItems, isEdit = false) => { let result = buildViewKeyMap(panelItems) - - result = buildViewKeyFilters(panelItems, result) + result = buildViewKeyFilters(panelItems, result, isEdit) return result } From b8af080b4d565607761be76b5aeadae2b4e06876 Mon Sep 17 00:00:00 2001 From: ulleo Date: Wed, 29 Nov 2023 14:47:18 +0800 Subject: [PATCH 05/12] =?UTF-8?q?fix:=20=E5=9C=A8=E6=8C=87=E6=A0=87?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA=E2=80=9C=E5=8D=A0=E6=AF=94=E2=80=9D?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E9=92=BB=E5=8F=96?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E8=A7=A6=E5=8F=91=20/=20by=20zero=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/dataease/service/chart/ChartViewService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index e62b4833ef..414025dfac 100644 --- a/core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -1379,6 +1379,9 @@ public class ChartViewService { if (StringUtils.isEmpty(cValue)) { continue; } + if (sum.equals(new BigDecimal(0))) { + continue; + } item[dataIndex] = new BigDecimal(cValue) .divide(sum, 8, RoundingMode.HALF_UP) .toString(); From f78ab3f29d0d48d2324d1016506167c8fb36a7a3 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 29 Nov 2023 16:23:56 +0800 Subject: [PATCH 06/12] =?UTF-8?q?perf:=20=E4=B8=8B=E6=8B=89=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=99=A8=E4=B8=8E=E9=80=89=E9=A1=B9=E5=8D=A1=E4=BA=A4?= =?UTF-8?q?=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/src/components/canvas/utils/utils.js | 1 + core/frontend/src/components/widget/deWidget/DeSelect.vue | 2 ++ core/frontend/src/utils/conditionUtil.js | 7 +------ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/core/frontend/src/components/canvas/utils/utils.js b/core/frontend/src/components/canvas/utils/utils.js index 630adfcbb8..19ed237940 100644 --- a/core/frontend/src/components/canvas/utils/utils.js +++ b/core/frontend/src/components/canvas/utils/utils.js @@ -136,6 +136,7 @@ export function panelDataPrepare(componentData, componentStyle, callback) { } if (item.type === 'custom') { item.options.manualModify = false + item.options.loaded = false } if (item.filters && item.filters.length > 0) { item.filters = [] diff --git a/core/frontend/src/components/widget/deWidget/DeSelect.vue b/core/frontend/src/components/widget/deWidget/DeSelect.vue index 599e192c0e..d8097e4361 100644 --- a/core/frontend/src/components/widget/deWidget/DeSelect.vue +++ b/core/frontend/src/components/widget/deWidget/DeSelect.vue @@ -382,6 +382,8 @@ export default { componentId: this.element.id, val: (this.value && Array.isArray(this.value)) ? this.value.join(',') : this.value }) + this.element.options.loaded = true + this.$store.commit('setComponentWithId', this.element) } }, refreshLoad() { diff --git a/core/frontend/src/utils/conditionUtil.js b/core/frontend/src/utils/conditionUtil.js index 0c960538b9..ac93c68890 100644 --- a/core/frontend/src/utils/conditionUtil.js +++ b/core/frontend/src/utils/conditionUtil.js @@ -91,11 +91,6 @@ const cacheCondition = (cb, obj) => { obj.cb = cb } -const crossCanvasFilter = (filterEle, viewId) => { - const filterCanvas = filterEle.canvasId - const canvasIdMap = buildCanvasIdMap(store.state.componentData) - return canvasIdMap[viewId] !== filterCanvas -} export const buildViewKeyFilters = (panelItems, result, isEdit = false) => { if (!(panelItems && panelItems.length > 0)) { return result @@ -118,7 +113,7 @@ export const buildViewKeyFilters = (panelItems, result, isEdit = false) => { // 进行过滤时 如果过滤组件在主画布 则条件适用于所有画布视图 否则需要过滤组件和视图在相同画布 if (element.canvasId === 'canvas-main' || element.canvasId === canvasIdMap[viewId]) { const vidMatch = viewIdMatch(condition.viewIds, viewId) - if (vidMatch && selectFirst && !(crossCanvasFilter(element, viewId) && isEdit)) { + if (vidMatch && selectFirst && !element.options.loaded) { const obj = {} const promise = new Promise(resolve => { cacheCondition(cbParam => { From c22e25ec00ec77b08ad999d4e697c2c4a093ebd8 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 29 Nov 2023 19:26:12 +0800 Subject: [PATCH 07/12] =?UTF-8?q?fix:=20SQL=E5=8F=98=E9=87=8F=E8=AF=AF?= =?UTF-8?q?=E6=8A=A5=E9=94=99=20#6624?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/DriverMgmController.java | 1 - .../provider/query/es/EsQueryProvider.java | 4 +- .../service/dataset/DataSetTableService.java | 76 ++++++++++--------- .../system/datasource/DsConfiguration.vue | 3 - .../views/system/datasource/DsFormContent.vue | 2 +- 5 files changed, 44 insertions(+), 42 deletions(-) diff --git a/core/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java b/core/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java index 32edc4ae23..aadd2df8f1 100644 --- a/core/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java +++ b/core/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java @@ -34,7 +34,6 @@ public class DriverMgmController { @ApiOperation("驱动列表") @PostMapping("/list") public List listDeDriver() throws Exception{ - checkPermission(); return driverService.list(); } diff --git a/core/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java b/core/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java index db09106e94..0072a0d374 100644 --- a/core/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java +++ b/core/backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java @@ -333,8 +333,10 @@ public class EsQueryProvider extends QueryProvider { } else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); } else { - if (y.getDeType() == 2 || y.getDeType() == 3) { + if (y.getDeType() == 2) { originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()), "bigint"); + } else if (y.getDeType() == 3) { + originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()), "float"); } else { originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()); } diff --git a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 8b9adb8d47..51cef6c3b9 100644 --- a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -1115,22 +1115,25 @@ public class DataSetTableService { } } - private void handleSelectItems(PlainSelect plainSelect, String dsType) throws Exception{ + private void handleSelectItems(PlainSelect plainSelect, String dsType) throws Exception { List selectItems = new ArrayList<>(); for (SelectItem selectItem : plainSelect.getSelectItems()) { - SelectExpressionItem selectExpressionItem = (SelectExpressionItem) selectItem; - if (selectExpressionItem.getExpression() instanceof SubSelect) { - SubSelect subSelect = (SubSelect) selectExpressionItem.getExpression(); - Select select = (Select) CCJSqlParserUtil.parse (removeVariables(subSelect.getSelectBody().toString(), dsType)); - subSelect.setSelectBody(select.getSelectBody()); - ((SelectExpressionItem) selectItem).setExpression(subSelect); + try { + SelectExpressionItem selectExpressionItem = (SelectExpressionItem) selectItem; + if (selectExpressionItem.getExpression() instanceof SubSelect) { + SubSelect subSelect = (SubSelect) selectExpressionItem.getExpression(); + Select select = (Select) CCJSqlParserUtil.parse(removeVariables(subSelect.getSelectBody().toString(), dsType)); + subSelect.setSelectBody(select.getSelectBody()); + ((SelectExpressionItem) selectItem).setExpression(subSelect); + } + } catch (Exception e) { } selectItems.add(selectItem); } plainSelect.setSelectItems(selectItems); } - private void handleFromItems(PlainSelect plainSelect, String dsType) throws Exception{ + private void handleFromItems(PlainSelect plainSelect, String dsType) throws Exception { FromItem fromItem = plainSelect.getFromItem(); if (fromItem instanceof SubSelect) { SelectBody selectBody = ((SubSelect) fromItem).getSelectBody(); @@ -1138,7 +1141,7 @@ public class DataSetTableService { Select subSelectTmp = (Select) CCJSqlParserUtil.parse(removeVariables(selectBody.toString(), dsType)); subSelect.setSelectBody(subSelectTmp.getSelectBody()); if (dsType.equals(DatasourceTypes.oracle.getType())) { - if(fromItem.getAlias() != null){ + if (fromItem.getAlias() != null) { subSelect.setAlias(new Alias(fromItem.getAlias().toString(), false)); } } else { @@ -1150,7 +1153,8 @@ public class DataSetTableService { plainSelect.setFromItem(subSelect); } } - private void handleJoins(PlainSelect plainSelect, String dsType) throws Exception{ + + private void handleJoins(PlainSelect plainSelect, String dsType) throws Exception { List joins = plainSelect.getJoins(); if (joins != null) { List joinsList = new ArrayList<>(); @@ -1177,28 +1181,29 @@ public class DataSetTableService { plainSelect.setJoins(joinsList); } } - private String handleWhere(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception{ - Expression expr = plainSelect.getWhere(); - if (expr == null) { - return handleWith(plainSelect, statementSelect, dsType); - } - StringBuilder stringBuilder = new StringBuilder(); - BinaryExpression binaryExpression = null; - try { - binaryExpression = (BinaryExpression) expr; - } catch (Exception e) { - } - if (binaryExpression != null) { - if (!(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && hasVariable(binaryExpression.getRightExpression().toString())) { - stringBuilder.append(SubstitutedSql); - } else { - expr.accept(getExpressionDeParser(stringBuilder)); - } - } else { - expr.accept(getExpressionDeParser(stringBuilder)); - } - plainSelect.setWhere(CCJSqlParserUtil.parseCondExpression(stringBuilder.toString())); - return handleWith(plainSelect, statementSelect, dsType); + + private String handleWhere(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception { + Expression expr = plainSelect.getWhere(); + if (expr == null) { + return handleWith(plainSelect, statementSelect, dsType); + } + StringBuilder stringBuilder = new StringBuilder(); + BinaryExpression binaryExpression = null; + try { + binaryExpression = (BinaryExpression) expr; + } catch (Exception e) { + } + if (binaryExpression != null) { + if (!(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && hasVariable(binaryExpression.getRightExpression().toString())) { + stringBuilder.append(SubstitutedSql); + } else { + expr.accept(getExpressionDeParser(stringBuilder)); + } + } else { + expr.accept(getExpressionDeParser(stringBuilder)); + } + plainSelect.setWhere(CCJSqlParserUtil.parseCondExpression(stringBuilder.toString())); + return handleWith(plainSelect, statementSelect, dsType); } private String handleWith(PlainSelect plainSelect, Select select, String dsType) throws Exception { @@ -1227,7 +1232,6 @@ public class DataSetTableService { } - public Map getDBPreview(DataSetTableRequest dataSetTableRequest) throws Exception { Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId()); if (ds == null) { @@ -2783,13 +2787,13 @@ public class DataSetTableService { if (StringUtils.isEmpty(s)) { throw new RuntimeException(Translator.get("i18n_excel_empty_column")); } - if(hashSet.contains(s)){ + if (hashSet.contains(s)) { repeat.add(s); - }else { + } else { hashSet.add(s); } } - if(CollectionUtils.isNotEmpty(repeat)){ + if (CollectionUtils.isNotEmpty(repeat)) { DataEaseException.throwException(Translator.get("i18n_excel_field_repeat") + "" + String.valueOf(repeat)); } } diff --git a/core/frontend/src/views/system/datasource/DsConfiguration.vue b/core/frontend/src/views/system/datasource/DsConfiguration.vue index 1223b9430f..74c922f4d6 100644 --- a/core/frontend/src/views/system/datasource/DsConfiguration.vue +++ b/core/frontend/src/views/system/datasource/DsConfiguration.vue @@ -1159,8 +1159,6 @@ export default { callback() }, isNumber(rule, value, callback) { - console.log(value) - console.log(!value) if (!value) { callback(new Error(i18n.t('datasource.please_input_query_timeout'))) return @@ -1168,7 +1166,6 @@ export default { let isNumber = false var reg = /^\d+$/; isNumber = reg.test(value); - console.log(!isNumber) if (!isNumber) { callback(new Error(i18n.t('datasource.please_input_query_timeout'))) return diff --git a/core/frontend/src/views/system/datasource/DsFormContent.vue b/core/frontend/src/views/system/datasource/DsFormContent.vue index a99defa973..9753494be1 100644 --- a/core/frontend/src/views/system/datasource/DsFormContent.vue +++ b/core/frontend/src/views/system/datasource/DsFormContent.vue @@ -946,7 +946,7 @@ export default { this.tData.forEach((item) => { if (item.id === this.form.type) { item.children.forEach((child) => { - if (this.formType === 'modify' && child.id === this.form.id) { + if (child.id === this.form.id) { return } const configuration = JSON.parse(child.configuration) From 3e8e910c25640026d94498a9f86e3d823dbe3270 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 30 Nov 2023 12:37:59 +0800 Subject: [PATCH 08/12] =?UTF-8?q?fix:=20API=20=E4=B8=A2=E5=A4=B1null?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/provider/datasource/ApiProvider.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java b/core/backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java index 0b4adc7626..4f850deeea 100644 --- a/core/backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java +++ b/core/backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java @@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; import com.alibaba.fastjson.serializer.SerializerFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import com.google.gson.JsonObject; @@ -239,7 +241,12 @@ public class ApiProvider extends Provider { String rootPath; if (response.startsWith("[")) { rootPath = "$[*]"; - JSONArray jsonArray = JSONObject.parseArray(response); + JsonNode jsonArray = null; + try { + jsonArray = new ObjectMapper().readTree(response); + } catch (Exception e) { + e.printStackTrace(); + } for (Object o : jsonArray) { handleStr(apiDefinition, o.toString(), fields, rootPath); } From c8a4059dd43e58078a5cfa00acd66e009f45e762 Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 30 Nov 2023 16:19:59 +0800 Subject: [PATCH 09/12] =?UTF-8?q?fix:=20=E5=85=B3=E8=81=94=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E4=BF=9D=E5=AD=98=20#6894?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/dataease/service/dataset/DataSetTableService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 51cef6c3b9..6d46d0b169 100644 --- a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -1659,7 +1659,7 @@ public class DataSetTableService { } List fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField()); - String[] array = fields.stream() + String[] array = fields.stream().filter(Objects::nonNull) .map(f -> table + "." + f.getDataeaseName() + " AS " + TableUtils.fieldName(tableId + "_" + f.getDataeaseName())) .toArray(String[]::new); From a18015dbbd42a4d5b932a8ea25ed853c63757a7f Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 30 Nov 2023 16:24:47 +0800 Subject: [PATCH 10/12] =?UTF-8?q?fix:=20API=20=E4=B8=A2=E5=A4=B1null?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/controller/datasource/DriverMgmController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java b/core/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java index aadd2df8f1..3c4b1d88bd 100644 --- a/core/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java +++ b/core/backend/src/main/java/io/dataease/controller/datasource/DriverMgmController.java @@ -56,7 +56,6 @@ public class DriverMgmController { @ApiOperation("驱动列表") @GetMapping("/list/{type}") public List listDeDriver(@PathVariable String type) throws Exception{ - checkPermission(); return listDeDriver().stream().filter(driverDTO -> driverDTO.getType().equalsIgnoreCase(type)).collect(Collectors.toList()); } From cba0c4130cf01b7ca60201284b157146de3ade4d Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 30 Nov 2023 16:35:54 +0800 Subject: [PATCH 11/12] =?UTF-8?q?fix:=20API=20=E8=B6=85=E6=97=B6=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/src/lang/en.js | 2 +- core/frontend/src/lang/tw.js | 2 +- core/frontend/src/lang/zh.js | 2 +- core/frontend/src/views/system/datasource/DsConfiguration.vue | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/frontend/src/lang/en.js b/core/frontend/src/lang/en.js index 187004dd64..28943c1bd5 100644 --- a/core/frontend/src/lang/en.js +++ b/core/frontend/src/lang/en.js @@ -1944,7 +1944,7 @@ export default { please_input_max_pool_size: 'Please enter the maximum number of connections', please_input_max_idle_time: 'Please enter the maximum idle (seconds)', please_input_acquire_increment: 'Please enter the growth number', - please_input_query_timeout: 'Please enter query timeout,no less then zero', + please_input_query_timeout: 'Please enter query timeout,Valid range [1 - 300]', please_input_connect_timeout: 'Please enter the connection timeout (seconds)', no_less_then_0: 'Parameters in advanced settings cannot be less than zero', port_no_less_then_0: 'Port cannot be less than zero', diff --git a/core/frontend/src/lang/tw.js b/core/frontend/src/lang/tw.js index cf3a0c0a50..c9df7fe82d 100644 --- a/core/frontend/src/lang/tw.js +++ b/core/frontend/src/lang/tw.js @@ -1936,7 +1936,7 @@ export default { please_input_max_pool_size: '請輸入最大連接數', please_input_max_idle_time: '請輸入最大空閑(秒)', please_input_acquire_increment: '請輸入增長數', - please_input_query_timeout: '請輸入查詢超時,不小于零', + please_input_query_timeout: '請輸入查詢超時,請填寫1-300正整數', please_input_connect_timeout: '請輸輸入連接超時(秒)', no_less_then_0: '高級設置中的參數不能小於零', port_no_less_then_0: '端口不能小於零', diff --git a/core/frontend/src/lang/zh.js b/core/frontend/src/lang/zh.js index 9a7081548b..45cf7ff125 100644 --- a/core/frontend/src/lang/zh.js +++ b/core/frontend/src/lang/zh.js @@ -1936,7 +1936,7 @@ export default { please_input_max_pool_size: '请输入最大连接数', please_input_max_idle_time: '请输入最大空闲(秒)', please_input_acquire_increment: '请输入增长数', - please_input_query_timeout: '请输入查询超时,不小于零', + please_input_query_timeout: '请输入查询超时,填写1-300正整数', please_input_connect_timeout: '请输入连接超时(秒)', no_less_then_0: '高级设置中的参数不能小于零', port_no_less_then_0: '端口不能小于零', diff --git a/core/frontend/src/views/system/datasource/DsConfiguration.vue b/core/frontend/src/views/system/datasource/DsConfiguration.vue index 74c922f4d6..78e27d1705 100644 --- a/core/frontend/src/views/system/datasource/DsConfiguration.vue +++ b/core/frontend/src/views/system/datasource/DsConfiguration.vue @@ -1170,6 +1170,10 @@ export default { callback(new Error(i18n.t('datasource.please_input_query_timeout'))) return } + if(value <= 0 || value > 300){ + callback(new Error(i18n.t('datasource.please_input_query_timeout'))) + return + } callback() }, next() { From c591a8377e3a1fd6d38eb0d00c32c6c294cf082a Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 30 Nov 2023 16:56:53 +0800 Subject: [PATCH 12/12] =?UTF-8?q?fix:=20=E5=85=B3=E8=81=94=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=8A=A5=E9=94=99=20#6894?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 6d46d0b169..8539ce7738 100644 --- a/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/core/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -1659,9 +1659,18 @@ public class DataSetTableService { } List fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField()); - String[] array = fields.stream().filter(Objects::nonNull) - .map(f -> table + "." + f.getDataeaseName() + " AS " - + TableUtils.fieldName(tableId + "_" + f.getDataeaseName())) + String[] array = fields.stream() + .map(f -> { + String s = ""; + if (f == null) { + DEException.throwException( + Translator.get("i18n_ds_error")); + } else { + s = table + "." + f.getDataeaseName() + " AS " + + TableUtils.fieldName(tableId + "_" + f.getDataeaseName()); + } + return s; + }) .toArray(String[]::new); checkedInfo.put(table, array); checkedFields.addAll(fields);