Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
@@ -68,7 +68,27 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
|
||||
logx.Error(err)
|
||||
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 必须重新处理
|
||||
|
||||
@@ -88,7 +88,10 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
|
||||
"mail": {req.Email}, //邮箱
|
||||
"postalCode": {fmt.Sprintf("%d", req.Status)}, //状态
|
||||
"roomNumber": {fmt.Sprintf("%d", req.GroupId)}, //权限分组id
|
||||
"departmentNumber": req.OrganizationDNList, //所属组织部门
|
||||
"departmentNumber": {""}, //所属组织部门
|
||||
"telexNumber": {""}, //管理的部门
|
||||
"st": {fmt.Sprintf("%d", req.Gender)}, //性别
|
||||
"title": {req.Birthday}, //生日
|
||||
"postalAddress": {req.Avatar}, //头像
|
||||
"mobile": {req.Mobile}, //手机号
|
||||
"userPassword": {req.Password}, //密码
|
||||
@@ -97,13 +100,6 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "添加用户失败,"+err.Error())
|
||||
}
|
||||
//将用户加入这些部门
|
||||
for _, v := range req.OrganizationDNList {
|
||||
if err = l.svcCtx.Ldap.AddUserToOrganization(v, userDN); err != nil {
|
||||
logx.Error("加入部门失败:", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "添加用户成功")
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ func (l *GetLdapOrganizationMembersLogic) GetLdapOrganizationMembers(req *types.
|
||||
Mobile: user.Mobile,
|
||||
Avatar: user.Avatar,
|
||||
EmployeeType: user.EmployeeType,
|
||||
Gender: user.Gender,
|
||||
Birthday: user.Birthday,
|
||||
Status: user.Status,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,8 +54,10 @@ func (l *GetLdapUserInfoLogic) GetLdapUserInfo(req *types.GetLdapUserInfoReq, r
|
||||
Email: user.Email,
|
||||
Mobile: user.Mobile,
|
||||
Avatar: user.Avatar,
|
||||
Status: user.Status,
|
||||
EmployeeTpye: user.EmployeeType,
|
||||
Gender: user.Gender,
|
||||
Birthday: user.Birthday,
|
||||
Status: user.Status,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -49,11 +49,42 @@ func (l *RemoveLdapOrganizationMemberLogic) RemoveLdapOrganizationMember(req *ty
|
||||
if !email.IsEmailValid(cnEmail) {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "错误的用户cn")
|
||||
}
|
||||
//获取组织成员列表
|
||||
err := l.svcCtx.Ldap.RemoveUserFromOrganization(req.OrganizationDN, req.UserDN)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
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, "移除成员成功")
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, r *ht
|
||||
"postalAddress": {req.Avatar},
|
||||
"postalCode": {fmt.Sprintf("%d", req.Status)},
|
||||
"employeeType": {fmt.Sprintf("%d", req.EmployeeType)},
|
||||
"st": {fmt.Sprintf("%d", req.Gender)}, //性别
|
||||
"title": {req.Birthday}, //生日
|
||||
}
|
||||
err := l.svcCtx.Ldap.Update(req.UserDN, attr)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user