forked from github/dataease
feat: 修改API 数据集名称时,同步修改数据集里的表名
This commit is contained in:
parent
13ba5a52a6
commit
5d22d1e720
@ -26,5 +26,7 @@ public class ApiDefinition {
|
||||
private boolean useJsonPath;
|
||||
private String jsonPath;
|
||||
private boolean showApiStructure;
|
||||
private boolean reName = false;
|
||||
private String orgName;
|
||||
|
||||
}
|
||||
|
@ -284,7 +284,6 @@ public class DatasourceService {
|
||||
datasource.setUpdateTime(System.currentTimeMillis());
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(updataDsRequest.getType());
|
||||
datasourceProvider.checkConfiguration(datasource);
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
updateDatasource(updataDsRequest.getId(), datasource);
|
||||
}
|
||||
|
||||
@ -295,6 +294,28 @@ public class DatasourceService {
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
datasourceMapper.updateByExampleSelective(datasource, example);
|
||||
handleConnectionPool(id);
|
||||
|
||||
if (datasource.getType().equalsIgnoreCase("api")) {
|
||||
DatasetTableExample datasetTableExample = new DatasetTableExample();
|
||||
datasetTableExample.createCriteria().andDataSourceIdEqualTo(id);
|
||||
List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(datasetTableExample);
|
||||
List<ApiDefinition> apiDefinitionList = new Gson().fromJson(datasource.getConfiguration(), new TypeToken<List<ApiDefinition>>() {}.getType());
|
||||
apiDefinitionList.forEach(apiDefinition -> {
|
||||
if(apiDefinition.isReName()){
|
||||
datasetTables.forEach(datasetTable -> {
|
||||
if(new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable().equals(apiDefinition.getOrgName())){
|
||||
DatasetTable record = new DatasetTable();
|
||||
DataTableInfoDTO dataTableInfoDTO = new DataTableInfoDTO();
|
||||
dataTableInfoDTO.setTable(apiDefinition.getName());
|
||||
record.setInfo(new Gson().toJson(dataTableInfoDTO));
|
||||
datasetTableExample.clear();
|
||||
datasetTableExample.createCriteria().andIdEqualTo(datasetTable.getId());
|
||||
datasetTableMapper.updateByExampleSelective(record, datasetTableExample);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleConnectionPool(String datasourceId) {
|
||||
|
@ -1223,14 +1223,15 @@ export default {
|
||||
this.edit_api_item = false
|
||||
if (!this.add_api_item) {
|
||||
for (let i = 0; i < this.form.apiConfiguration.length; i++) {
|
||||
if (
|
||||
this.form.apiConfiguration[i].serialNumber ===
|
||||
this.apiItem.serialNumber
|
||||
) {
|
||||
this.form.apiConfiguration[i] = JSON.parse(
|
||||
JSON.stringify(this.apiItem)
|
||||
)
|
||||
if (this.form.apiConfiguration[i].serialNumber === this.apiItem.serialNumber) {
|
||||
this.certinKey = !this.certinKey
|
||||
if(this.form.apiConfiguration[i].name !== this.apiItem.name){
|
||||
this.apiItem.reName = true
|
||||
this.apiItem.orgName = this.form.apiConfiguration[i].name
|
||||
}else {
|
||||
this.apiItem.reName = false
|
||||
}
|
||||
this.form.apiConfiguration[i] = JSON.parse(JSON.stringify(this.apiItem))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user