From 3919dae9feadc891840549f42a09354fc745d2da Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 15 Nov 2023 17:41:16 +0800 Subject: [PATCH] fix --- server/ldap-admin/internal/logic/getdepartmentslogic.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/ldap-admin/internal/logic/getdepartmentslogic.go b/server/ldap-admin/internal/logic/getdepartmentslogic.go index da8fabdf..f6cf2190 100644 --- a/server/ldap-admin/internal/logic/getdepartmentslogic.go +++ b/server/ldap-admin/internal/logic/getdepartmentslogic.go @@ -56,18 +56,19 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth. } mapDN := make(map[string]*DNItem) sortNum := 0 + //每个DN存入map for _, v := range searchResult.Entries { sortNum++ attribute := make(map[string]interface{}) for _, attr := range v.Attributes { - //objectcalss属性特别处理 - if attr.Name == "objectClass" { + switch attr.Name { + case "objectClass": //objectcalss属性特别处理 mapObjectClass := make(map[string]struct{}) for _, objectClassItem := range attr.Values { mapObjectClass[objectClassItem] = struct{}{} } attribute[attr.Name] = mapObjectClass - } else { //普通属性 + default: //普通属性 attribute[attr.Name] = strings.Join(attr.Values, ",") } } @@ -79,7 +80,7 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth. Child: make([]*DNItem, 0, 100), } } - //组织层级关系 + //组织树形层级关系 minLevel := 0 for dn, v := range mapDN { sl := strings.Split(dn, ",")