report_approve.go 623 B

12345678910111213141516171819202122
  1. package services
  2. import (
  3. "eta/eta_api/models"
  4. "eta/eta_api/models/report_approve"
  5. )
  6. // GetReportClassifyTreeRecursive 递归获取报告分类树
  7. func GetReportClassifyTreeRecursive(list []*models.Classify, parentId int) []*report_approve.ReportClassifyTreeItem {
  8. res := make([]*report_approve.ReportClassifyTreeItem, 0)
  9. for _, v := range list {
  10. if v.ParentId == parentId {
  11. t := new(report_approve.ReportClassifyTreeItem)
  12. t.ClassifyId = v.Id
  13. t.ClassifyName = v.ClassifyName
  14. t.ParentId = v.ParentId
  15. t.Children = GetReportClassifyTreeRecursive(list, v.Id)
  16. res = append(res, t)
  17. }
  18. }
  19. return res
  20. }