forked from github/dataease
feat: 过滤组件绑定参数优化,可直接展示数据集中的参数
This commit is contained in:
parent
c6ab3cc44a
commit
5eb4abe5ae
@ -247,6 +247,12 @@ public class DataSetTableController {
|
||||
return dataSetTableService.paramsWithIds(type, viewIds);
|
||||
}
|
||||
|
||||
@ApiOperation("数据集的SQL变量")
|
||||
@PostMapping("/params/{id}/{type}")
|
||||
List<SqlVariableDetails> paramsWithIds(@PathVariable String type, @PathVariable String id) {
|
||||
return dataSetTableService.datasetParams(type, id);
|
||||
}
|
||||
|
||||
@ApiOperation("根据数据集文件夹ID查询数据集名称")
|
||||
@PostMapping("/getDatasetNameFromGroup/{sceneId}")
|
||||
public List<String> getDatasetNameFromGroup(@PathVariable String sceneId) {
|
||||
|
@ -48,7 +48,7 @@ public class DatasourceController {
|
||||
positionIndex = 0, positionKey = "type",
|
||||
value = "id"
|
||||
)
|
||||
public Datasource addDatasource(@RequestBody Datasource datasource) throws Exception {
|
||||
public Datasource addDatasource(@RequestBody DatasourceDTO datasource) throws Exception {
|
||||
return datasourceService.addDatasource(datasource);
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class DatasourceController {
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/validate")
|
||||
public ResultHolder validate(@RequestBody Datasource datasource) throws Exception {
|
||||
public ResultHolder validate(@RequestBody DatasourceDTO datasource) throws Exception {
|
||||
return datasourceService.validate(datasource);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class DatasourceController {
|
||||
|
||||
@ApiIgnore
|
||||
@PostMapping("/getSchema")
|
||||
public List<String> getSchema(@RequestBody Datasource datasource) throws Exception {
|
||||
public List<String> getSchema(@RequestBody DatasourceDTO datasource) throws Exception {
|
||||
return datasourceService.getSchema(datasource);
|
||||
}
|
||||
|
||||
|
@ -15,4 +15,5 @@ public class UpdataDsRequest {
|
||||
private String type;
|
||||
@ApiModelProperty(value = "配置详情", required = true)
|
||||
private String configuration;
|
||||
private boolean configurationEncryption = false;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.dataease.controller.request.panel;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.dto.DatasourceDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@ -33,5 +33,5 @@ public class PanelAppTemplateApplyRequest {
|
||||
|
||||
private String datasourceHistoryId;
|
||||
|
||||
private List<Datasource> datasourceList;
|
||||
private List<DatasourceDTO> datasourceList;
|
||||
}
|
||||
|
@ -22,4 +22,5 @@ public class DatasourceDTO extends Datasource {
|
||||
private String apiConfigurationStr;
|
||||
private String typeDesc;
|
||||
private DatasourceCalculationMode calculationMode;
|
||||
private boolean isConfigurationEncryption = false;
|
||||
}
|
||||
|
@ -967,26 +967,15 @@ public class DataSetTableService {
|
||||
return map;
|
||||
}
|
||||
|
||||
public List<SqlVariableDetails> paramsWithIds(String type, List<String> viewIds) {
|
||||
if (CollectionUtils.isEmpty(viewIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<SqlVariableDetails> datasetParams(String type, String id) {
|
||||
if (!Arrays.asList("DATE", "TEXT", "NUM").contains(type)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
ChartViewExample chartViewExample = new ChartViewExample();
|
||||
chartViewExample.createCriteria().andIdIn(viewIds);
|
||||
List<String> datasetIds = chartViewMapper.selectByExample(chartViewExample).stream().map(ChartView::getTableId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(datasetIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
DatasetTableExample datasetTableExample = new DatasetTableExample();
|
||||
datasetTableExample.createCriteria().andIdIn(datasetIds);
|
||||
List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(datasetTableExample);
|
||||
if (CollectionUtils.isEmpty(datasetTables)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(id);
|
||||
return getSqlVariableDetails(type, Arrays.asList(datasetTable));
|
||||
}
|
||||
|
||||
private List<SqlVariableDetails> getSqlVariableDetails(String type, List<DatasetTable> datasetTables) {
|
||||
List<SqlVariableDetails> sqlVariableDetails = new ArrayList<>();
|
||||
for (DatasetTable datasetTable : datasetTables) {
|
||||
if (StringUtils.isNotEmpty(datasetTable.getSqlVariableDetails())) {
|
||||
@ -999,6 +988,7 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case "DATE":
|
||||
sqlVariableDetails = sqlVariableDetails.stream().filter(item -> item.getType().get(0).contains("DATETIME")).collect(Collectors.toList());
|
||||
@ -1022,6 +1012,29 @@ public class DataSetTableService {
|
||||
return sqlVariableDetails;
|
||||
}
|
||||
|
||||
public List<SqlVariableDetails> paramsWithIds(String type, List<String> viewIds) {
|
||||
if (CollectionUtils.isEmpty(viewIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (!Arrays.asList("DATE", "TEXT", "NUM").contains(type)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
ChartViewExample chartViewExample = new ChartViewExample();
|
||||
chartViewExample.createCriteria().andIdIn(viewIds);
|
||||
List<String> datasetIds = chartViewMapper.selectByExample(chartViewExample).stream().map(ChartView::getTableId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(datasetIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
DatasetTableExample datasetTableExample = new DatasetTableExample();
|
||||
datasetTableExample.createCriteria().andIdIn(datasetIds);
|
||||
List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(datasetTableExample);
|
||||
if (CollectionUtils.isEmpty(datasetTables)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return getSqlVariableDetails(type, datasetTables);
|
||||
}
|
||||
|
||||
|
||||
public void checkVariable(final String sql, String dsType) throws Exception {
|
||||
String tmpSql = removeVariables(sql, dsType);
|
||||
|
@ -104,11 +104,13 @@ public class DatasourceService {
|
||||
|
||||
@DeCleaner(DePermissionType.DATASOURCE)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Datasource addDatasource(Datasource datasource) throws Exception {
|
||||
public Datasource addDatasource(DatasourceDTO datasource) throws Exception {
|
||||
if (!types().stream().map(DataSourceType::getType).collect(Collectors.toList()).contains(datasource.getType())) {
|
||||
throw new Exception("Datasource type not supported.");
|
||||
}
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
if(datasource.isConfigurationEncryption()){
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
}
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
datasourceProvider.checkConfiguration(datasource);
|
||||
|
||||
@ -261,7 +263,12 @@ public class DatasourceService {
|
||||
if (!types().stream().map(DataSourceType::getType).collect(Collectors.toList()).contains(updataDsRequest.getType())) {
|
||||
throw new Exception("Datasource type not supported.");
|
||||
}
|
||||
updataDsRequest.setConfiguration(new String(java.util.Base64.getDecoder().decode(updataDsRequest.getConfiguration())));
|
||||
System.out.println(updataDsRequest.getConfiguration());
|
||||
System.out.println(updataDsRequest.isConfigurationEncryption());
|
||||
if(updataDsRequest.isConfigurationEncryption()){
|
||||
updataDsRequest.setConfiguration(new String(java.util.Base64.getDecoder().decode(updataDsRequest.getConfiguration())));
|
||||
}
|
||||
System.out.println(updataDsRequest.getConfiguration());
|
||||
checkName(updataDsRequest.getName(), updataDsRequest.getType(), updataDsRequest.getId());
|
||||
Datasource datasource = new Datasource();
|
||||
datasource.setName(updataDsRequest.getName());
|
||||
@ -292,8 +299,10 @@ public class DatasourceService {
|
||||
}
|
||||
}
|
||||
|
||||
public ResultHolder validate(Datasource datasource) throws Exception {
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
public ResultHolder validate(DatasourceDTO datasource) throws Exception {
|
||||
if(datasource.isConfigurationEncryption()){
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
}
|
||||
DatasourceDTO datasourceDTO = new DatasourceDTO();
|
||||
BeanUtils.copyBean(datasourceDTO, datasource);
|
||||
try {
|
||||
@ -381,8 +390,10 @@ public class DatasourceService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getSchema(Datasource datasource) throws Exception {
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
public List<String> getSchema(DatasourceDTO datasource) throws Exception {
|
||||
if(datasource.isConfigurationEncryption()){
|
||||
datasource.setConfiguration(new String(java.util.Base64.getDecoder().decode(datasource.getConfiguration())));
|
||||
}
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
|
@ -11,6 +11,7 @@ import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.request.panel.PanelAppTemplateApplyRequest;
|
||||
import io.dataease.controller.request.panel.PanelAppTemplateRequest;
|
||||
import io.dataease.controller.request.panel.PanelGroupRequest;
|
||||
import io.dataease.dto.DatasourceDTO;
|
||||
import io.dataease.ext.ExtPanelAppTemplateMapper;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.PanelAppTemplateMapper;
|
||||
@ -142,9 +143,9 @@ public class PanelAppTemplateService {
|
||||
if (PanelConstants.APP_DATASOURCE_FROM.HISTORY.equals(request.getDatasourceFrom())) {
|
||||
datasourceRealMap.put(oldDatasourceList.get(0).getId(), request.getDatasourceHistoryId());
|
||||
} else {
|
||||
List<Datasource> newDatasourceList = request.getDatasourceList();
|
||||
List<DatasourceDTO> newDatasourceList = request.getDatasourceList();
|
||||
for (int i = 0; i < newDatasourceList.size(); i++) {
|
||||
Datasource datasource = newDatasourceList.get(0);
|
||||
DatasourceDTO datasource = newDatasourceList.get(0);
|
||||
datasource.setId(null);
|
||||
Datasource newDatasource = datasourceService.addDatasource(datasource);
|
||||
datasourceRealMap.put(oldDatasourceList.get(i).getId(), newDatasource.getId());
|
||||
@ -392,7 +393,7 @@ public class PanelAppTemplateService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void editDatasource(List<Datasource> updateDatasourceList) throws Exception {
|
||||
public void editDatasource(List<DatasourceDTO> updateDatasourceList) throws Exception {
|
||||
for (int i = 0; i < updateDatasourceList.size(); i++) {
|
||||
UpdataDsRequest updataDsRequest = new UpdataDsRequest();
|
||||
BeanUtils.copyBean(updataDsRequest, updateDatasourceList.get(i));
|
||||
|
@ -128,6 +128,14 @@ export function fieldListWithPermission(id, showLoading = true) {
|
||||
})
|
||||
}
|
||||
|
||||
export function datasetParams(id, type, showLoading = true) {
|
||||
return request({
|
||||
url: '/dataset/table/params/' + id + '/' + type,
|
||||
loading: showLoading,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
export function fieldListDQ(id, showLoading = true) {
|
||||
return request({
|
||||
url: '/dataset/field/listByDQ/' + id,
|
||||
|
@ -274,6 +274,7 @@
|
||||
:widget="widget"
|
||||
:control-attrs="myAttrs"
|
||||
:child-views="childViews"
|
||||
:dataset-params="datasetParams"
|
||||
/>
|
||||
|
||||
<filter-foot :element="currentElement" />
|
||||
@ -296,10 +297,7 @@ import { queryAuthModel } from '@/api/authModel/authModel'
|
||||
import {
|
||||
mapState
|
||||
} from 'vuex'
|
||||
import {
|
||||
groupTree,
|
||||
fieldListWithPermission
|
||||
} from '@/api/dataset/dataset'
|
||||
import { groupTree, fieldListWithPermission, datasetParams } from '@/api/dataset/dataset'
|
||||
import {
|
||||
paramsWithIds,
|
||||
viewsWithIds
|
||||
@ -386,6 +384,7 @@ export default {
|
||||
viewInfos: [],
|
||||
datasetParams: []
|
||||
},
|
||||
datasetParams: [],
|
||||
currentElement: null,
|
||||
tempTreeData: null,
|
||||
showTips: false
|
||||
@ -735,6 +734,18 @@ export default {
|
||||
this.fieldData = JSON.parse(JSON.stringify(data))
|
||||
})
|
||||
},
|
||||
loadDatasetParams(tableId) {
|
||||
var type = 'TEXT'
|
||||
if (this.widgetInfo.name.indexOf('time') !== -1) {
|
||||
type = 'DATE'
|
||||
}
|
||||
if (this.widgetInfo.name === 'numberSelectWidget') {
|
||||
type = 'NUM'
|
||||
}
|
||||
datasetParams(tableId, type).then(res => {
|
||||
this.datasetParams = res.data
|
||||
})
|
||||
},
|
||||
comLoadField(tableId) {
|
||||
fieldListWithPermission(tableId).then(res => {
|
||||
let data = res.data
|
||||
@ -751,6 +762,7 @@ export default {
|
||||
this.addQueue(row)
|
||||
this.fieldsParent = row
|
||||
this.loadField(row.id)
|
||||
this.loadDatasetParams(row.id)
|
||||
},
|
||||
showNextGroup(row) {
|
||||
this.tempTreeData = JSON.parse(JSON.stringify(row.children))
|
||||
|
@ -184,7 +184,7 @@
|
||||
@change="val => {changeDynamicParams(val, item.name)}"
|
||||
>
|
||||
<el-checkbox
|
||||
v-for="(ele ) in childViews.datasetParams"
|
||||
v-for="(ele ) in allParams"
|
||||
:key="ele.id"
|
||||
:label="ele.id"
|
||||
:disabled="attrs[tabsOption[(index + 1)%2].name + 'Parameters'] && attrs[tabsOption[(index + 1)%2].name + 'Parameters'].includes(ele.id)"
|
||||
@ -276,6 +276,10 @@ export default {
|
||||
element: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
datasetParams: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@ -296,7 +300,8 @@ export default {
|
||||
{ id: 'HH', name: 'HH' },
|
||||
{ id: 'HH:mm', name: 'HH:mm' },
|
||||
{ id: 'HH:mm:ss', name: 'HH:mm:ss' }
|
||||
]
|
||||
],
|
||||
allParams: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -322,6 +327,21 @@ export default {
|
||||
}
|
||||
this.attrs.parameters = parameters
|
||||
}
|
||||
this.allParams = this.childViews.datasetParams
|
||||
}
|
||||
},
|
||||
'datasetParams': {
|
||||
handler(newName, oldName) {
|
||||
if (this.datasetParams.length > 0) {
|
||||
this.allParams = this.childViews.datasetParams
|
||||
for (var j = 0; j < this.datasetParams.length; j++) {
|
||||
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]) {
|
||||
this.allParams.push(this.datasetParams[j])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -712,6 +712,7 @@ export default {
|
||||
} else {
|
||||
data.configuration = Base64.encode(JSON.stringify(data.configuration))
|
||||
}
|
||||
data.configurationEncryption = true
|
||||
if (data.showModel === 'show' && !this.canEdit) {
|
||||
validateDsById(data.id).then(res => {
|
||||
if (res.success) {
|
||||
|
@ -981,6 +981,7 @@ export default {
|
||||
} else {
|
||||
form.configuration = Base64.encode(JSON.stringify(form.configuration))
|
||||
}
|
||||
form.configurationEncryption = true
|
||||
const isAppMarket = this.positionCheck('appMarket')
|
||||
let appApplyForm
|
||||
if (isAppMarket) {
|
||||
@ -1062,6 +1063,7 @@ export default {
|
||||
if (valid) {
|
||||
const data = JSON.parse(JSON.stringify(this.form))
|
||||
data.configuration = Base64.encode(JSON.stringify(data.configuration))
|
||||
data.configurationEncryption = true
|
||||
getSchema(data).then((res) => {
|
||||
this.schemas = res.data
|
||||
this.openMessageSuccess('commons.success')
|
||||
@ -1116,6 +1118,7 @@ export default {
|
||||
} else {
|
||||
data.configuration = Base64.encode(JSON.stringify(data.configuration))
|
||||
}
|
||||
data.configurationEncryption = true
|
||||
if (data.showModel === 'show' && !this.canEdit) {
|
||||
validateDsById(data.id).then((res) => {
|
||||
if (res.success) {
|
||||
|
Loading…
Reference in New Issue
Block a user