fix
This commit is contained in:
parent
420829cec3
commit
79a6c3fa24
@ -4,6 +4,7 @@ import (
|
|||||||
"fusenapi/model/gmodel"
|
"fusenapi/model/gmodel"
|
||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/basic"
|
"fusenapi/utils/basic"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@ -61,23 +62,17 @@ func (l *GetDepartmentsLogic)DepartmentListToTree(deps []gmodel.LdapDepartment)[
|
|||||||
Child: make([]*types.DepartmentsItem, 0, 50),
|
Child: make([]*types.DepartmentsItem, 0, 50),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//组织从属关系
|
||||||
for _,v := range mapDepartment{
|
for _,v := range mapDepartment{
|
||||||
for _,val := range deps{
|
//如果有父级
|
||||||
if *val.ParentId != v.Id{
|
if parent,ok := mapDepartment[v.ParentId];ok{
|
||||||
continue
|
parent.Child = append(parent.Child,v)
|
||||||
}
|
sort.Slice(parent.Child, func(i, j int) bool {
|
||||||
v.Child = append(v.Child,&types.DepartmentsItem{
|
return parent.Child[i].Sort < parent.Child[j].Sort //升序
|
||||||
Id: val.Id,
|
|
||||||
Name: *val.Name,
|
|
||||||
Remark: *val.Remark,
|
|
||||||
Type: *val.Type,
|
|
||||||
ParentId: *val.ParentId,
|
|
||||||
Dn: *val.Dn,
|
|
||||||
SyncState: *val.SyncState,
|
|
||||||
Sort: *val.Sort,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//排序
|
||||||
list := make([]*types.DepartmentsItem, 0, len(deps))
|
list := make([]*types.DepartmentsItem, 0, len(deps))
|
||||||
for _, v := range deps {
|
for _, v := range deps {
|
||||||
if *v.ParentId == 0 {
|
if *v.ParentId == 0 {
|
||||||
|
@ -31,7 +31,10 @@ func NewSaveDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sa
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
func (l *SaveDepartmentLogic) SaveDepartment(req *types.SaveDepartmentReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
func (l *SaveDepartmentLogic) SaveDepartment(req *types.SaveDepartmentReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
//todo 鉴权。。。
|
|
||||||
|
if req.Id > 0{//更新
|
||||||
|
|
||||||
|
}
|
||||||
return resp.SetStatus(basic.CodeOK)
|
return resp.SetStatus(basic.CodeOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,14 @@ type DepartmentsItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SaveDepartmentReq struct {
|
type SaveDepartmentReq struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
ParentId int64 `json:"parent_id"`
|
ParentId int64 `json:"parent_id"`
|
||||||
Dn string `json:"dn"`
|
Dn string `json:"dn"`
|
||||||
|
SyncState int64 `json:"sync_state"`
|
||||||
|
Sort int64 `json:"sort"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
|
@ -35,10 +35,12 @@ type DepartmentsItem {
|
|||||||
}
|
}
|
||||||
//保存部门信息
|
//保存部门信息
|
||||||
type SaveDepartmentReq {
|
type SaveDepartmentReq {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
ParentId int64 `json:"parent_id"`
|
ParentId int64 `json:"parent_id"`
|
||||||
Dn string `json:"dn"`
|
Dn string `json:"dn"`
|
||||||
|
SyncState int64 `json:"sync_state"`
|
||||||
|
Sort int64 `json:"sort"`
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user