Ver código fonte

验证饼状图只能选择一个数据项

zhoupeng 1 ano atrás
pai
commit
0b3076a2b7

+ 12 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/ChartServiceImpl.java

@@ -50,6 +50,12 @@ public class ChartServiceImpl implements ChartService {
         Integer id = chart.getId();
         List<ChartItem> chartItemList = chart.getChartItemList();
         if (Blank.isNotEmpty(chartItemList)) {
+            String chartType = chart.getChartType();
+            if (chartType.equals(ConstantStr.BAR_CHART)) {
+                if (chartItemList.size() != 1) {
+                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "饼状图只能配置一个数据项");
+                }
+            }
             chartDao.addChartItem(id, chartItemList);
         }
         List<UserGroup> userGroupList = chart.getUserGroupList();
@@ -69,6 +75,12 @@ public class ChartServiceImpl implements ChartService {
         chartDao.delChartUserGroup(id);
         List<ChartItem> chartItemList = chart.getChartItemList();
         if (Blank.isNotEmpty(chartItemList)) {
+            String chartType = chart.getChartType();
+            if (chartType.equals(ConstantStr.BAR_CHART)) {
+                if (chartItemList.size() != 1) {
+                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "饼状图只能配置一个数据项");
+                }
+            }
             chartDao.addChartItem(id, chartItemList);
         }
         List<UserGroup> userGroupList = chart.getUserGroupList();