From 2d6c22190f83fb05817293ec5edbb0e7f8b0d4a1 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 3 Jun 2021 17:32:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(fix):=E6=95=B0=E6=8D=AE=E6=BA=90=E3=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E3=80=81=E8=A7=86=E5=9B=BE=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=88=86=E7=BB=84=E5=9C=BA=E6=99=AF=E7=AD=89=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E7=BA=A7=E4=B8=8B=E5=90=8D=E7=A7=B0=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E5=94=AF=E4=B8=80=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=96=87=E6=A1=88=EF=BC=9B=E5=90=8C=E4=B8=80=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E4=B8=8B=E7=9B=B8=E5=90=8C=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=90=8C=E5=90=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataset/DataSetTableTaskService.java | 30 +++++++++++++++---- .../resources/i18n/messages_en_US.properties | 5 ++-- .../resources/i18n/messages_zh_CN.properties | 5 ++-- .../resources/i18n/messages_zh_TW.properties | 5 ++-- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskService.java index e99650b809..4a35c5d1d1 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableTaskService.java @@ -1,8 +1,6 @@ package io.dataease.service.dataset; -import io.dataease.base.domain.DatasetTableTask; -import io.dataease.base.domain.DatasetTableTaskExample; -import io.dataease.base.domain.DatasetTableTaskLog; +import io.dataease.base.domain.*; import io.dataease.base.mapper.DatasetTableTaskMapper; import io.dataease.commons.constants.JobStatus; import io.dataease.commons.constants.ScheduleType; @@ -38,7 +36,9 @@ public class DataSetTableTaskService { private DataSetTableService dataSetTableService; @Resource private ExtractDataService extractDataService; + public DatasetTableTask save(DataSetTaskRequest dataSetTaskRequest) throws Exception { + checkName(dataSetTaskRequest); DatasetTableTask datasetTableTask = dataSetTaskRequest.getDatasetTableTask(); dataSetTableService.saveIncrementalConfig(dataSetTaskRequest.getDatasetTableIncrementalConfig()); @@ -60,10 +60,10 @@ public class DataSetTableTaskService { datasetTableTask.setId(UUID.randomUUID().toString()); datasetTableTask.setCreateTime(System.currentTimeMillis()); // SIMPLE 类型,提前占位 - if(datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())){ - if(extractDataService.updateSyncStatus(dataSetTableService.get(datasetTableTask.getTableId()))){ + if (datasetTableTask.getRate().equalsIgnoreCase(ScheduleType.SIMPLE.toString())) { + if (extractDataService.updateSyncStatus(dataSetTableService.get(datasetTableTask.getTableId()))) { throw new Exception(Translator.get("i18n_sync_job_exists")); - }else { + } else { //write log DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog(); datasetTableTaskLog.setTableId(datasetTableTask.getTableId()); @@ -119,4 +119,22 @@ public class DataSetTableTaskService { datasetTableTaskExample.setOrderByClause("create_time desc,name asc"); return datasetTableTaskMapper.selectByExample(datasetTableTaskExample); } + + private void checkName(DataSetTaskRequest dataSetTaskRequest) { + DatasetTableTaskExample datasetTableTaskExample = new DatasetTableTaskExample(); + DatasetTableTaskExample.Criteria criteria = datasetTableTaskExample.createCriteria(); + if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getId())) { + criteria.andIdNotEqualTo(dataSetTaskRequest.getDatasetTableTask().getId()); + } + if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getTableId())) { + criteria.andTableIdEqualTo(dataSetTaskRequest.getDatasetTableTask().getTableId()); + } + if (StringUtils.isNotEmpty(dataSetTaskRequest.getDatasetTableTask().getName())) { + criteria.andNameEqualTo(dataSetTaskRequest.getDatasetTableTask().getName()); + } + List list = datasetTableTaskMapper.selectByExample(datasetTableTaskExample); + if (list.size() > 0) { + throw new RuntimeException(Translator.get("i18n_task_name_repeat")); + } + } } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 0a378bdf4d..9fe4ffeaed 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -241,8 +241,9 @@ i18n_union_field_exists=The same field can't in two dataset i18n_cron_time_error=Start time can't greater then end time i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled i18n_username_exists=ID is already exists -i18n_ds_name_exists=Datasource name exists +i18n_ds_name_exists=Datasource name used i18n_sync_job_exists=There is already a synchronization task running, please try again later i18n_datasource_check_fail=Invalid,please check config i18n_not_find_user=Can not find user. -i18n_sql_not_empty=SQL can not be empty. \ No newline at end of file +i18n_sql_not_empty=SQL can not be empty. +i18n_task_name_repeat=Name is used in same data set \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 46259d26ec..8968ee429a 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -243,8 +243,9 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字 i18n_cron_time_error=开始时间不能大于结束时间 i18n_auth_source_be_canceled=当前资源授权权限已经被取消 i18n_username_exists=用户 ID 已存在 -i18n_ds_name_exists=数据源名称已存在 +i18n_ds_name_exists=数据源名称已被使用 i18n_sync_job_exists=已经有同步任务在运行,稍后重试 i18n_datasource_check_fail=校验失败,请检查配置信息 i18n_not_find_user=未找到用户 -i18n_sql_not_empty=SQL 不能为空 \ No newline at end of file +i18n_sql_not_empty=SQL 不能为空 +i18n_task_name_repeat=同一数据集下任务名称已被使用 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index fd650136bf..9b91c813dc 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -243,8 +243,9 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字 i18n_cron_time_error=開始時間不能大於結束時間 i18n_auth_source_be_canceled=當前資源授權權限已經被取消 i18n_username_exists=用戶ID已存在 -i18n_ds_name_exists=數據源名稱已存在 +i18n_ds_name_exists=數據源名稱已被使用 i18n_sync_job_exists=已經有同步任務在運行,稍後重試 i18n_datasource_check_fail=校驗失敗,請檢查配置信息 i18n_not_find_user=未找到用戶 -i18n_sql_not_empty=SQL 不能為空 \ No newline at end of file +i18n_sql_not_empty=SQL 不能為空 +i18n_task_name_repeat=同一數據集下任務名稱已被使用 \ No newline at end of file