浏览代码

关系添加修改

rgb 6 年之前
父节点
当前提交
dcd36e9c0e

+ 14 - 0
knowledgeman-service/src/main/java/com/diagbot/enums/LexiconTypeEnum.java

@@ -80,11 +80,25 @@ public enum LexiconTypeEnum implements KeyedNamed {
         }
         return null;
     }
+    
+    public static LexiconTypeEnum getEnum(String name) {
+        for (LexiconTypeEnum item : LexiconTypeEnum.values()) {
+            if (item.name.equals(name)) {
+                return item;
+            }
+        }
+        return null;
+    }
 
     public static String getName(Integer key) {
         LexiconTypeEnum item = getEnum(key);
         return item != null ? item.name : null;
     }
+    
+    public static Integer getKey(String name) {
+        LexiconTypeEnum item = getEnum(name);
+        return item != null ? item.key : null;
+    }
 
     @Override
     public int getKey() {

+ 2 - 2
knowledgeman-service/src/main/java/com/diagbot/facade/RelationFacade.java

@@ -196,7 +196,7 @@ public class RelationFacade extends RelationServiceImpl {
 		libraryInfoQe1.eq("is_deleted", "N");
 		libraryInfoQe1.eq("is_concept", 1);
 		libraryInfoQe1.eq("name", addRelationInfoVO.getStartName());
-		libraryInfoQe1.eq("type", addRelationInfoVO.getStartType());
+		libraryInfoQe1.eq("type_id", LexiconTypeEnum.getKey(addRelationInfoVO.getStartType()));
 		LibraryInfo startLibraryInfo = libraryInfoFacade.getOne(libraryInfoQe1);
 		if(startLibraryInfo==null){
 			retMap.put("message", "数据库中无该起始术语!");
@@ -220,7 +220,7 @@ public class RelationFacade extends RelationServiceImpl {
 		libraryInfoQe2.eq("is_deleted", "N");
 		libraryInfoQe2.eq("is_concept", 1);
 		libraryInfoQe2.eq("name", addRelationInfoVO.getEndName());
-		libraryInfoQe2.eq("type", addRelationInfoVO.getEndType());
+		libraryInfoQe2.eq("type", LexiconTypeEnum.getKey(addRelationInfoVO.getEndType()));
 		LibraryInfo endLibraryInfo = libraryInfoFacade.getOne(libraryInfoQe2);
 		if(endLibraryInfo==null){
 			retMap.put("message", "数据库中无该终点术语");