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