浏览代码

调整/special/listToTree接口

Feick 5 年之前
父节点
当前提交
c7cc64f722

+ 31 - 53
src/main/java/com/yaoxiang/diagnosis/entity/SpecialKnowledge.java

@@ -11,13 +11,16 @@ public class SpecialKnowledge {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
 
+    @ApiModelProperty("科目")
     private Long subjectId;
 
+    @ApiModelProperty("年级")
     private String grade;
 
     @ApiModelProperty("知识点类别")
     private String category;
 
+    @ApiModelProperty("层级")
     private Integer level;
 
 //    @ApiModelProperty("开头两位数字表示层级,之后每两位表示一个层级 01010101")
@@ -37,17 +40,24 @@ public class SpecialKnowledge {
     @ApiModelProperty("父Id")
     private Long parentId;
 
-    @ApiModelProperty("第1级Id")
-    private Long rootId1;
-    private String root1;
+//    @ApiModelProperty("第1级Id")
+//    private Long rootId1;
+//    private String root1;
 
-    @ApiModelProperty("第2级Id")
-    private Long rootId2;
-    private String root2;
+//    @ApiModelProperty("第2级Id")
+//    private Long rootId2;
+//    private String root2;
 
-    @ApiModelProperty("第3级Id")
-    private Long rootId3;
-    private String root3;
+//    @ApiModelProperty("第3级Id")
+//    private Long rootId3;
+//    private String root3;
+
+    @Transient
+    @ApiModelProperty("掌握率")
+    private Double master;
+    @Transient
+    @ApiModelProperty("掌握情况")
+    private Double masterStatus;
 
     @Transient
     private SpecialKnowledge parent;
@@ -127,30 +137,6 @@ public class SpecialKnowledge {
         this.parentId = parentId;
     }
 
-    public Long getRootId1() {
-        return rootId1;
-    }
-
-    public void setRootId1(Long rootId1) {
-        this.rootId1 = rootId1;
-    }
-
-    public Long getRootId2() {
-        return rootId2;
-    }
-
-    public void setRootId2(Long rootId2) {
-        this.rootId2 = rootId2;
-    }
-
-    public Long getRootId3() {
-        return rootId3;
-    }
-
-    public void setRootId3(Long rootId3) {
-        this.rootId3 = rootId3;
-    }
-
     public SpecialKnowledge getParent() {
         return parent;
     }
@@ -159,36 +145,28 @@ public class SpecialKnowledge {
         this.parent = parent;
     }
 
-    public String getRoot1() {
-        return root1;
-    }
-
-    public void setRoot1(String root1) {
-        this.root1 = root1;
-    }
-
-    public String getRoot2() {
-        return root2;
+    public List<SpecialKnowledge> getChildren() {
+        return children;
     }
 
-    public void setRoot2(String root2) {
-        this.root2 = root2;
+    public void setChildren(List<SpecialKnowledge> children) {
+        this.children = children;
     }
 
-    public String getRoot3() {
-        return root3;
+    public Double getMaster() {
+        return master;
     }
 
-    public void setRoot3(String root3) {
-        this.root3 = root3;
+    public void setMaster(Double master) {
+        this.master = master;
     }
 
-    public List<SpecialKnowledge> getChildren() {
-        return children;
+    public Double getMasterStatus() {
+        return masterStatus;
     }
 
-    public void setChildren(List<SpecialKnowledge> children) {
-        this.children = children;
+    public void setMasterStatus(Double masterStatus) {
+        this.masterStatus = masterStatus;
     }
 
     @Override

+ 1 - 4
src/main/java/com/yaoxiang/diagnosis/service/SpecialKnowledgeService.java

@@ -46,10 +46,7 @@ public class SpecialKnowledgeService {
             }
             //找到子
             for (SpecialKnowledge treeNode : list) {
-                if(treeNode.getParentId() == null){
-                    continue;
-                }
-                if (treeNode.getParentId().equals( tree.getId())) {
+                if (tree.getId().equals(treeNode.getParentId())) {
                     if (tree.getChildren() == null) {
                         tree.setChildren(new ArrayList<>());
                     }