浏览代码

Merge branch 'bzq/306_report_classify' of eta_gn_server/eta_api into debug

baoziqiang 4 月之前
父节点
当前提交
dc843e141b
共有 2 个文件被更改,包括 16 次插入0 次删除
  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