123456789101112131415161718192021222324 |
- package services
- import (
- "eta/eta_hub/models/data_manage"
- )
- // GetChartClassifyTreeRecursive 递归图表分类树
- func GetChartClassifyTreeRecursive(list []*data_manage.ChartClassify, parentId int) []*data_manage.ChartClassifyItem {
- res := make([]*data_manage.ChartClassifyItem, 0)
- for _, v := range list {
- t := new(data_manage.ChartClassifyItem)
- t.ClassifyId = v.ChartClassifyId
- t.ClassifyName = v.ChartClassifyName
- t.UniqueCode = v.UniqueCode
- t.ParentId = v.ParentId
- t.Level = v.Level
- t.Sort = v.Sort
- if v.ParentId == parentId {
- t.Child = GetChartClassifyTreeRecursive(list, v.ChartClassifyId)
- res = append(res, t)
- }
- }
- return res
- }
|