Browse Source

refactor(adm-diagram): 代码优化

liyang 2 years ago
parent
commit
0570988d08

+ 1 - 3
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/controller/DiagramController.java

@@ -104,9 +104,7 @@ public class DiagramController {
             Optional.ofNullable(map.get("lines")).ifPresent(lines ->
                     diagram.setLines(parser.parseContent(parser.toJson(lines), List.class)));
             Optional.ofNullable(map.get("nodes")).ifPresent(nodes -> {
-                DiagramNode[] diagramNodes = parser.parseContent(parser.toJson(nodes), DiagramNode[].class);
-                List<DiagramNode> asList = Arrays.asList(diagramNodes);
-                diagram.setNodes(asList);
+                diagram.setNodes(Arrays.asList(parser.parseContent(parser.toJson(nodes), DiagramNode[].class)));
             });
         });
 

+ 1 - 13
adm-business/adm-diagram/src/main/java/com/persagy/adm/diagram/entity/ModelAdapter.java

@@ -2,16 +2,11 @@ package com.persagy.adm.diagram.entity;
 
 import com.persagy.adm.diagram.core.ContentParser;
 import com.persagy.adm.diagram.core.model.Diagram;
-import com.persagy.adm.diagram.core.model.DiagramNode;
 import com.persagy.adm.diagram.core.model.legend.Legend;
 import com.persagy.adm.diagram.core.model.template.DiagramTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
 /**
  * 运行时模型-实体 类型转换适配器
  *
@@ -66,14 +61,7 @@ public class ModelAdapter {
     }
 
     public Diagram toDiagram(DiagramEntity diagramEntity) {
-        //Diagram diagram = parser.parseContent(diagramEntity.getDiagramContent(), Diagram.class);
-        Diagram diagram = new Diagram();
-        Map map = parser.parseContent(diagramEntity.getDiagramContent(), Map.class);
-        diagram.setLines(parser.parseContent(parser.toJson(map.get("lines")), List.class));
-        DiagramNode[] nodes = parser.parseContent(parser.toJson(map.get("nodes")), DiagramNode[].class);
-        List<DiagramNode> diagramNodes = Arrays.asList(nodes);
-        diagram.setNodes(diagramNodes);
-
+        Diagram diagram = parser.parseContent(diagramEntity.getDiagramContent(), Diagram.class);
         diagram.setId(diagramEntity.getId());
         diagram.setName(diagramEntity.getName());
         diagram.setRemark(diagramEntity.getRemark());