Browse Source

修复添加菜单报错问题

dzx 10 months ago
parent
commit
1300fa7003

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

@@ -251,9 +251,12 @@ public class MenuController {
 
         //多选
         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()));
         xjrMenuDeptRelationService.remove(Wrappers.<XjrMenuDeptRelation>query().lambda().eq(XjrMenuDeptRelation::getMenuId, menu.getId()));
         xjrMenuDeptRelationService.saveBatch(menuDeptRelationsList);