fix
This commit is contained in:
parent
1041caad23
commit
dd4c9ca1e0
|
@ -35,6 +35,7 @@ func NewGetDepartmentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
|
|||
type DNItem struct {
|
||||
Attribute map[string]interface{} `json:"attribute"`
|
||||
DN string `json:"dn"`
|
||||
ParentDN string `json:"parent_dn"`
|
||||
Sort int `json:"sort"`
|
||||
Child []*DNItem `json:"child"`
|
||||
}
|
||||
|
@ -72,6 +73,7 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.
|
|||
}
|
||||
mapDN[v.DN] = &DNItem{
|
||||
DN: v.DN,
|
||||
ParentDN: "",
|
||||
Attribute: attribute,
|
||||
Sort: sortNum,
|
||||
Child: make([]*DNItem, 0, 100),
|
||||
|
@ -90,8 +92,9 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.
|
|||
continue
|
||||
}
|
||||
//有父级
|
||||
parentKey := strings.Join(sl[1:], ",")
|
||||
if parent, ok := mapDN[parentKey]; ok {
|
||||
parentDN := strings.Join(sl[1:], ",")
|
||||
if parent, ok := mapDN[parentDN]; ok {
|
||||
v.ParentDN = parentDN
|
||||
parent.Child = append(parent.Child, v)
|
||||
//排序
|
||||
sort.Slice(parent.Child, func(i, j int) bool {
|
||||
|
|
Loading…
Reference in New Issue
Block a user