diff --git a/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java b/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java index 9f5150a431..bdc787d6b2 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartGroupService.java @@ -1,9 +1,6 @@ package io.dataease.service.chart; -import io.dataease.base.domain.ChartGroup; -import io.dataease.base.domain.ChartGroupExample; -import io.dataease.base.domain.DatasetGroup; -import io.dataease.base.domain.DatasetTable; +import io.dataease.base.domain.*; import io.dataease.base.mapper.ChartGroupMapper; import io.dataease.commons.utils.BeanUtils; import io.dataease.controller.request.chart.ChartGroupRequest; @@ -28,6 +25,7 @@ public class ChartGroupService { private ChartViewService chartViewService; public ChartGroupDTO save(ChartGroup chartGroup) { + checkName(chartGroup); if (StringUtils.isEmpty(chartGroup.getId())) { chartGroup.setId(UUID.randomUUID().toString()); chartGroup.setCreateTime(System.currentTimeMillis()); @@ -125,4 +123,25 @@ public class ChartGroupService { } return ids; } + + private void checkName(ChartGroup chartGroup) { + ChartGroupExample chartGroupExample = new ChartGroupExample(); + ChartGroupExample.Criteria criteria = chartGroupExample.createCriteria(); + if (StringUtils.isNotEmpty(chartGroup.getPid())) { + criteria.andPidEqualTo(chartGroup.getPid()); + } + if (StringUtils.isNotEmpty(chartGroup.getType())) { + criteria.andTypeEqualTo(chartGroup.getType()); + } + if (StringUtils.isNotEmpty(chartGroup.getName())) { + criteria.andNameEqualTo(chartGroup.getName()); + } + if (StringUtils.isNotEmpty(chartGroup.getId())) { + criteria.andIdNotEqualTo(chartGroup.getId()); + } + List list = chartGroupMapper.selectByExample(chartGroupExample); + if (list.size() > 0) { + throw new RuntimeException("Name can't repeat in same group."); + } + } } diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java index 2abaef77d6..7a68bd83ff 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java @@ -30,6 +30,7 @@ public class DataSetGroupService { private DataSetTableService dataSetTableService; public DataSetGroupDTO save(DatasetGroup datasetGroup) { + checkName(datasetGroup); if (StringUtils.isEmpty(datasetGroup.getId())) { datasetGroup.setId(UUID.randomUUID().toString()); datasetGroup.setCreateTime(System.currentTimeMillis()); @@ -132,4 +133,25 @@ public class DataSetGroupService { } return ids; } + + private void checkName(DatasetGroup datasetGroup) { + DatasetGroupExample datasetGroupExample = new DatasetGroupExample(); + DatasetGroupExample.Criteria criteria = datasetGroupExample.createCriteria(); + if (StringUtils.isNotEmpty(datasetGroup.getPid())) { + criteria.andPidEqualTo(datasetGroup.getPid()); + } + if (StringUtils.isNotEmpty(datasetGroup.getType())) { + criteria.andTypeEqualTo(datasetGroup.getType()); + } + if (StringUtils.isNotEmpty(datasetGroup.getName())) { + criteria.andNameEqualTo(datasetGroup.getName()); + } + if (StringUtils.isNotEmpty(datasetGroup.getId())) { + criteria.andIdNotEqualTo(datasetGroup.getId()); + } + List list = datasetGroupMapper.selectByExample(datasetGroupExample); + if (list.size() > 0) { + throw new RuntimeException("Name can't repeat in same group."); + } + } } diff --git a/backend/src/main/java/io/dataease/service/spark/SparkCalc.java b/backend/src/main/java/io/dataease/service/spark/SparkCalc.java index ef905453ab..dea6b5aa63 100644 --- a/backend/src/main/java/io/dataease/service/spark/SparkCalc.java +++ b/backend/src/main/java/io/dataease/service/spark/SparkCalc.java @@ -16,7 +16,6 @@ import org.apache.spark.api.java.JavaPairRDD; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.api.java.function.FlatMapFunction; -import org.apache.spark.api.java.function.Function; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; import org.apache.spark.sql.RowFactory;