edb_classify.go 618 B

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