forked from github/dataease
Merge pull request #4171 from dataease/pr@dev@fixds
fix: SQL参数在过滤组件中按表选择字段时出现重复的情况
This commit is contained in:
commit
17390e7396
@ -123,7 +123,6 @@ public class HttpClientUtil {
|
|||||||
EntityBuilder entityBuilder = EntityBuilder.create();
|
EntityBuilder entityBuilder = EntityBuilder.create();
|
||||||
entityBuilder.setText(json);
|
entityBuilder.setText(json);
|
||||||
entityBuilder.setContentType(ContentType.APPLICATION_JSON);
|
entityBuilder.setContentType(ContentType.APPLICATION_JSON);
|
||||||
entityBuilder.setContentEncoding(config.getCharset());
|
|
||||||
HttpEntity requestEntity = entityBuilder.build();
|
HttpEntity requestEntity = entityBuilder.build();
|
||||||
httpPost.setEntity(requestEntity);
|
httpPost.setEntity(requestEntity);
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package io.dataease.controller.datasource;
|
package io.dataease.controller.datasource;
|
||||||
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import io.dataease.auth.annotation.DeLog;
|
import io.dataease.auth.annotation.DeLog;
|
||||||
import io.dataease.auth.annotation.DePermission;
|
import io.dataease.auth.annotation.DePermission;
|
||||||
import io.dataease.commons.constants.DePermissionType;
|
import io.dataease.commons.constants.DePermissionType;
|
||||||
@ -27,6 +29,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Api(tags = "数据源:数据源管理")
|
@Api(tags = "数据源:数据源管理")
|
||||||
@ -135,7 +138,9 @@ public class DatasourceController {
|
|||||||
|
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
@PostMapping("/checkApiDatasource")
|
@PostMapping("/checkApiDatasource")
|
||||||
public ApiDefinition checkApiDatasource(@RequestBody ApiDefinition apiDefinition) throws Exception {
|
public ApiDefinition checkApiDatasource(@RequestBody Map<String, String> data) throws Exception {
|
||||||
|
ApiDefinition apiDefinition = new Gson().fromJson(new String(java.util.Base64.getDecoder().decode(data.get("data"))), new TypeToken<ApiDefinition>() {
|
||||||
|
}.getType());
|
||||||
return datasourceService.checkApiDatasource(apiDefinition);
|
return datasourceService.checkApiDatasource(apiDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,31 @@
|
|||||||
package io.dataease.provider.query.doris;
|
package io.dataease.provider.query.doris;
|
||||||
|
|
||||||
|
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||||
|
import io.dataease.plugins.common.base.domain.Datasource;
|
||||||
|
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||||
|
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||||
|
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||||
|
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||||
|
import io.dataease.plugins.datasource.entity.PageInfo;
|
||||||
import io.dataease.provider.query.mysql.MysqlQueryProvider;
|
import io.dataease.provider.query.mysql.MysqlQueryProvider;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Service("dorisQueryProvider")
|
@Service("dorisQueryProvider")
|
||||||
public class DorisQueryProvider extends MysqlQueryProvider {
|
public class DorisQueryProvider extends MysqlQueryProvider {
|
||||||
|
|
||||||
|
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||||
|
if(isTable){
|
||||||
|
return getSQLTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view);
|
||||||
|
}else {
|
||||||
|
return getSQLAsTmpTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResultCount(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -27,7 +28,9 @@ public class VAuthModelService {
|
|||||||
public List<VAuthModelDTO> queryAuthModel(VAuthModelRequest request) {
|
public List<VAuthModelDTO> queryAuthModel(VAuthModelRequest request) {
|
||||||
request.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
request.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||||
List<VAuthModelDTO> result = extVAuthModelMapper.queryAuthModel(request);
|
List<VAuthModelDTO> result = extVAuthModelMapper.queryAuthModel(request);
|
||||||
|
if(CollectionUtils.isEmpty(result)){
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
if (request.getPrivileges() != null) {
|
if (request.getPrivileges() != null) {
|
||||||
result = filterPrivileges(request, result);
|
result = filterPrivileges(request, result);
|
||||||
}
|
}
|
||||||
|
@ -1116,6 +1116,9 @@ public class DataSetTableService {
|
|||||||
if (dsType.equals(DatasourceTypes.oracle.getType())) {
|
if (dsType.equals(DatasourceTypes.oracle.getType())) {
|
||||||
subSelect.setAlias(new Alias(fromItem.getAlias().toString(), false));
|
subSelect.setAlias(new Alias(fromItem.getAlias().toString(), false));
|
||||||
} else {
|
} else {
|
||||||
|
if(fromItem.getAlias() == null){
|
||||||
|
throw new Exception("Failed to parse sql, Every derived table must have its own alias!");
|
||||||
|
}
|
||||||
subSelect.setAlias(new Alias(fromItem.getAlias().toString()));
|
subSelect.setAlias(new Alias(fromItem.getAlias().toString()));
|
||||||
}
|
}
|
||||||
plainSelect.setFromItem(subSelect);
|
plainSelect.setFromItem(subSelect);
|
||||||
@ -2818,7 +2821,7 @@ public class DataSetTableService {
|
|||||||
boolean hasSubBinaryExpression = false;
|
boolean hasSubBinaryExpression = false;
|
||||||
try {
|
try {
|
||||||
BinaryExpression leftBinaryExpression = (BinaryExpression) expr.getLeftExpression();
|
BinaryExpression leftBinaryExpression = (BinaryExpression) expr.getLeftExpression();
|
||||||
hasSubBinaryExpression = leftBinaryExpression.getLeftExpression() instanceof BinaryExpression;
|
hasSubBinaryExpression = leftBinaryExpression.getLeftExpression() instanceof Expression;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 50 KiB |
Binary file not shown.
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 265 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 55 KiB |
@ -275,6 +275,7 @@
|
|||||||
:control-attrs="myAttrs"
|
:control-attrs="myAttrs"
|
||||||
:child-views="childViews"
|
:child-views="childViews"
|
||||||
:dataset-params="datasetParams"
|
:dataset-params="datasetParams"
|
||||||
|
:activeName="activeName"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<filter-foot :element="currentElement" />
|
<filter-foot :element="currentElement" />
|
||||||
|
@ -166,7 +166,7 @@
|
|||||||
<el-popover
|
<el-popover
|
||||||
placement="bottom-end"
|
placement="bottom-end"
|
||||||
:disabled="!attrs.enableParameters"
|
:disabled="!attrs.enableParameters"
|
||||||
width="200"
|
width="420"
|
||||||
>
|
>
|
||||||
<div class="view-container-class">
|
<div class="view-container-class">
|
||||||
<el-tabs
|
<el-tabs
|
||||||
@ -215,12 +215,12 @@
|
|||||||
v-model="attrs.parameters"
|
v-model="attrs.parameters"
|
||||||
>
|
>
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-for="(item ) in childViews.datasetParams"
|
v-for="(item ) in allParams"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.id"
|
:label="item.id"
|
||||||
class="de-checkbox"
|
class="de-checkbox"
|
||||||
>
|
>
|
||||||
<div class="span-div">
|
<div class="span-div2">
|
||||||
<span
|
<span
|
||||||
v-if="item.alias && item.alias.length <= 7"
|
v-if="item.alias && item.alias.length <= 7"
|
||||||
style="margin-left: 6px"
|
style="margin-left: 6px"
|
||||||
@ -280,6 +280,9 @@ export default {
|
|||||||
datasetParams: {
|
datasetParams: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => []
|
||||||
|
},
|
||||||
|
activeName:{
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -327,16 +330,41 @@ export default {
|
|||||||
}
|
}
|
||||||
this.attrs.parameters = parameters
|
this.attrs.parameters = parameters
|
||||||
}
|
}
|
||||||
this.allParams = this.childViews.datasetParams
|
this.allParams = JSON.parse(JSON.stringify(this.childViews.datasetParams))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'datasetParams': {
|
'datasetParams': {
|
||||||
handler(newName, oldName) {
|
handler(newName, oldName) {
|
||||||
|
this.allParams = JSON.parse(JSON.stringify(this.childViews.datasetParams))
|
||||||
if (this.datasetParams.length > 0) {
|
if (this.datasetParams.length > 0) {
|
||||||
this.allParams = this.childViews.datasetParams
|
|
||||||
for (var j = 0; j < this.datasetParams.length; j++) {
|
for (var j = 0; j < this.datasetParams.length; j++) {
|
||||||
|
var hasParam = false
|
||||||
for (var i = 0; i < this.childViews.datasetParams.length; i++) {
|
for (var i = 0; i < this.childViews.datasetParams.length; i++) {
|
||||||
if (this.childViews.datasetParams[i].id.split('|DE|')[0] !== this.datasetParams[j].id.split('|DE|')[0]) {
|
if (this.childViews.datasetParams[i].id === this.datasetParams[j].id) {
|
||||||
|
hasParam = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!hasParam){
|
||||||
|
this.allParams.push(this.datasetParams[j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'activeName':{
|
||||||
|
handler(newName, oldName) {
|
||||||
|
if(this.activeName === 'assembly'){
|
||||||
|
this.allParams = JSON.parse(JSON.stringify(this.childViews.datasetParams))
|
||||||
|
}else {
|
||||||
|
if (this.datasetParams.length > 0) {
|
||||||
|
for (var j = 0; j < this.datasetParams.length; j++) {
|
||||||
|
var hasParam = false
|
||||||
|
for (var i = 0; i < this.childViews.datasetParams.length; i++) {
|
||||||
|
if (this.childViews.datasetParams[i].id === this.datasetParams[j].id) {
|
||||||
|
hasParam = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!hasParam){
|
||||||
this.allParams.push(this.datasetParams[j])
|
this.allParams.push(this.datasetParams[j])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,6 +503,13 @@ export default {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.span-div2 {
|
||||||
|
width: 350px;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.de-ul li {
|
.de-ul li {
|
||||||
margin: 5px 2px;
|
margin: 5px 2px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -800,7 +800,7 @@ export default {
|
|||||||
data.request = JSON.stringify(data.request)
|
data.request = JSON.stringify(data.request)
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.disabledNext = true
|
this.disabledNext = true
|
||||||
checkApiDatasource(data).then(res => {
|
checkApiDatasource({'data': Base64.encode(JSON.stringify(data))}).then(res => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.disabledNext = false
|
this.disabledNext = false
|
||||||
this.apiItem.status = 'Success'
|
this.apiItem.status = 'Success'
|
||||||
@ -858,7 +858,7 @@ export default {
|
|||||||
const data = JSON.parse(JSON.stringify(this.apiItem))
|
const data = JSON.parse(JSON.stringify(this.apiItem))
|
||||||
data.request = JSON.stringify(data.request)
|
data.request = JSON.stringify(data.request)
|
||||||
this.loading = true
|
this.loading = true
|
||||||
checkApiDatasource(data).then(res => {
|
checkApiDatasource({'data': Base64.encode(JSON.stringify(data))}).then(res => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.$success(i18n.t('commons.success'))
|
this.$success(i18n.t('commons.success'))
|
||||||
this.apiItem.fields = res.data.fields
|
this.apiItem.fields = res.data.fields
|
||||||
|
@ -734,6 +734,7 @@ import { checkApiDatasource, getSchema } from '@/api/system/datasource'
|
|||||||
import ApiHttpRequestForm from '@/views/system/datasource/ApiHttpRequestForm'
|
import ApiHttpRequestForm from '@/views/system/datasource/ApiHttpRequestForm'
|
||||||
import dePwd from '@/components/deCustomCm/DePwd.vue'
|
import dePwd from '@/components/deCustomCm/DePwd.vue'
|
||||||
import msgCfm from '@/components/msgCfm'
|
import msgCfm from '@/components/msgCfm'
|
||||||
|
import { Base64 } from 'js-base64'
|
||||||
export default {
|
export default {
|
||||||
name: 'DsConfiguration',
|
name: 'DsConfiguration',
|
||||||
components: {
|
components: {
|
||||||
@ -1069,10 +1070,10 @@ export default {
|
|||||||
}
|
}
|
||||||
this.$refs.apiItemBasicInfo.validate((valid) => {
|
this.$refs.apiItemBasicInfo.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
const data = JSON.parse(JSON.stringify(this.apiItem))
|
const data = Base64.encode(JSON.stringify(this.apiItem))
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.disabledNext = true
|
this.disabledNext = true
|
||||||
checkApiDatasource(data)
|
checkApiDatasource({'data': data})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.disabledNext = false
|
this.disabledNext = false
|
||||||
|
Loading…
Reference in New Issue
Block a user