Browse Source

fix:过滤无效PPT分类

zqbao 3 months ago
parent
commit
54788c0e8d
2 changed files with 16 additions and 0 deletions
  1. 1 0
      controllers/ppt_report.go
  2. 15 0
      services/ppt_report.go

+ 1 - 0
controllers/ppt_report.go

@@ -166,6 +166,7 @@ func (this *PptV2Controller) ReportClassify() {
 	}
 
 	resp = services.GetPptReportClassifyTreeRecursive(classifies, 0, classifyPpt)
+	resp = services.RecursiveFilterPptNoChildTreeClassify(resp)
 
 	br.Data = resp
 	br.Ret = 200

+ 15 - 0
services/ppt_report.go

@@ -30,6 +30,21 @@ func GetPptReportClassifyTreeRecursive(list []*models.Classify, parentId int, cl
 	return res
 }
 
+func RecursiveFilterPptNoChildTreeClassify(list []*models.PptReportClassifyItem) []*models.PptReportClassifyItem {
+	res := make([]*models.PptReportClassifyItem, 0)
+	for _, v := range list {
+		v.Child = RecursiveFilterPptNoChildTreeClassify(v.Child)
+		if len(v.Child) == 0 && v.HasChild == 1 {
+			continue
+		}
+		if len(v.Child) == 0 {
+			v.Child = nil
+		}
+		res = append(res, v)
+	}
+	return res
+}
+
 // 更新分类报告计数加个锁
 var classifyReportNumLock sync.Mutex