Преглед изворни кода

修复添加菜单报错问题

dzx пре 10 месеци
родитељ
комит
1300fa7003
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5 2
      src/main/java/com/xjrsoft/module/system/controller/MenuController.java

+ 5 - 2
src/main/java/com/xjrsoft/module/system/controller/MenuController.java

@@ -251,9 +251,12 @@ public class MenuController {
 
 
         //多选
         //多选
         List<XjrMenuDeptRelation> menuDeptRelationsList = new ArrayList<>();
         List<XjrMenuDeptRelation> menuDeptRelationsList = new ArrayList<>();
-        for (AddXjrMenuDeptRelationDto addXjrMenuDeptRelationDto : dto.getMenuDeptRelations()) {
-            menuDeptRelationsList.add(BeanUtil.toBean(addXjrMenuDeptRelationDto, XjrMenuDeptRelation.class));
+        if(dto.getMenuDeptRelations() != null){
+            for (AddXjrMenuDeptRelationDto addXjrMenuDeptRelationDto : dto.getMenuDeptRelations()) {
+                menuDeptRelationsList.add(BeanUtil.toBean(addXjrMenuDeptRelationDto, XjrMenuDeptRelation.class));
+            }
         }
         }
+
         menuDeptRelationsList.forEach(XjrMenuDeptRelation -> XjrMenuDeptRelation.setMenuId(menu.getId()));
         menuDeptRelationsList.forEach(XjrMenuDeptRelation -> XjrMenuDeptRelation.setMenuId(menu.getId()));
         xjrMenuDeptRelationService.remove(Wrappers.<XjrMenuDeptRelation>query().lambda().eq(XjrMenuDeptRelation::getMenuId, menu.getId()));
         xjrMenuDeptRelationService.remove(Wrappers.<XjrMenuDeptRelation>query().lambda().eq(XjrMenuDeptRelation::getMenuId, menu.getId()));
         xjrMenuDeptRelationService.saveBatch(menuDeptRelationsList);
         xjrMenuDeptRelationService.saveBatch(menuDeptRelationsList);