refactor: 复制视图名称不重复

This commit is contained in:
wangjiahao 2022-03-30 20:15:02 +08:00
parent 4f30b4e40f
commit c0682bcdc8
2 changed files with 9 additions and 2 deletions

View File

@ -187,11 +187,11 @@
`senior`,
`data_from`)
SELECT #{newChartId},
`name`,
GET_CHART_VIEW_COPY_NAME(#{oldChartId},#{panelId}) as `name`,
#{panelId},
`table_id`,
`type`,
`title`,
GET_CHART_VIEW_COPY_NAME(#{oldChartId},#{panelId}) as `title`,
`x_axis`,
`x_axis_ext`,
`y_axis`,

View File

@ -116,6 +116,13 @@ public class ChartViewService {
public ChartViewWithBLOBs newOne(ChartViewWithBLOBs chartView) {
long timestamp = System.currentTimeMillis();
// 校验名称
ChartViewExample queryExample = new ChartViewExample();
queryExample.createCriteria().andSceneIdEqualTo(chartView.getSceneId()).andNameEqualTo(chartView.getName());
List<ChartView> result = chartViewMapper.selectByExample(queryExample);
if(CollectionUtils.isNotEmpty(result)){
DEException.throwException(Translator.get("theme_name_repeat"));
}
chartView.setUpdateTime(timestamp);
chartView.setId(UUID.randomUUID().toString());
chartView.setCreateBy(AuthUtils.getUser().getUsername());