fix
This commit is contained in:
parent
681ec8269c
commit
ca91a6f3ce
|
@ -2,7 +2,6 @@ package logic
|
|||
|
||||
import (
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/chinese_to_pinyin"
|
||||
"fusenapi/utils/email"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -38,22 +37,14 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
|
|||
if !l.svcCtx.Ldap.VerifyAuthority(r) {
|
||||
return resp.SetStatusWithMessage(basic.CodeUnAuth, "无权限,请联系管理员开通")
|
||||
}
|
||||
req.OrganizationEnName = strings.Trim(req.OrganizationEnName, " ")
|
||||
req.ParentOrganizationDN = strings.Trim(req.ParentOrganizationDN, " ")
|
||||
req.BusinessCategory = strings.Trim(req.BusinessCategory, " ")
|
||||
if len(strings.Split(req.OrganizationEnName, ",")) != 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织英文名不符合规范")
|
||||
}
|
||||
//转拼音比较下
|
||||
if req.OrganizationEnName != chinese_to_pinyin.ChineseToPinyin(req.OrganizationEnName) {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织英文名不能包含中文")
|
||||
req.OrganizationName = strings.Trim(req.OrganizationName, " ")
|
||||
if req.OrganizationName == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "组织名不能为空")
|
||||
}
|
||||
if req.ParentOrganizationDN == "" {
|
||||
req.ParentOrganizationDN = l.svcCtx.Config.Ldap.BaseDN //不传则是第一层级
|
||||
}
|
||||
if req.BusinessCategory == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,组织分类名不能为空")
|
||||
}
|
||||
if len(req.OwnerDN) <= 3 || req.OwnerDN[:3] != "cn=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的用户DN")
|
||||
}
|
||||
|
@ -62,13 +53,13 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
|
|||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "错误的用户cn")
|
||||
}
|
||||
//组装organization dn
|
||||
organizationDN := "ou=" + req.OrganizationEnName + "," + req.ParentOrganizationDN
|
||||
organizationDN := "ou=" + req.OrganizationName + "," + req.ParentOrganizationDN
|
||||
err := l.svcCtx.Ldap.Create(organizationDN, map[string][]string{
|
||||
"objectClass": {"top", "groupOfUniqueNames"},
|
||||
"owner": {req.OwnerDN}, //负责人DN
|
||||
"cn": {req.OrganizationEnName},
|
||||
"ou": {req.OrganizationEnName},
|
||||
"businessCategory": {req.BusinessCategory},
|
||||
"cn": {req.OrganizationName},
|
||||
"ou": {req.OrganizationName},
|
||||
"businessCategory": {req.OrganizationName},
|
||||
"uniqueMember": {req.OwnerDN}, //必须有一个初始的成员
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -133,8 +133,7 @@ type MenuItem struct {
|
|||
}
|
||||
|
||||
type CreateLdapOrganizationReq struct {
|
||||
OrganizationEnName string `json:"organization_en_name"` //组织英文名
|
||||
BusinessCategory string `json:"business_category"` //组织类别名称
|
||||
OrganizationName string `json:"organization_name"` //组织名
|
||||
ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn
|
||||
OwnerDN string `json:"owner_dn"` //负责人dn
|
||||
}
|
||||
|
|
|
@ -221,10 +221,9 @@ type MenuItem {
|
|||
}
|
||||
//增加ldap组织
|
||||
type CreateLdapOrganizationReq {
|
||||
OrganizationEnName string `json:"organization_en_name"` //组织英文名
|
||||
BusinessCategory string `json:"business_category"` //组织类别名称
|
||||
ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn
|
||||
OwnerDN string `json:"owner_dn"` //负责人dn
|
||||
OrganizationName string `json:"organization_name"` //组织名
|
||||
ParentOrganizationDN string `json:"parent_organization_dn,optional"` //父级dn
|
||||
OwnerDN string `json:"owner_dn,optional"` //负责人dn
|
||||
}
|
||||
//删除ldap组织
|
||||
type DeleteLdapOrganizationReq {
|
||||
|
|
Loading…
Reference in New Issue
Block a user