Bläddra i källkod

解决模型绑定后,设备楼层ID、建筑ID为空问题

yucheng 3 år sedan
förälder
incheckning
a5254a0611

+ 7 - 4
src/main/java/com/persagy/proxy/adm/utils/AdmEntityTransferUtil.java

@@ -2,6 +2,7 @@ package com.persagy.proxy.adm.utils;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
@@ -45,17 +46,19 @@ public class AdmEntityTransferUtil {
                 continue;
             }
             ArrayNode nullList = (ArrayNode) nullNode;
+            ArrayNode removeNode = jsonNode.putArray("$remove");
             for(int k=0; k < nullList.size(); k++){
                 String node = nullList.get(k).textValue();
+                if(StrUtil.isBlank(node)) {
+                    continue;
+                }
                 if(node.startsWith("infos.")){
                     node = node.replace("infos.","");
-                    jsonNode.remove(node);
-                    nullList.remove(i);
-                    nullList.add(node);
                 }
+                jsonNode.remove(node);
+                removeNode.add(node);
             }
             jsonNode.remove("nullList");
-            jsonNode.putPOJO("$remove", nullList);
         }
         return arrayNode;
     }