package services import "eta/eta_mini_crm/models" // GetClassifyTreeRecursive 递归获取分类树 func GetClassifyTreeRecursive(classifies []*models.ClassifyItem, parentId int) []*models.ClassifyItem { res := make([]*models.ClassifyItem, 0) for _, v := range classifies { if v.ParentId == parentId { t := new(models.ClassifyItem) t.Id = v.Id t.ClassifyName = v.ClassifyName t.ParentId = v.ParentId t.CreateTime = v.CreateTime t.ModifyTime = v.ModifyTime t.Level = v.Level t.Enabled = v.Enabled t.Child = GetClassifyTreeRecursive(classifies, v.Id) res = append(res, t) } } return res }