Browse Source

更新图谱节点基类信息

MarkHuang 4 years ago
parent
commit
e8a4305713

+ 59 - 2
src/main/java/com/diagbot/facade/EntityFacade.java

@@ -1,9 +1,14 @@
 package com.diagbot.facade;
 
 import com.diagbot.dto.NeoEntityDTO;
+import com.diagbot.entity.node.Symptom;
+import com.diagbot.entity.node.base.BaseNode;
 import com.diagbot.repository.*;
+import com.diagbot.util.GenericNode;
+import com.diagbot.util.StringUtil;
 import com.diagbot.vo.*;
 
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Component;
@@ -25,6 +30,9 @@ public class EntityFacade {
     @Autowired
     BaseNodeRepository baseNodeRepository;
 
+    @Autowired
+    SymptomNameRepository symptomNameRepository;
+
     @Autowired
     LisNameRepository lisRepository;
 
@@ -39,11 +47,37 @@ public class EntityFacade {
     }
 
 
-    public void initEntity() {
-        List<String> labels = getLabels();
+    public List<BaseNode> getNodes(KgQueryVO kgQueryVO) {
+
+        List<BaseNode> baseNodes = new ArrayList<>();
+
+        String label = kgQueryVO.getStartLabel().trim();
+        String name = kgQueryVO.getStartName();
+
+        try {
+            if (StringUtil.isNotBlank(label) && StringUtil.isNotBlank(name)) {
+                if (Constants.node_Labels.contains(label)) {
+                    switch (label) {
+                        case "症状":
+                            List<Symptom> symptoms = symptomNameRepository.findByNameIs(name);
+                            GenericNode<Symptom> sNodes = new GenericNode<>();
+                            baseNodes = sNodes.fillNodeTree(symptoms);
+                            break;
+                    }
 
+                }
+            }
+        }
+        catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        finally {
+            return baseNodes;
+        }
     }
 
+
+
     public NeoEntityDTO updateNeoNode(NeoEntityVO neoEntityVO) {
 
         List<String> keys;
@@ -130,4 +164,27 @@ public class EntityFacade {
     }
 
 
+    /**
+     * 删除节点
+     * @param neoEntityVO
+     * @return
+     */
+    public int deleteNeoNode(NeoEntityVO neoEntityVO) {
+        int cnt = 0;
+
+        try {
+            if (null != neoEntityVO.getID()) {
+                long id = neoEntityVO.getID();
+                BaseNode node = baseNodeRepository.findById(id);
+                cnt = 1;
+//                baseNodeRepository.delete(node);
+            }
+        }
+        catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        finally {
+            return cnt;
+        }
+    }
 }

+ 11 - 4
src/main/java/com/diagbot/vo/KgQueryVO.java

@@ -14,10 +14,17 @@ import javax.validation.constraints.NotBlank;
 @Getter
 @Setter
 public class KgQueryVO {
-    @ApiModelProperty(value = "标签名")
+
+    @ApiModelProperty(value = "起始节点标签名")
     @NotBlank(message = "标签名不能为空")
-    private String labelName;
-    @ApiModelProperty(value = "搜索内容")
+    private String startLabel;
+    @ApiModelProperty(value = "起始节点名")
     @NotBlank(message = "搜索内容不能为空")
-    private String inputStr;
+    private String startName;
+    @ApiModelProperty(value = "关系名")
+    private String relName;
+    @ApiModelProperty(value = "终结节点标签名")
+    private String endLabel;
+    @ApiModelProperty(value = "终结节点名")
+    private String endName;
 }