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