12345678910111213141516171819202122 |
- package services
- import (
- "eta/eta_api/models"
- "eta/eta_api/models/report_approve"
- )
- // GetReportClassifyTreeRecursive 递归获取报告分类树
- func GetReportClassifyTreeRecursive(list []*models.Classify, parentId int) []*report_approve.ReportClassifyTreeItem {
- res := make([]*report_approve.ReportClassifyTreeItem, 0)
- for _, v := range list {
- if v.ParentId == parentId {
- t := new(report_approve.ReportClassifyTreeItem)
- t.ClassifyId = v.Id
- t.ClassifyName = v.ClassifyName
- t.ParentId = v.ParentId
- t.Children = GetReportClassifyTreeRecursive(list, v.Id)
- res = append(res, t)
- }
- }
- return res
- }
|