chart_classify.go 667 B

123456789101112131415161718192021222324
  1. package services
  2. import (
  3. "eta/eta_hub/models/data_manage"
  4. )
  5. // GetChartClassifyTreeRecursive 递归图表分类树
  6. func GetChartClassifyTreeRecursive(list []*data_manage.ChartClassify, parentId int) []*data_manage.ChartClassifyItem {
  7. res := make([]*data_manage.ChartClassifyItem, 0)
  8. for _, v := range list {
  9. t := new(data_manage.ChartClassifyItem)
  10. t.ClassifyId = v.ChartClassifyId
  11. t.ClassifyName = v.ChartClassifyName
  12. t.UniqueCode = v.UniqueCode
  13. t.ParentId = v.ParentId
  14. t.Level = v.Level
  15. t.Sort = v.Sort
  16. if v.ParentId == parentId {
  17. t.Child = GetChartClassifyTreeRecursive(list, v.ChartClassifyId)
  18. res = append(res, t)
  19. }
  20. }
  21. return res
  22. }