Bladeren bron

看板更新接口BUG修改

chenw 7 jaren geleden
bovenliggende
commit
c1770975c3

+ 16 - 5
bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsService.java

@@ -76,11 +76,22 @@ public class DashboardsService {
         }
         dashboardsMapper.updateDashboards(dashboards);
         //更新报表图表关系
-        String oldChartIds = dashboardsMapper.getChartIdsById(dashboardsInfo.getId());
-        if (!StringUtils.isEmpty(oldChartIds) && !oldChartIds.equals(dashboardsInfo.getChartIds())) {
-            dashboardsMapper.deleteDashboardChartRelation(dashboardsInfo.getId());
-            if (!StringUtils.isEmpty(dashboardsInfo.getChartIds())) {
-                dashboardsMapper.saveDashboardChartRelation(dashboardsInfo.getId(), dashboardsInfo.getChartIds().split(","));
+        int dashboardId = dashboardsInfo.getId();
+        String chartIds = dashboardsInfo.getChartIds();
+        String oldChartIds = dashboardsMapper.getChartIdsById(dashboardId);
+        if (!StringUtils.isEmpty(oldChartIds)) {
+            if (StringUtils.isEmpty(chartIds)) {    //旧不为空 & 新为空
+                dashboardsMapper.deleteDashboardChartRelation(dashboardId);
+            }else {                                 //旧不为空 & 新不为空
+                if (!oldChartIds.equals(dashboardsInfo.getChartIds())) {
+                    dashboardsMapper.deleteDashboardChartRelation(dashboardId);
+                    dashboardsMapper.saveDashboardChartRelation(dashboardId, chartIds.split(","));
+                }
+            }
+        }else {
+            //旧为空  & 新不为空
+            if (!StringUtils.isEmpty(chartIds)) {
+                dashboardsMapper.saveDashboardChartRelation(dashboardId, chartIds.split(","));
             }
         }
         return new RepEntity(RepCode.success);