12345678910111213141516171819202122232425262728293031 |
- package services
- import "eta/eta_mini_crm_ht/models"
- // 获得全部的权限结构列表树形结构
- func GetChartPermissionListTree(list []*models.ChartPermissionListTree, parentId int) []*models.ChartPermissionListTree {
- res := make([]*models.ChartPermissionListTree, 0)
- for _, v := range list {
- if v.ParentId == parentId {
- t := new(models.ChartPermissionListTree)
- t.ChartPermissionId = v.ChartPermissionId
- t.PermissionName = v.PermissionName
- t.ParentId = v.ParentId
- for _, j := range list {
- if j.ParentId == v.ChartPermissionId {
- c := new(models.ChartPermissionListTree)
- c.ChartPermissionId = j.ChartPermissionId
- c.PermissionName = j.PermissionName
- c.ParentId = j.ParentId
- if j.IsPublic == 1 {
- t.PublicChild = append(t.PublicChild, c)
- } else {
- t.PrivateChild = append(t.PrivateChild, c)
- }
- }
- }
- res = append(res, t)
- }
- }
- return res
- }
|