Merge pull request #4434 from dataease/pr@dev@refactor_edit_field

refactor(数据集): 非直连数据集修改字段前需完成数据同步
This commit is contained in:
Junjun 2023-02-01 10:31:47 +08:00 committed by GitHub
commit 6b1e3cb370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -155,8 +155,14 @@ public class DataSetTableFieldController {
public DatasetTableField save(@RequestBody DatasetTableField datasetTableField) {
dataSetTableFieldsService.checkFieldName(datasetTableField);
try {
// 执行一次sql确保数据集中所有字段均能正确执行
// 非直连数据集需先完成数据同步
DatasetTable datasetTable = dataSetTableService.get(datasetTableField.getTableId());
if (datasetTable.getMode() == 1) {
if (!dataSetTableService.checkEngineTableIsExists(datasetTableField.getTableId())) {
throw new RuntimeException(Translator.get("i18n_data_not_sync"));
}
}
// 执行一次sql确保数据集中所有字段均能正确执行
DataSetTableRequest dataSetTableRequest = new DataSetTableRequest();
BeanUtils.copyProperties(datasetTable, dataSetTableRequest);
dataSetTableService.getPreviewData(dataSetTableRequest, 1, 1, Collections.singletonList(datasetTableField), null);