From f946f2926ad707eab83b598ac9d9758a03d3af7a Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 21 Nov 2023 10:13:12 +0800 Subject: [PATCH] fix --- server/ldap-admin/internal/logic/createldapuserlogic.go | 3 +++ server/ldap-admin/internal/logic/updateldapuserlogic.go | 4 ++-- server/ldap-admin/internal/types/types.go | 4 ++-- server_api/ldap-admin.api | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server/ldap-admin/internal/logic/createldapuserlogic.go b/server/ldap-admin/internal/logic/createldapuserlogic.go index c3dd3ce8..3134f5c8 100644 --- a/server/ldap-admin/internal/logic/createldapuserlogic.go +++ b/server/ldap-admin/internal/logic/createldapuserlogic.go @@ -42,6 +42,9 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, useri req.Mobile = strings.Trim(req.Mobile, " ") req.Email = strings.Trim(req.Email, " ") req.Password = strings.Trim(req.Password, " ") + if req.GroupId < 0 { + req.GroupId = 0 + } if req.UserName == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,用户名不能为空") } diff --git a/server/ldap-admin/internal/logic/updateldapuserlogic.go b/server/ldap-admin/internal/logic/updateldapuserlogic.go index 769f09f4..3f2390c9 100644 --- a/server/ldap-admin/internal/logic/updateldapuserlogic.go +++ b/server/ldap-admin/internal/logic/updateldapuserlogic.go @@ -40,7 +40,7 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, useri req.Mobile = strings.Trim(req.Mobile, " ") req.Avatar = strings.Trim(req.Avatar, " ") req.UserName = strings.Trim(req.UserName, " ") - if req.AuthGroupId < 0 { + if req.GroupId < 0 { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,无效的用户权限组id") } if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" { @@ -56,7 +56,7 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, useri //更新的属性 attr := map[string][]string{ "homeDirectory": {"/home/users/" + userNamePinyin}, - "departmentNumber": {fmt.Sprintf("%d", req.AuthGroupId)}, + "departmentNumber": {fmt.Sprintf("%d", req.GroupId)}, "sn": {req.UserName}, "uid": {userNamePinyin}, "mobile": {req.Mobile}, diff --git a/server/ldap-admin/internal/types/types.go b/server/ldap-admin/internal/types/types.go index 07b490e3..5d74dba7 100644 --- a/server/ldap-admin/internal/types/types.go +++ b/server/ldap-admin/internal/types/types.go @@ -137,7 +137,7 @@ type CreateLdapUserReq struct { 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"` //分组id + GroupId int64 `json:"group_id,optional"` //分组id Status int64 `json:"status,options=0|1"` //状态 1正常0离职 } @@ -148,7 +148,7 @@ type UpdateLdapUserReq struct { Avatar string `json:"avatar,optional"` //头像地址 Status int64 `json:"status,options=0|1"` //状态 1正常0离职 EmployeeType int64 `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包 - AuthGroupId int64 `json:"auth_group_id,optional"` //权限分组id + GroupId int64 `json:"group_id,optional"` //权限分组id } type UpdateLdapUserPwdReq struct { diff --git a/server_api/ldap-admin.api b/server_api/ldap-admin.api index 610cd794..c57b7b3f 100644 --- a/server_api/ldap-admin.api +++ b/server_api/ldap-admin.api @@ -221,7 +221,7 @@ type CreateLdapUserReq { 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"` //分组id + GroupId int64 `json:"group_id,optional"` //分组id Status int64 `json:"status,options=0|1"` //状态 1正常0离职 } //修改ldap用户信息 @@ -232,7 +232,7 @@ type UpdateLdapUserReq { Avatar string `json:"avatar,optional"` //头像地址 Status int64 `json:"status,options=0|1"` //状态 1正常0离职 EmployeeType int64 `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包 - AuthGroupId int64 `json:"auth_group_id,optional"` //权限分组id + GroupId int64 `json:"group_id,optional"` //权限分组id } //修改用户密码 type UpdateLdapUserPwdReq {