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.setText(json);
|
||||
entityBuilder.setContentType(ContentType.APPLICATION_JSON);
|
||||
entityBuilder.setContentEncoding(config.getCharset());
|
||||
HttpEntity requestEntity = entityBuilder.build();
|
||||
httpPost.setEntity(requestEntity);
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.dataease.controller.datasource;
|
||||
|
||||
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.DePermission;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
@ -27,6 +29,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "数据源:数据源管理")
|
||||
@ -135,7 +138,9 @@ public class DatasourceController {
|
||||
|
||||
@ApiIgnore
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,31 @@
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service("dorisQueryProvider")
|
||||
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 javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -27,7 +28,9 @@ public class VAuthModelService {
|
||||
public List<VAuthModelDTO> queryAuthModel(VAuthModelRequest request) {
|
||||
request.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
|
||||
List<VAuthModelDTO> result = extVAuthModelMapper.queryAuthModel(request);
|
||||
|
||||
if(CollectionUtils.isEmpty(result)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
if (request.getPrivileges() != null) {
|
||||
result = filterPrivileges(request, result);
|
||||
}
|
||||
|
@ -1116,6 +1116,9 @@ public class DataSetTableService {
|
||||
if (dsType.equals(DatasourceTypes.oracle.getType())) {
|
||||
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!");
|
||||
}
|
||||
subSelect.setAlias(new Alias(fromItem.getAlias().toString()));
|
||||
}
|
||||
plainSelect.setFromItem(subSelect);
|
||||
@ -2818,7 +2821,7 @@ public class DataSetTableService {
|
||||
boolean hasSubBinaryExpression = false;
|
||||
try {
|
||||
BinaryExpression leftBinaryExpression = (BinaryExpression) expr.getLeftExpression();
|
||||
hasSubBinaryExpression = leftBinaryExpression.getLeftExpression() instanceof BinaryExpression;
|
||||
hasSubBinaryExpression = leftBinaryExpression.getLeftExpression() instanceof Expression;
|
||||
} catch (Exception e) {
|
||||
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"
|
||||
:child-views="childViews"
|
||||
:dataset-params="datasetParams"
|
||||
:activeName="activeName"
|
||||
/>
|
||||
|
||||
<filter-foot :element="currentElement" />
|
||||
|
@ -166,7 +166,7 @@
|
||||
<el-popover
|
||||
placement="bottom-end"
|
||||
:disabled="!attrs.enableParameters"
|
||||
width="200"
|
||||
width="420"
|
||||
>
|
||||
<div class="view-container-class">
|
||||
<el-tabs
|
||||
@ -215,12 +215,12 @@
|
||||
v-model="attrs.parameters"
|
||||
>
|
||||
<el-checkbox
|
||||
v-for="(item ) in childViews.datasetParams"
|
||||
v-for="(item ) in allParams"
|
||||
:key="item.id"
|
||||
:label="item.id"
|
||||
class="de-checkbox"
|
||||
>
|
||||
<div class="span-div">
|
||||
<div class="span-div2">
|
||||
<span
|
||||
v-if="item.alias && item.alias.length <= 7"
|
||||
style="margin-left: 6px"
|
||||
@ -280,6 +280,9 @@ export default {
|
||||
datasetParams: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
activeName:{
|
||||
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -327,16 +330,41 @@ export default {
|
||||
}
|
||||
this.attrs.parameters = parameters
|
||||
}
|
||||
this.allParams = this.childViews.datasetParams
|
||||
this.allParams = JSON.parse(JSON.stringify(this.childViews.datasetParams))
|
||||
}
|
||||
},
|
||||
'datasetParams': {
|
||||
handler(newName, oldName) {
|
||||
this.allParams = JSON.parse(JSON.stringify(this.childViews.datasetParams))
|
||||
if (this.datasetParams.length > 0) {
|
||||
this.allParams = this.childViews.datasetParams
|
||||
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.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])
|
||||
}
|
||||
}
|
||||
@ -475,6 +503,13 @@ export default {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.span-div2 {
|
||||
width: 350px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.de-ul li {
|
||||
margin: 5px 2px;
|
||||
cursor: pointer;
|
||||
|
@ -800,7 +800,7 @@ export default {
|
||||
data.request = JSON.stringify(data.request)
|
||||
this.loading = true
|
||||
this.disabledNext = true
|
||||
checkApiDatasource(data).then(res => {
|
||||
checkApiDatasource({'data': Base64.encode(JSON.stringify(data))}).then(res => {
|
||||
this.loading = false
|
||||
this.disabledNext = false
|
||||
this.apiItem.status = 'Success'
|
||||
@ -858,7 +858,7 @@ export default {
|
||||
const data = JSON.parse(JSON.stringify(this.apiItem))
|
||||
data.request = JSON.stringify(data.request)
|
||||
this.loading = true
|
||||
checkApiDatasource(data).then(res => {
|
||||
checkApiDatasource({'data': Base64.encode(JSON.stringify(data))}).then(res => {
|
||||
this.loading = false
|
||||
this.$success(i18n.t('commons.success'))
|
||||
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 dePwd from '@/components/deCustomCm/DePwd.vue'
|
||||
import msgCfm from '@/components/msgCfm'
|
||||
import { Base64 } from 'js-base64'
|
||||
export default {
|
||||
name: 'DsConfiguration',
|
||||
components: {
|
||||
@ -1069,10 +1070,10 @@ export default {
|
||||
}
|
||||
this.$refs.apiItemBasicInfo.validate((valid) => {
|
||||
if (valid) {
|
||||
const data = JSON.parse(JSON.stringify(this.apiItem))
|
||||
const data = Base64.encode(JSON.stringify(this.apiItem))
|
||||
this.loading = true
|
||||
this.disabledNext = true
|
||||
checkApiDatasource(data)
|
||||
checkApiDatasource({'data': data})
|
||||
.then((res) => {
|
||||
this.loading = false
|
||||
this.disabledNext = false
|
||||
|
Loading…
Reference in New Issue
Block a user