Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop

This commit is contained in:
eson 2023-11-24 13:16:01 +08:00
commit 5005bac4a5
5 changed files with 23 additions and 23 deletions

View File

@ -55,7 +55,7 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
}
organizationNamePinyin := chinese_to_pinyin.ChineseToPinyin(req.OrganizationName)
//组装organization dn
organizationDN := "ou=" + req.OrganizationName + "," + req.ParentOrganizationDN
organizationDN := "ou=" + organizationNamePinyin + "," + req.ParentOrganizationDN
err := l.svcCtx.Ldap.Create(organizationDN, map[string][]string{
"objectClass": {"top", "groupOfUniqueNames"},
"owner": {req.OwnerDN}, //负责人DN

View File

@ -34,15 +34,15 @@ func NewGetLdapOrganizationsLogic(ctx context.Context, svcCtx *svc.ServiceContex
// func (l *GetLdapOrganizationsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
type DNItem struct {
MemberCount int `json:"member_count"`
BusinessCategory string `json:"business_category"`
OwnerName string `json:"owner_name"`
OwnerDN string `json:"owner_dn"`
Level int `json:"level"`
DepartmentDN string `json:"department_dn"`
DepartmentParentDN string `json:"department_parent_dn"`
Sort int `json:"sort"`
Child []*DNItem `json:"child"`
MemberCount int `json:"member_count"`
OrganizationName string `json:"organization_name"`
OwnerName string `json:"owner_name"`
OwnerDN string `json:"owner_dn"`
Level int `json:"level"`
OrganizationDN string `json:"organization_dn"`
ParentOrganizationDN string `json:"parent_organization_dn"`
Sort int `json:"sort"`
Child []*DNItem `json:"child"`
}
func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, r *http.Request) (resp *basic.Response) {
@ -72,8 +72,8 @@ func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, r *
ownerDN := ""
for _, v := range searchResult.Entries {
sortNum++
memberCount := 0 //成员数
businessCategory := "" //部门名称
memberCount := 0 //成员数
departmentName := "" //部门名称
for _, attr := range v.Attributes {
switch attr.Name {
case "uniqueMember":
@ -87,14 +87,14 @@ func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, r *
userCn := strings.Split(attr.Values[0], ",")[0]
ownerFilterBuilder.WriteString(fmt.Sprintf("(%s)", userCn))
case "businessCategory":
businessCategory = strings.Join(attr.Values, ",")
departmentName = strings.Join(attr.Values, ",")
}
}
dnSlice := strings.ReplaceAll(v.DN, ","+l.svcCtx.Config.Ldap.BaseDN, "") //把最顶级的组织去掉
level := len(strings.Split(dnSlice, ","))
data := &DNItem{
DepartmentDN: v.DN,
BusinessCategory: businessCategory,
OrganizationDN: v.DN,
OrganizationName: departmentName,
Level: level,
MemberCount: memberCount,
OwnerDN: ownerDN,
@ -136,7 +136,7 @@ func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, r *
//有父级
parentDN := strings.Join(sl[1:], ",")
if parent, ok := mapDN[parentDN]; ok {
v.DepartmentParentDN = parentDN
v.ParentOrganizationDN = parentDN
parent.Child = append(parent.Child, v)
//排序
sort.Slice(parent.Child, func(i, j int) bool {

View File

@ -44,7 +44,7 @@ func (l *UpdateLdapOrganizationLogic) UpdateLdapOrganization(req *types.UpdateLd
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误无效的组织DN")
}
if err := l.svcCtx.Ldap.Update(req.OrganizationDN, map[string][]string{
"businessCategory": {req.BusinessCategory},
"businessCategory": {req.OrganizationName},
}); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "更新ldap组织失败,"+err.Error())

View File

@ -133,9 +133,9 @@ type MenuItem struct {
}
type CreateLdapOrganizationReq struct {
OrganizationName string `json:"organization_name"` //组织名
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
}
type DeleteLdapOrganizationReq struct {
@ -144,7 +144,7 @@ type DeleteLdapOrganizationReq struct {
type UpdateLdapOrganizationReq struct {
OrganizationDN string `json:"organization_dn"` //组织dn
BusinessCategory string `json:"business_category"` //组织分类名称
OrganizationName string `json:"organization_name"` //组织分类名称
}
type CreateLdapUserReq struct {

View File

@ -221,7 +221,7 @@ type MenuItem {
}
//增加ldap组织
type CreateLdapOrganizationReq {
OrganizationName string `json:"organization_name"` //组织名
OrganizationName string `json:"organization_name"` //组织名
ParentOrganizationDN string `json:"parent_organization_dn,optional"` //父级dn
OwnerDN string `json:"owner_dn,optional"` //负责人dn
}
@ -232,7 +232,7 @@ type DeleteLdapOrganizationReq {
//修改ldap组织
type UpdateLdapOrganizationReq {
OrganizationDN string `json:"organization_dn"` //组织dn
BusinessCategory string `json:"business_category"` //组织分类名称
OrganizationName string `json:"organization_name"` //组织分类名称
}
//添加ldap用户帐号
type CreateLdapUserReq {