|
@@ -13,7 +13,7 @@ import com.persagy.adm.diagram.core.model.base.Container;
|
|
|
import com.persagy.adm.diagram.core.model.base.IComponent;
|
|
|
import com.persagy.adm.diagram.core.model.template.DiagramTemplate;
|
|
|
import com.persagy.adm.diagram.frame.BdtpRequest;
|
|
|
-import com.persagy.adm.diagram.manage.DemoDiagramManager;
|
|
|
+import com.persagy.adm.diagram.manage.DiagramManager;
|
|
|
import com.persagy.dmp.common.constant.ResponseCode;
|
|
|
import com.persagy.dmp.common.exception.BusinessException;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
@@ -21,18 +21,9 @@ import com.persagy.dmp.common.utils.ResultHelper;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
* 系统图相关接口
|
|
@@ -48,7 +39,7 @@ public class DiagramController {
|
|
|
@Qualifier("dataStrategyImpl")
|
|
|
private DataStrategy dataStrategy;
|
|
|
@Autowired
|
|
|
- private DemoDiagramManager diagramManager;
|
|
|
+ private DiagramManager diagramManager;
|
|
|
@Autowired
|
|
|
private ContentParser parser;
|
|
|
|
|
@@ -84,29 +75,31 @@ public class DiagramController {
|
|
|
public CommonResult<Diagram> newDiagram(@RequestBody Map<String, Object> params,
|
|
|
@RequestParam String projectId,
|
|
|
@RequestParam String groupCode) {
|
|
|
- Diagram diagram = new Diagram();
|
|
|
+ Diagram diagram = diagramManager.fromMapData(params);
|
|
|
diagram.setGroupCode(groupCode);
|
|
|
diagram.setProjectId(projectId);
|
|
|
|
|
|
- Optional.ofNullable(params).ifPresent(map -> {
|
|
|
- Optional.ofNullable(map.get("id")).ifPresent(o -> diagram.setId(String.valueOf(o)));
|
|
|
- Optional.ofNullable(map.get("type")).ifPresent(o -> {
|
|
|
- if (String.valueOf(o).length() < 4) {
|
|
|
- throw new BusinessException(ResponseCode.A0400.getCode(), "type参数非法");
|
|
|
- }
|
|
|
- diagram.setType(String.valueOf(o));
|
|
|
- diagram.setSystem(String.valueOf(o).substring(0, 4));
|
|
|
- });
|
|
|
- Optional.ofNullable(map.get("systemId")).ifPresent(o -> diagram.setSystemId(String.valueOf(o)));
|
|
|
- Optional.ofNullable(map.get("name")).ifPresent(o -> diagram.setName(String.valueOf(o)));
|
|
|
- Optional.ofNullable(map.get("remark")).ifPresent(o -> diagram.setRemark(String.valueOf(o)));
|
|
|
- Optional.ofNullable(map.get("templateId")).ifPresent(o -> diagram.setTemplateId(String.valueOf(o)));
|
|
|
- Optional.ofNullable(map.get("extraProps")).ifPresent(s -> {
|
|
|
- Map<String, Object> m = parser.parseContent(parser.toJson(s), Map.class);
|
|
|
- diagram.setExtraProp("state", m.get("state"));
|
|
|
- });
|
|
|
- buildLinesAndNodes(diagram, map);
|
|
|
- });
|
|
|
+ diagramManager.buildDiagram(diagram);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
return ResultHelper.single(dataStrategy.saveDiagram(diagram));
|
|
|
}
|
|
@@ -166,7 +159,7 @@ public class DiagramController {
|
|
|
@GetMapping("/getDiagram")
|
|
|
public CommonResult<Diagram> getDiagram(String diagramId) {
|
|
|
Diagram diagram = dataStrategy.getDiagram(diagramId);
|
|
|
- diagramManager.buildDiagram(diagram, true);
|
|
|
+ diagramManager.buildDiagram(diagram);
|
|
|
return ResultHelper.single(diagram);
|
|
|
}
|
|
|
|
|
@@ -250,7 +243,11 @@ public class DiagramController {
|
|
|
@ApiOperation("加载数据")
|
|
|
@PostMapping("/loadData")
|
|
|
public CommonResult<Diagram> loadData(@RequestBody Diagram diagram) {
|
|
|
- return ResultHelper.single(diagramManager.loadData(diagram.getId(), true));
|
|
|
+ diagram = dataStrategy.getDiagram(diagram.getId());
|
|
|
+ if(diagram == null) {
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(), "系统图id不存在");
|
|
|
+ }
|
|
|
+ return ResultHelper.single(diagramManager.loadData(diagram));
|
|
|
}
|
|
|
|
|
|
|