This commit is contained in:
laodaming 2023-11-24 14:44:54 +08:00
parent 689433001f
commit 2fd6c1459f
3 changed files with 27 additions and 17 deletions

View File

@ -87,7 +87,8 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
"sn": {req.UserName}, //用户名
"mail": {req.Email}, //邮箱
"postalCode": {fmt.Sprintf("%d", req.Status)}, //状态
"departmentNumber": {fmt.Sprintf("%d", req.GroupId)}, //权限分组id
"roomNumber": {fmt.Sprintf("%d", req.GroupId)}, //权限分组id
"departmentNumber": req.OrganizationDNList, //所属组织部门
"postalAddress": {req.Avatar}, //头像
"mobile": {req.Mobile}, //手机号
"userPassword": {req.Password}, //密码
@ -96,6 +97,13 @@ 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, "添加用户成功")
}

View File

@ -148,14 +148,15 @@ type UpdateLdapOrganizationReq struct {
}
type CreateLdapUserReq struct {
UserName string `json:"user_name"` //用户名
Email string `json:"email"` //邮箱
Password string `json:"password"` //密码
Mobile string `json:"mobile"` //手机号
Avatar string `json:"avatar"` //头像地址
EmployeeType int64 `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包
GroupId int64 `json:"group_id,optional"` //分组id
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
UserName string `json:"user_name"` //用户名
Email string `json:"email"` //邮箱
Password string `json:"password"` //密码
Mobile string `json:"mobile"` //手机号
Avatar string `json:"avatar"` //头像地址
EmployeeType int64 `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包
GroupId int64 `json:"group_id,optional"` //授权分组id
OrganizationDNList []string `json:"organization_dn_list"` //属于哪些部门
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
}
type UpdateLdapUserReq struct {

View File

@ -236,14 +236,15 @@ type UpdateLdapOrganizationReq {
}
//添加ldap用户帐号
type CreateLdapUserReq {
UserName string `json:"user_name"` //用户名
Email string `json:"email"` //邮箱
Password string `json:"password"` //密码
Mobile string `json:"mobile"` //手机号
Avatar string `json:"avatar"` //头像地址
EmployeeType int64 `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包
GroupId int64 `json:"group_id,optional"` //分组id
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
UserName string `json:"user_name"` //用户名
Email string `json:"email"` //邮箱
Password string `json:"password"` //密码
Mobile string `json:"mobile"` //手机号
Avatar string `json:"avatar"` //头像地址
EmployeeType int64 `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包
GroupId int64 `json:"group_id,optional"` //授权分组id
OrganizationDNList []string `json:"organization_dn_list"` //属于哪些部门
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
}
//修改ldap用户信息
type UpdateLdapUserReq {