fix
This commit is contained in:
parent
42e2001160
commit
fdb8082095
@ -68,7 +68,27 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
|
|||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "创建组织失败,"+err.Error())
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "创建组织失败,"+err.Error())
|
||||||
}
|
}
|
||||||
return resp.SetStatus(basic.CodeOK)
|
user, err := l.svcCtx.Ldap.GetLdapUserInfo(req.OwnerDN)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "获取负责人信息失败,"+err.Error())
|
||||||
|
}
|
||||||
|
if user.Status != 1 {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "负责人状态不正常")
|
||||||
|
}
|
||||||
|
//用户加入的部门
|
||||||
|
user.OrganizationDNList = append(user.OrganizationDNList, organizationDN)
|
||||||
|
//用户管理的部门
|
||||||
|
user.ManageOrganizationDNList = append(user.ManageOrganizationDNList, organizationDN)
|
||||||
|
//更新用户信息
|
||||||
|
err = l.svcCtx.Ldap.Update(user.UserDN, map[string][]string{
|
||||||
|
"departmentNumber": user.OrganizationDNList,
|
||||||
|
"telexNumber": user.ManageOrganizationDNList,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "添加组织成功,但是设置负责人信息失败,"+err.Error())
|
||||||
|
}
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeOK, "添加组织成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
@ -49,11 +49,42 @@ func (l *RemoveLdapOrganizationMemberLogic) RemoveLdapOrganizationMember(req *ty
|
|||||||
if !email.IsEmailValid(cnEmail) {
|
if !email.IsEmailValid(cnEmail) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "错误的用户cn")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "错误的用户cn")
|
||||||
}
|
}
|
||||||
|
//获取组织成员列表
|
||||||
err := l.svcCtx.Ldap.RemoveUserFromOrganization(req.OrganizationDN, req.UserDN)
|
err := l.svcCtx.Ldap.RemoveUserFromOrganization(req.OrganizationDN, req.UserDN)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "移除成员失败,"+err.Error())
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "移除成员失败,"+err.Error())
|
||||||
}
|
}
|
||||||
|
//获取用户信息
|
||||||
|
userInfo, err := l.svcCtx.Ldap.GetLdapUserInfo(req.UserDN)
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "获取用户信息失败,"+err.Error())
|
||||||
|
}
|
||||||
|
//把属于的组织去掉
|
||||||
|
newOrganizationDNList := make([]string, 0, len(userInfo.OrganizationDNList))
|
||||||
|
for _, v := range userInfo.OrganizationDNList {
|
||||||
|
if v == req.OrganizationDN {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newOrganizationDNList = append(newOrganizationDNList, v)
|
||||||
|
}
|
||||||
|
//如果是负责人也要把管理组织标识去掉
|
||||||
|
newManageOrganizationDNList := make([]string, 0, len(userInfo.OrganizationDNList))
|
||||||
|
for _, v := range userInfo.ManageOrganizationDNList {
|
||||||
|
if v == req.OrganizationDN {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newManageOrganizationDNList = append(newManageOrganizationDNList, v)
|
||||||
|
}
|
||||||
|
err = l.svcCtx.Ldap.Update(req.UserDN, map[string][]string{
|
||||||
|
"departmentNumber": newOrganizationDNList, //所属组织部门
|
||||||
|
"telexNumber": newManageOrganizationDNList, //管理的部门
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "移除成员成功,但更新用户信息失败")
|
||||||
|
}
|
||||||
return resp.SetStatusWithMessage(basic.CodeOK, "移除成员成功")
|
return resp.SetStatusWithMessage(basic.CodeOK, "移除成员成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user