This commit is contained in:
laodaming
2023-11-27 12:31:53 +08:00
parent 20a84e4899
commit 6585fecc6a
4 changed files with 84 additions and 37 deletions

View File

@@ -9,17 +9,20 @@ import (
)
type LdapUserInfo 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"` //头像地址
EmployeeType int64 `json:"employee_type"` //1正式 2实习 3外包
GroupId int64 `json:"group_id"` //权限组id
OrganizationDNList []string `json:"organization_dn_list"` //加入的部门
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外包
GroupId int64 `json:"group_id"` //权限组id
OrganizationDNList []string `json:"organization_dn_list"` //加入的部门
ManageOrganizationDNList []string `json:"manage_organization_dn_list"` //管理的部门
Gender int64 `json:"gender"` //性别
Birthday string `json:"birthday"` //生日
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
}
// 获取用户详情
@@ -87,6 +90,18 @@ func (l *Ldap) GetLdapUserInfo(userDN string) (*LdapUserInfo, error) {
}
case "departmentNumber": //加入的部门dn集合
user.OrganizationDNList = attr.Values
case "telexNumber": //管理的部门dn集合
user.ManageOrganizationDNList = attr.Values
case "st": //性别
if len(attr.Values) == 0 {
return nil, errors.New("性别不存在")
}
user.Gender, err = strconv.ParseInt(attr.Values[0], 10, 64)
if err != nil {
return nil, err
}
case "title": //生日
user.Birthday = strings.Join(attr.Values, ",")
}
}
if user.UserId == 0 {
@@ -156,6 +171,18 @@ func (l *Ldap) GetLdapBaseTeamUserList(pageSize uint32, filter, pageCookie strin
}
case "departmentNumber": //加入的部门dn集合
user.OrganizationDNList = attr.Values
case "telexNumber": //管理的部门dn集合
user.ManageOrganizationDNList = attr.Values
case "st": //性别
if len(attr.Values) == 0 {
return nil, "", errors.New("性别不存在")
}
user.Gender, err = strconv.ParseInt(attr.Values[0], 10, 64)
if err != nil {
return nil, "", err
}
case "title": //生日
user.Birthday = strings.Join(attr.Values, ",")
}
}
list = append(list, user)
@@ -219,6 +246,28 @@ func (l *Ldap) GetLdapBaseTeamUsersByParams(filter string) ([]LdapUserInfo, erro
if err != nil {
return nil, err
}
case "roomNumber": //权限组id
if len(attr.Values) == 0 {
return nil, errors.New("权限组id不存在")
}
user.GroupId, err = strconv.ParseInt(attr.Values[0], 10, 64)
if err != nil {
return nil, err
}
case "departmentNumber": //加入的部门dn集合
user.OrganizationDNList = attr.Values
case "telexNumber": //管理的部门dn集合
user.ManageOrganizationDNList = attr.Values
case "st": //性别
if len(attr.Values) == 0 {
return nil, errors.New("性别不存在")
}
user.Gender, err = strconv.ParseInt(attr.Values[0], 10, 64)
if err != nil {
return nil, err
}
case "title": //生日
user.Birthday = strings.Join(attr.Values, ",")
}
}
list = append(list, user)