diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index c133f0d7f8..1c835c47d3 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -75,13 +75,14 @@ public class ChartViewService { checkName(chartView); long timestamp = System.currentTimeMillis(); chartView.setUpdateTime(timestamp); - int i = chartViewMapper.updateByPrimaryKeySelective(chartView); - if (i == 0) { + if (ObjectUtils.isEmpty(chartView.getId())) { chartView.setId(UUID.randomUUID().toString()); chartView.setCreateBy(AuthUtils.getUser().getUsername()); chartView.setCreateTime(timestamp); chartView.setUpdateTime(timestamp); chartViewMapper.insertSelective(chartView); + } else { + chartViewMapper.updateByPrimaryKeySelective(chartView); } Optional.ofNullable(chartView.getId()).ifPresent(id -> { CacheUtils.remove(JdbcConstants.VIEW_CACHE_KEY, id); @@ -216,8 +217,10 @@ public class ChartViewService { if (ObjectUtils.isEmpty(view)) { throw new RuntimeException(Translator.get("i18n_chart_delete")); } - List xAxis = new Gson().fromJson(view.getXAxis(), new TypeToken>() {}.getType()); - List yAxis = new Gson().fromJson(view.getYAxis(), new TypeToken>() {}.getType()); + List xAxis = new Gson().fromJson(view.getXAxis(), new TypeToken>() { + }.getType()); + List yAxis = new Gson().fromJson(view.getYAxis(), new TypeToken>() { + }.getType()); if (StringUtils.equalsIgnoreCase(view.getType(), "chart-mix")) { List yAxisExt = new Gson().fromJson(view.getYAxisExt(), new TypeToken>() { }.getType());