Ver Fonte

fix:解决动态表格bug

xuezizhuo há 1 ano atrás
pai
commit
8696dbf56a

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragTableBtnRelevanceServiceImpl.java

@@ -71,7 +71,9 @@ public class DragTableBtnRelevanceServiceImpl implements IDragTableBtnRelevanceS
         // delete
         dragTableBtnRelevanceMapper.deleteDragTableBtnRelevanceByTableKey(dragTableVo.getTableKey());
         // insert
-        dragTableBtnRelevanceMapper.batchInsertDragTableBtnRelevance(dragTableVo.getDragTableBtnRelevanceList());
+        if(dragTableVo.getDragTableBtnRelevanceList().size() > 0){
+            dragTableBtnRelevanceMapper.batchInsertDragTableBtnRelevance(dragTableVo.getDragTableBtnRelevanceList());
+        }
     }
 
     /**

+ 17 - 14
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/DragTableServiceImpl.java

@@ -159,26 +159,29 @@ public class DragTableServiceImpl implements IDragTableService {
         dragTableStyle.setTableKey(dragTable.getTableKey());
         List<DragTableStyle> dragTableStyleList = dragTableStyleMapper.selectDragTableStyleList(dragTableStyle);
         resultMap.put("style",dragTableStyleList);
+        CommonEntity commonEntity = new CommonEntity();
         // 动态表格按钮信息
         //根据tableKey获取根节点信息
         List<String> btnKeys = dragTableBtnRelevanceMapper.selectBtnKeyByTableKey(dragTable.getTableKey());
         //获取根节点数据
         System.err.println(btnKeys.toString());
-        List<DragTableBtn> rootNodes = dragTableBtnMapper.selectDragTableBtnListByBtnKey(btnKeys);
-        System.err.println(rootNodes.toString());
-        //查询子节点
-        List<Long> ids = rootNodes.stream().map(m -> m.getId()).collect(Collectors.toList());
-        if (ids.isEmpty()){
-            resultMap.put("button",rootNodes);
-        }else {
-            List<DragTableBtn> childNodes = dragTableBtnMapper.selectChildNodeById(ids);
-            List<DragTableBtn> btnList = rootNodes.stream().peek(
-                    root -> root.setChildren(getChildrenList(root, childNodes))
-            ).collect(Collectors.toList());
-            resultMap.put("button",btnList);
+        if(btnKeys.size() > 0){
+            List<DragTableBtn> rootNodes = dragTableBtnMapper.selectDragTableBtnListByBtnKey(btnKeys);
+            System.err.println(rootNodes.toString());
+            //查询子节点
+            List<Long> ids = rootNodes.stream().map(m -> m.getId()).collect(Collectors.toList());
+            if (ids.isEmpty()){
+                resultMap.put("button",rootNodes);
+            }else {
+                List<DragTableBtn> childNodes = dragTableBtnMapper.selectChildNodeById(ids);
+                List<DragTableBtn> btnList = rootNodes.stream().peek(
+                        root -> root.setChildren(getChildrenList(root, childNodes))
+                ).collect(Collectors.toList());
+                resultMap.put("button",btnList);
+            }
+
+            commonEntity.setResultMap(resultMap);
         }
-        CommonEntity commonEntity = new CommonEntity();
-        commonEntity.setResultMap(resultMap);
         return commonEntity;
     }