chart_permission.go 921 B

12345678910111213141516171819202122232425262728293031
  1. package services
  2. import "eta/eta_mini_crm_ht/models"
  3. // 获得全部的权限结构列表树形结构
  4. func GetChartPermissionListTree(list []*models.ChartPermissionListTree, parentId int) []*models.ChartPermissionListTree {
  5. res := make([]*models.ChartPermissionListTree, 0)
  6. for _, v := range list {
  7. if v.ParentId == parentId {
  8. t := new(models.ChartPermissionListTree)
  9. t.ChartPermissionId = v.ChartPermissionId
  10. t.PermissionName = v.PermissionName
  11. t.ParentId = v.ParentId
  12. for _, j := range list {
  13. if j.ParentId == v.ChartPermissionId {
  14. c := new(models.ChartPermissionListTree)
  15. c.ChartPermissionId = j.ChartPermissionId
  16. c.PermissionName = j.PermissionName
  17. c.ParentId = j.ParentId
  18. if j.IsPublic == 1 {
  19. t.PublicChild = append(t.PublicChild, c)
  20. } else {
  21. t.PrivateChild = append(t.PrivateChild, c)
  22. }
  23. }
  24. }
  25. res = append(res, t)
  26. }
  27. }
  28. return res
  29. }