소스 검색

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

zhoupeng 1 년 전
부모
커밋
0b3076a2b7
1개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/ChartServiceImpl.java

+ 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();