Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo 2023-11-15 17:55:56 +08:00
commit 51fd9a634e

View File

@ -56,18 +56,19 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.
} }
mapDN := make(map[string]*DNItem) mapDN := make(map[string]*DNItem)
sortNum := 0 sortNum := 0
//每个DN存入map
for _, v := range searchResult.Entries { for _, v := range searchResult.Entries {
sortNum++ sortNum++
attribute := make(map[string]interface{}) attribute := make(map[string]interface{})
for _, attr := range v.Attributes { for _, attr := range v.Attributes {
//objectcalss属性特别处理 switch attr.Name {
if attr.Name == "objectClass" { case "objectClass": //objectcalss属性特别处理
mapObjectClass := make(map[string]struct{}) mapObjectClass := make(map[string]struct{})
for _, objectClassItem := range attr.Values { for _, objectClassItem := range attr.Values {
mapObjectClass[objectClassItem] = struct{}{} mapObjectClass[objectClassItem] = struct{}{}
} }
attribute[attr.Name] = mapObjectClass attribute[attr.Name] = mapObjectClass
} else { //普通属性 default: //普通属性
attribute[attr.Name] = strings.Join(attr.Values, ",") 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), Child: make([]*DNItem, 0, 100),
} }
} }
//组织层级关系 //组织树形层级关系
minLevel := 0 minLevel := 0
for dn, v := range mapDN { for dn, v := range mapDN {
sl := strings.Split(dn, ",") sl := strings.Split(dn, ",")