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