Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
@@ -68,7 +68,27 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "创建组织失败,"+err.Error())
|
||||
}
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
user, err := l.svcCtx.Ldap.GetLdapUserInfo(req.OwnerDN)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "获取负责人信息失败,"+err.Error())
|
||||
}
|
||||
if user.Status != 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "负责人状态不正常")
|
||||
}
|
||||
//用户加入的部门
|
||||
user.OrganizationDNList = append(user.OrganizationDNList, organizationDN)
|
||||
//用户管理的部门
|
||||
user.ManageOrganizationDNList = append(user.ManageOrganizationDNList, organizationDN)
|
||||
//更新用户信息
|
||||
err = l.svcCtx.Ldap.Update(user.UserDN, map[string][]string{
|
||||
"departmentNumber": user.OrganizationDNList,
|
||||
"telexNumber": user.ManageOrganizationDNList,
|
||||
})
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "添加组织成功,但是设置负责人信息失败,"+err.Error())
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "添加组织成功")
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
|
||||
@@ -88,7 +88,10 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, r *ht
|
||||
"mail": {req.Email}, //邮箱
|
||||
"postalCode": {fmt.Sprintf("%d", req.Status)}, //状态
|
||||
"roomNumber": {fmt.Sprintf("%d", req.GroupId)}, //权限分组id
|
||||
"departmentNumber": req.OrganizationDNList, //所属组织部门
|
||||
"departmentNumber": {""}, //所属组织部门
|
||||
"telexNumber": {""}, //管理的部门
|
||||
"st": {fmt.Sprintf("%d", req.Gender)}, //性别
|
||||
"title": {req.Birthday}, //生日
|
||||
"postalAddress": {req.Avatar}, //头像
|
||||
"mobile": {req.Mobile}, //手机号
|
||||
"userPassword": {req.Password}, //密码
|
||||
@@ -97,13 +100,6 @@ 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, "添加用户成功")
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ func (l *GetLdapOrganizationMembersLogic) GetLdapOrganizationMembers(req *types.
|
||||
Mobile: user.Mobile,
|
||||
Avatar: user.Avatar,
|
||||
EmployeeType: user.EmployeeType,
|
||||
Gender: user.Gender,
|
||||
Birthday: user.Birthday,
|
||||
Status: user.Status,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,8 +54,10 @@ func (l *GetLdapUserInfoLogic) GetLdapUserInfo(req *types.GetLdapUserInfoReq, r
|
||||
Email: user.Email,
|
||||
Mobile: user.Mobile,
|
||||
Avatar: user.Avatar,
|
||||
Status: user.Status,
|
||||
EmployeeTpye: user.EmployeeType,
|
||||
Gender: user.Gender,
|
||||
Birthday: user.Birthday,
|
||||
Status: user.Status,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -49,11 +49,42 @@ func (l *RemoveLdapOrganizationMemberLogic) RemoveLdapOrganizationMember(req *ty
|
||||
if !email.IsEmailValid(cnEmail) {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "错误的用户cn")
|
||||
}
|
||||
//获取组织成员列表
|
||||
err := l.svcCtx.Ldap.RemoveUserFromOrganization(req.OrganizationDN, req.UserDN)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "移除成员失败,"+err.Error())
|
||||
}
|
||||
//获取用户信息
|
||||
userInfo, err := l.svcCtx.Ldap.GetLdapUserInfo(req.UserDN)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "获取用户信息失败,"+err.Error())
|
||||
}
|
||||
//把属于的组织去掉
|
||||
newOrganizationDNList := make([]string, 0, len(userInfo.OrganizationDNList))
|
||||
for _, v := range userInfo.OrganizationDNList {
|
||||
if v == req.OrganizationDN {
|
||||
continue
|
||||
}
|
||||
newOrganizationDNList = append(newOrganizationDNList, v)
|
||||
}
|
||||
//如果是负责人也要把管理组织标识去掉
|
||||
newManageOrganizationDNList := make([]string, 0, len(userInfo.OrganizationDNList))
|
||||
for _, v := range userInfo.ManageOrganizationDNList {
|
||||
if v == req.OrganizationDN {
|
||||
continue
|
||||
}
|
||||
newManageOrganizationDNList = append(newManageOrganizationDNList, v)
|
||||
}
|
||||
err = l.svcCtx.Ldap.Update(req.UserDN, map[string][]string{
|
||||
"departmentNumber": newOrganizationDNList, //所属组织部门
|
||||
"telexNumber": newManageOrganizationDNList, //管理的部门
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "移除成员成功,但更新用户信息失败")
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "移除成员成功")
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, r *ht
|
||||
"postalAddress": {req.Avatar},
|
||||
"postalCode": {fmt.Sprintf("%d", req.Status)},
|
||||
"employeeType": {fmt.Sprintf("%d", req.EmployeeType)},
|
||||
"st": {fmt.Sprintf("%d", req.Gender)}, //性别
|
||||
"title": {req.Birthday}, //生日
|
||||
}
|
||||
err := l.svcCtx.Ldap.Update(req.UserDN, attr)
|
||||
if err != nil {
|
||||
|
||||
@@ -144,15 +144,16 @@ 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
|
||||
OrganizationDNList []string `json:"organization_dn_list"` //属于哪些部门
|
||||
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
|
||||
Gender int64 `json:"gender,options=1|2|3"` //性别 1男 2女 3未知
|
||||
Birthday string `json:"birthday"` //生日
|
||||
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
|
||||
}
|
||||
|
||||
type UpdateLdapUserReq struct {
|
||||
@@ -163,6 +164,8 @@ type UpdateLdapUserReq struct {
|
||||
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
|
||||
EmployeeType int64 `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包
|
||||
GroupId int64 `json:"group_id,optional"` //权限分组id
|
||||
Gender int64 `json:"gender,options=1|2|3"` //性别 1男 2女 3未知
|
||||
Birthday string `json:"birthday"` //生日
|
||||
}
|
||||
|
||||
type UpdateLdapUserPwdReq struct {
|
||||
@@ -182,12 +185,14 @@ type GetLdapUserInfoReq struct {
|
||||
type GetLdapUserInfoRsp struct {
|
||||
UserId int64 `json:"user_id"`
|
||||
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离职
|
||||
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外包
|
||||
Gender int64 `json:"gender,options=1|2|3"` //性别 1男 2女 3未知
|
||||
Birthday string `json:"birthday"` //生日
|
||||
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
|
||||
}
|
||||
|
||||
type AddLdapOrganizationMemberReq struct {
|
||||
@@ -211,12 +216,14 @@ type GetLdapOrganizationMembersRsp struct {
|
||||
type GetLdapOrganizationMembersItem 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"` //头像地址
|
||||
EmployeeType int64 `json:"employee_type"`
|
||||
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
|
||||
UserName string `json:"user_name"` //用户名
|
||||
Email string `json:"email"` //邮箱
|
||||
Mobile string `json:"mobile"` //手机号
|
||||
Avatar string `json:"avatar"` //头像地址
|
||||
EmployeeType int64 `json:"employee_type"` //雇佣类型
|
||||
Gender int64 `json:"gender,options=1|2|3"` //性别 1男 2女 3未知
|
||||
Birthday string `json:"birthday"` //生日
|
||||
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
|
||||
}
|
||||
|
||||
type GetLdapUsersReq struct {
|
||||
|
||||
Reference in New Issue
Block a user