fix
This commit is contained in:
		
							parent
							
								
									e7eeb9114c
								
							
						
					
					
						commit
						be0a5a8e98
					
				| @ -36,7 +36,7 @@ func NewCreateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceCont | |||||||
| func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) { | func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) { | ||||||
| 	req.OrganizationEnName = strings.Trim(req.OrganizationEnName, " ") | 	req.OrganizationEnName = strings.Trim(req.OrganizationEnName, " ") | ||||||
| 	req.ParentOrganizationDN = strings.Trim(req.ParentOrganizationDN, " ") | 	req.ParentOrganizationDN = strings.Trim(req.ParentOrganizationDN, " ") | ||||||
| 	req.OrganizationName = strings.Trim(req.OrganizationName, " ") | 	req.BusinessCategory = strings.Trim(req.BusinessCategory, " ") | ||||||
| 	if len(strings.Split(req.OrganizationEnName, ",")) != 1 { | 	if len(strings.Split(req.OrganizationEnName, ",")) != 1 { | ||||||
| 		return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织英文名不符合规范") | 		return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织英文名不符合规范") | ||||||
| 	} | 	} | ||||||
| @ -47,17 +47,17 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd | |||||||
| 	if req.ParentOrganizationDN == "" { | 	if req.ParentOrganizationDN == "" { | ||||||
| 		return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,父级DN不能为空") | 		return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,父级DN不能为空") | ||||||
| 	} | 	} | ||||||
| 	if req.OrganizationName == "" { | 	if req.BusinessCategory == "" { | ||||||
| 		return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织中文名不能为空") | 		return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织分类名不能为空") | ||||||
| 	} | 	} | ||||||
| 	//组装organization dn | 	//组装organization dn | ||||||
| 	organizationDN := "ou=" + req.OrganizationEnName + "," + req.ParentOrganizationDN | 	organizationDN := "ou=" + req.OrganizationEnName + "," + req.ParentOrganizationDN | ||||||
| 	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.Create(organizationDN, map[string][]string{ | 	err := ldapServer.Create(organizationDN, map[string][]string{ | ||||||
| 		"objectClass":      {"top", "groupOfUniqueNames"}, | 		"objectClass":      {"top", "groupOfUniqueNames"}, | ||||||
| 		"cn":               {req.OrganizationName}, | 		"cn":               {req.OrganizationEnName}, | ||||||
| 		"ou":               {req.OrganizationEnName}, | 		"ou":               {req.OrganizationEnName}, | ||||||
| 		"businessCategory": {req.OrganizationName}, | 		"businessCategory": {req.BusinessCategory}, | ||||||
| 		"uniqueMember":     {l.svcCtx.Config.Ldap.RootDN}, //创建groupOfUniqueNames对象类型需要至少一个member,把root加进去 | 		"uniqueMember":     {l.svcCtx.Config.Ldap.RootDN}, //创建groupOfUniqueNames对象类型需要至少一个member,把root加进去 | ||||||
| 	}) | 	}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | |||||||
| @ -74,7 +74,7 @@ func (l *CreateLdapUserLogic) CreateLdapUser(req *types.CreateLdapUserReq, useri | |||||||
| 		"shadowWarning":    {"7"},                                                                                       //固有属性 | 		"shadowWarning":    {"7"},                                                                                       //固有属性 | ||||||
| 		"loginShell":       {"/usr/sbin/nologin"},                                                                       //固有属性 | 		"loginShell":       {"/usr/sbin/nologin"},                                                                       //固有属性 | ||||||
| 		"homeDirectory":    {"/home/users/" + userNamePinyin}, | 		"homeDirectory":    {"/home/users/" + userNamePinyin}, | ||||||
| 		"employeeType":     {"1"}, //1正式 2实习 3外包 | 		"employeeType":     {fmt.Sprintf("%d", req.EmployeeType)}, //1正式 2实习 3外包 | ||||||
| 		"uidNumber":        {fmt.Sprintf("%d", userData.Id)}, | 		"uidNumber":        {fmt.Sprintf("%d", userData.Id)}, | ||||||
| 		"gidNumber":        {fmt.Sprintf("%d", userData.Id)}, | 		"gidNumber":        {fmt.Sprintf("%d", userData.Id)}, | ||||||
| 		"uid":              {userNamePinyin}, | 		"uid":              {userNamePinyin}, | ||||||
|  | |||||||
| @ -62,6 +62,7 @@ func (l *UpdateLdapUserLogic) UpdateLdapUser(req *types.UpdateLdapUserReq, useri | |||||||
| 		"mobile":           {req.Mobile}, | 		"mobile":           {req.Mobile}, | ||||||
| 		"postalAddress":    {req.Avatar}, | 		"postalAddress":    {req.Avatar}, | ||||||
| 		"postalCode":       {fmt.Sprintf("%d", req.Status)}, | 		"postalCode":       {fmt.Sprintf("%d", req.Status)}, | ||||||
|  | 		"employeeType":     {fmt.Sprintf("%d", req.EmployeeType)}, | ||||||
| 	} | 	} | ||||||
| 	err := ldapServer.Update(req.UserDN, attr) | 	err := ldapServer.Update(req.UserDN, attr) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | |||||||
| @ -117,7 +117,7 @@ type MenuItem struct { | |||||||
| 
 | 
 | ||||||
| type CreateLdapOrganizationReq struct { | type CreateLdapOrganizationReq struct { | ||||||
| 	OrganizationEnName   string `json:"organization_en_name"`   //组织英文名 | 	OrganizationEnName   string `json:"organization_en_name"`   //组织英文名 | ||||||
| 	OrganizationName     string `json:"organization_name"`      //组织中文名称 | 	BusinessCategory     string `json:"business_category"`      //组织类别 | ||||||
| 	ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn | 	ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -136,6 +136,7 @@ type CreateLdapUserReq struct { | |||||||
| 	Password     string `json:"password"`                    //密码 | 	Password     string `json:"password"`                    //密码 | ||||||
| 	Mobile       string `json:"mobile"`                      //手机号 | 	Mobile       string `json:"mobile"`                      //手机号 | ||||||
| 	Avatar       string `json:"avatar"`                      //头像地址 | 	Avatar       string `json:"avatar"`                      //头像地址 | ||||||
|  | 	EmployeeType int64  `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包 | ||||||
| 	Status       int64  `json:"status,options=0|1"`          //状态 1正常0离职 | 	Status       int64  `json:"status,options=0|1"`          //状态 1正常0离职 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -145,6 +146,7 @@ type UpdateLdapUserReq struct { | |||||||
| 	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离职 | ||||||
|  | 	EmployeeType int64  `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包 | ||||||
| 	AuthGroupId  int64  `json:"auth_group_id,optional"`      //权限分组id | 	AuthGroupId  int64  `json:"auth_group_id,optional"`      //权限分组id | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -62,7 +62,7 @@ service ldap-admin { | |||||||
| 	//修改ldap组织 | 	//修改ldap组织 | ||||||
| 	@handler UpdateLdapOrganizationHandler | 	@handler UpdateLdapOrganizationHandler | ||||||
| 	post /api/ldap-admin/update_ldap_organization(UpdateLdapOrganizationReq) returns (response); | 	post /api/ldap-admin/update_ldap_organization(UpdateLdapOrganizationReq) returns (response); | ||||||
| 	//添加ldap用户到员工基本组中 | 	//添加ldap用户帐号 | ||||||
| 	@handler CreateLdapUserHandler | 	@handler CreateLdapUserHandler | ||||||
| 	post /api/ldap-admin/create_ldap_user(CreateLdapUserReq) returns (response); | 	post /api/ldap-admin/create_ldap_user(CreateLdapUserReq) returns (response); | ||||||
| 	//修改ldap用户信息 | 	//修改ldap用户信息 | ||||||
| @ -198,7 +198,7 @@ type MenuItem { | |||||||
| //增加ldap组织 | //增加ldap组织 | ||||||
| type CreateLdapOrganizationReq { | type CreateLdapOrganizationReq { | ||||||
| 	OrganizationEnName   string `json:"organization_en_name"`   //组织英文名 | 	OrganizationEnName   string `json:"organization_en_name"`   //组织英文名 | ||||||
| 	OrganizationName     string `json:"organization_name"`      //组织中文名称 | 	BusinessCategory     string `json:"business_category"`      //组织类别 | ||||||
| 	ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn | 	ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn | ||||||
| } | } | ||||||
| //删除ldap组织 | //删除ldap组织 | ||||||
| @ -210,13 +210,14 @@ type UpdateLdapOrganizationReq { | |||||||
| 	OrganizationDN   string `json:"organization_dn"`   //组织dn | 	OrganizationDN   string `json:"organization_dn"`   //组织dn | ||||||
| 	BusinessCategory string `json:"business_category"` //组织分类名称 | 	BusinessCategory string `json:"business_category"` //组织分类名称 | ||||||
| } | } | ||||||
| //添加ldap用户到员工基本组中 | //添加ldap用户帐号 | ||||||
| type CreateLdapUserReq { | type CreateLdapUserReq { | ||||||
| 	UserName     string `json:"user_name"`                   //用户名 | 	UserName     string `json:"user_name"`                   //用户名 | ||||||
| 	Email        string `json:"email"`                       //邮箱 | 	Email        string `json:"email"`                       //邮箱 | ||||||
| 	Password     string `json:"password"`                    //密码 | 	Password     string `json:"password"`                    //密码 | ||||||
| 	Mobile       string `json:"mobile"`                      //手机号 | 	Mobile       string `json:"mobile"`                      //手机号 | ||||||
| 	Avatar       string `json:"avatar"`                      //头像地址 | 	Avatar       string `json:"avatar"`                      //头像地址 | ||||||
|  | 	EmployeeType int64  `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包 | ||||||
| 	Status       int64  `json:"status,options=0|1"`          //状态 1正常0离职 | 	Status       int64  `json:"status,options=0|1"`          //状态 1正常0离职 | ||||||
| } | } | ||||||
| //修改ldap用户信息 | //修改ldap用户信息 | ||||||
| @ -226,6 +227,7 @@ type UpdateLdapUserReq { | |||||||
| 	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离职 | ||||||
|  | 	EmployeeType int64  `json:"employee_type,options=1|2|3"` //1正式 2实习 3外包 | ||||||
| 	AuthGroupId  int64  `json:"auth_group_id,optional"`      //权限分组id | 	AuthGroupId  int64  `json:"auth_group_id,optional"`      //权限分组id | ||||||
| } | } | ||||||
| //修改用户密码 | //修改用户密码 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user