This commit is contained in:
laodaming 2023-11-17 15:29:43 +08:00
parent ee2b0b5b81
commit 440f939725
3 changed files with 26 additions and 20 deletions

View File

@ -40,6 +40,9 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, useri
req.Password = strings.Trim(req.Password, " ") req.Password = strings.Trim(req.Password, " ")
req.Avatar = strings.Trim(req.Avatar, " ") req.Avatar = strings.Trim(req.Avatar, " ")
req.UserName = strings.Trim(req.UserName, " ") req.UserName = strings.Trim(req.UserName, " ")
if req.AuthGroupId < 0 {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误无效的用户权限组id")
}
if req.Password != "" { if req.Password != "" {
//todo 验证下是不是本人 //todo 验证下是不是本人
} }
@ -50,13 +53,14 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, useri
userNamePinyin := chinese_to_pinyin.ChineseToPinyin(req.UserName) userNamePinyin := chinese_to_pinyin.ChineseToPinyin(req.UserName)
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN) ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
err := ldapServer.Update(req.UserDN, map[string][]string{ err := ldapServer.Update(req.UserDN, map[string][]string{
"homeDirectory": {"/home/users/" + userNamePinyin}, "homeDirectory": {"/home/users/" + userNamePinyin},
"sn": {req.UserName}, "departmentNumber": {fmt.Sprintf("%d", req.AuthGroupId)},
"uid": {userNamePinyin}, "sn": {req.UserName},
"mobile": {req.Mobile}, "uid": {userNamePinyin},
"userPassword": {req.Password}, "mobile": {req.Mobile},
"postalAddress": {req.Avatar}, "userPassword": {req.Password},
"postalCode": {fmt.Sprintf("%d", req.Status)}, "postalAddress": {req.Avatar},
"postalCode": {fmt.Sprintf("%d", req.Status)},
}) })
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)

View File

@ -136,12 +136,13 @@ type CreateLdapUserReq struct {
} }
type UpdateLdapUserReq struct { type UpdateLdapUserReq struct {
UserDN string `json:"user_dn"` //用户dn UserDN string `json:"user_dn"` //用户dn
UserName string `json:"user_name"` //用户名 UserName string `json:"user_name"` //用户名
Password string `json:"password,optional"` //密码 Password string `json:"password,optional"` //密码
Mobile string `json:"mobile,optional"` //手机号 Mobile string `json:"mobile,optional"` //手机号
Avatar string `json:"avatar,optional"` //头像地址 Avatar string `json:"avatar,optional"` //头像地址
Status int64 `json:"status,options=0|1"` //状态 1正常0离职 Status int64 `json:"status,options=0|1"` //状态 1正常0离职
AuthGroupId int64 `json:"authGroupId"` //权限分组id
} }
type DeleteLdapUserReq struct { type DeleteLdapUserReq struct {

View File

@ -26,7 +26,7 @@ service ldap-admin {
//权限组授权接口 //权限组授权接口
@handler SetLdapCasbinRuleHandler @handler SetLdapCasbinRuleHandler
post /api/ldap-admin/set_ldap_casbin_rule(SetLdapCasbinRuleReq) returns (response); post /api/ldap-admin/set_ldap_casbin_rule(SetLdapCasbinRuleReq) returns (response);
//权限组授权用户 //权限组授权用户
@handler SetLdapGroupUserHandler @handler SetLdapGroupUserHandler
post /api/ldap-admin/set_ldap_group_user(SetLdapGroupUserReq) returns (response); post /api/ldap-admin/set_ldap_group_user(SetLdapGroupUserReq) returns (response);
@ -211,12 +211,13 @@ type CreateLdapUserReq {
} }
//修改ldap用户信息 //修改ldap用户信息
type UpdateLdapUserReq { type UpdateLdapUserReq {
UserDN string `json:"user_dn"` //用户dn UserDN string `json:"user_dn"` //用户dn
UserName string `json:"user_name"` //用户名 UserName string `json:"user_name"` //用户名
Password string `json:"password,optional"` //密码 Password string `json:"password,optional"` //密码
Mobile string `json:"mobile,optional"` //手机号 Mobile string `json:"mobile,optional"` //手机号
Avatar string `json:"avatar,optional"` //头像地址 Avatar string `json:"avatar,optional"` //头像地址
Status int64 `json:"status,options=0|1"` //状态 1正常0离职 Status int64 `json:"status,options=0|1"` //状态 1正常0离职
AuthGroupId int64 `json:"authGroupId"` //权限分组id
} }
//删除ldap用户 //删除ldap用户
type DeleteLdapUserReq { type DeleteLdapUserReq {