diff --git a/server/ldap-admin/internal/logic/getdepartmentslogic.go b/server/ldap-admin/internal/logic/getdepartmentslogic.go index ce311be6..483e3ea3 100644 --- a/server/ldap-admin/internal/logic/getdepartmentslogic.go +++ b/server/ldap-admin/internal/logic/getdepartmentslogic.go @@ -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 {