From e7eeb9114cffa18ee94cf4722e88b1034a178049 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 20 Nov 2023 12:08:04 +0800 Subject: [PATCH] fix --- .../internal/logic/getldapuserinfologic.go | 15 +++++------ server/ldap-admin/internal/types/types.go | 15 +++++------ server_api/ldap-admin.api | 15 +++++------ utils/ldap_lib/ldap_user.go | 25 +++++++++++++------ 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/server/ldap-admin/internal/logic/getldapuserinfologic.go b/server/ldap-admin/internal/logic/getldapuserinfologic.go index cfd67261..c4ff0824 100644 --- a/server/ldap-admin/internal/logic/getldapuserinfologic.go +++ b/server/ldap-admin/internal/logic/getldapuserinfologic.go @@ -46,13 +46,14 @@ func (l *GetLdapUserInfoLogic) GetLdapUserInfo(req *types.GetLdapUserInfoReq, us return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error()) } return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetLdapUserInfoRsp{ - UserId: user.UserId, - UserDN: user.UserDN, - UserName: user.UserName, - Email: user.Email, - Mobile: user.Mobile, - Avatar: user.Avatar, - Status: user.Status, + UserId: user.UserId, + UserDN: user.UserDN, + UserName: user.UserName, + Email: user.Email, + Mobile: user.Mobile, + Avatar: user.Avatar, + Status: user.Status, + EmployeeTpye: user.EmployeeType, }) } diff --git a/server/ldap-admin/internal/types/types.go b/server/ldap-admin/internal/types/types.go index 08fb2651..7f3688ae 100644 --- a/server/ldap-admin/internal/types/types.go +++ b/server/ldap-admin/internal/types/types.go @@ -163,13 +163,14 @@ type GetLdapUserInfoReq struct { } type GetLdapUserInfoRsp struct { - UserId int64 `json:"userId"` - UserDN string `json:"user_dn"` - UserName string `json:"user_name"` //用户名 - Email string `json:"email"` //邮箱 - Mobile string `json:"mobile"` //手机号 - Avatar string `json:"avatar"` //头像地址 - Status int64 `json:"status,options=0|1"` //状态 1正常0离职 + UserId int64 `json:"userId"` + UserDN string `json:"user_dn"` + UserName string `json:"user_name"` //用户名 + Email string `json:"email"` //邮箱 + Mobile string `json:"mobile"` //手机号 + Avatar string `json:"avatar"` //头像地址 + EmployeeTpye int64 `json:"employee_tpye"` //雇佣类型 1正式 2实习 3外包 + Status int64 `json:"status,options=0|1"` //状态 1正常0离职 } type AddLdapOrganizationMemberReq struct { diff --git a/server_api/ldap-admin.api b/server_api/ldap-admin.api index e4e5c80b..2d0ed7ec 100644 --- a/server_api/ldap-admin.api +++ b/server_api/ldap-admin.api @@ -243,13 +243,14 @@ type GetLdapUserInfoReq { UserDN string `form:"user_dn"` //用户dn } type GetLdapUserInfoRsp { - UserId int64 `json:"userId"` - UserDN string `json:"user_dn"` - UserName string `json:"user_name"` //用户名 - Email string `json:"email"` //邮箱 - Mobile string `json:"mobile"` //手机号 - Avatar string `json:"avatar"` //头像地址 - Status int64 `json:"status,options=0|1"` //状态 1正常0离职 + UserId int64 `json:"userId"` + UserDN string `json:"user_dn"` + UserName string `json:"user_name"` //用户名 + Email string `json:"email"` //邮箱 + Mobile string `json:"mobile"` //手机号 + Avatar string `json:"avatar"` //头像地址 + EmployeeTpye int64 `json:"employee_tpye"` //雇佣类型 1正式 2实习 3外包 + Status int64 `json:"status,options=0|1"` //状态 1正常0离职 } //ldap组织添加成员 type AddLdapOrganizationMemberReq { diff --git a/utils/ldap_lib/ldap_user.go b/utils/ldap_lib/ldap_user.go index f8bba87d..20df8aab 100644 --- a/utils/ldap_lib/ldap_user.go +++ b/utils/ldap_lib/ldap_user.go @@ -9,14 +9,15 @@ import ( ) type GetLdapUserInfoRsp struct { - UserId int64 `json:"userId"` - UserDN string `json:"user_dn"` - UserName string `json:"user_name"` //用户名 - Password string `json:"password"` //密码 - Email string `json:"email"` //邮箱 - Mobile string `json:"mobile"` //手机号 - Avatar string `json:"avatar"` //头像地址 - Status int64 `json:"status,options=0|1"` //状态 1正常0离职 + UserId int64 `json:"userId"` + UserDN string `json:"user_dn"` + UserName string `json:"user_name"` //用户名 + Password string `json:"password"` //密码 + Email string `json:"email"` //邮箱 + Mobile string `json:"mobile"` //手机号 + Avatar string `json:"avatar"` //头像地址 + EmployeeType int64 `json:"employee_type"` //1正式 2实习 3外包 + Status int64 `json:"status,options=0|1"` //状态 1正常0离职 } func (l *Ldap) GetLdapUserInfo(userDN string) (*GetLdapUserInfoRsp, error) { @@ -54,6 +55,14 @@ func (l *Ldap) GetLdapUserInfo(userDN string) (*GetLdapUserInfoRsp, error) { user.Avatar = strings.Join(attr.Values, "") case "userPassword": //密码 user.Password = strings.Join(attr.Values, ",") + case "employeeType": //员工类型 + if len(attr.Values) == 0 { + continue + } + user.EmployeeType, err = strconv.ParseInt(attr.Values[0], 10, 64) + if err != nil { + return nil, errors.New("用户类型转数字失败") + } case "postalCode": //状态 if len(attr.Values) == 0 { continue