增加添加部门接口

This commit is contained in:
laodaming
2023-11-16 14:29:24 +08:00
parent 6fb16aa12c
commit c7ca444fe7
11 changed files with 75 additions and 75 deletions

View File

@@ -14,14 +14,14 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type CreateLdapOrganizationLogic struct {
type CreateLdapOrginationLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLdapOrganizationLogic {
return &CreateLdapOrganizationLogic{
func NewCreateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLdapOrginationLogic {
return &CreateLdapOrginationLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
@@ -29,31 +29,31 @@ func NewCreateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceCont
}
// 处理进入前逻辑w,r
// func (l *CreateLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// func (l *CreateLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
req.OrganizationOu = strings.Trim(req.OrganizationOu, " ")
req.ParentOrganizationDN = strings.Trim(req.ParentOrganizationDN, " ")
func (l *CreateLdapOrginationLogic) CreateLdapOrgination(req *types.CreateLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
req.OrginationOu = strings.Trim(req.OrginationOu, " ")
req.ParentOrginationDN = strings.Trim(req.ParentOrginationDN, " ")
req.BusinessCategory = strings.Trim(req.BusinessCategory, " ")
if req.OrganizationOu == "" {
if req.OrginationOu == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,organization_ou不能为空")
}
if len(strings.Split(req.OrganizationOu, ",")) != 1 {
if len(strings.Split(req.OrginationOu, ",")) != 1 {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,不合法的organization_ou")
}
if req.ParentOrganizationDN == "" {
if req.ParentOrginationDN == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,parentOrganization_dn不能为空")
}
if req.BusinessCategory == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,business_category不能为空")
}
//组装organization dn
organizationDN := "ou=" + req.OrganizationOu + "," + req.ParentOrganizationDN
organizationDN := "ou=" + req.OrginationOu + "," + req.ParentOrginationDN
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
err := ldapServer.Create(organizationDN, map[string][]string{
"objectClass": {"top", "organizationalUnit"},
"ou": {req.OrganizationOu},
"ou": {req.OrginationOu},
"businessCategory": {req.BusinessCategory},
})
if err != nil {
@@ -64,6 +64,6 @@ func (l *CreateLdapOrganizationLogic) CreateLdapOrganization(req *types.CreateLd
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *CreateLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// func (l *CreateLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -12,14 +12,14 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteLdapOrganizationLogic struct {
type DeleteLdapOrginationLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDeleteLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLdapOrganizationLogic {
return &DeleteLdapOrganizationLogic{
func NewDeleteLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLdapOrginationLogic {
return &DeleteLdapOrginationLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
@@ -27,10 +27,10 @@ func NewDeleteLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceCont
}
// 处理进入前逻辑w,r
// func (l *DeleteLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// func (l *DeleteLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *DeleteLdapOrganizationLogic) DeleteLdapOrganization(req *types.DeleteLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
func (l *DeleteLdapOrginationLogic) DeleteLdapOrgination(req *types.DeleteLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
@@ -38,6 +38,6 @@ func (l *DeleteLdapOrganizationLogic) DeleteLdapOrganization(req *types.DeleteLd
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *DeleteLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// func (l *DeleteLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -15,14 +15,14 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type GetOrganizationsLogic struct {
type GetorginationsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetOrganizationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOrganizationsLogic {
return &GetOrganizationsLogic{
func NewGetorginationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetorginationsLogic {
return &GetorginationsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
@@ -30,7 +30,7 @@ func NewGetOrganizationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}
// 处理进入前逻辑w,r
// func (l *GetOrganizationsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// func (l *GetorginationsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
type DNItem struct {
Attribute map[string]interface{} `json:"attribute"`
@@ -40,7 +40,7 @@ type DNItem struct {
Child []*DNItem `json:"child"`
}
func (l *GetOrganizationsLogic) GetOrganizations(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
func (l *GetorginationsLogic) Getorginations(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
//从ldap获取组织架构数据
rootCn := strings.Split(l.svcCtx.Config.Ldap.RootDN, ",")
if len(rootCn) == 0 {
@@ -115,6 +115,6 @@ func (l *GetOrganizationsLogic) GetOrganizations(req *types.Request, userinfo *a
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *GetOrganizationsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// func (l *GetorginationsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }

View File

@@ -12,14 +12,14 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type UpdateLdapOrganizationLogic struct {
type UpdateLdapOrginationLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUpdateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLdapOrganizationLogic {
return &UpdateLdapOrganizationLogic{
func NewUpdateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLdapOrginationLogic {
return &UpdateLdapOrginationLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
@@ -27,10 +27,10 @@ func NewUpdateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceCont
}
// 处理进入前逻辑w,r
// func (l *UpdateLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// func (l *UpdateLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
// }
func (l *UpdateLdapOrganizationLogic) UpdateLdapOrganization(req *types.UpdateLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
func (l *UpdateLdapOrginationLogic) UpdateLdapOrgination(req *types.UpdateLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
// userinfo 传入值时, 一定不为null
@@ -38,6 +38,6 @@ func (l *UpdateLdapOrganizationLogic) UpdateLdapOrganization(req *types.UpdateLd
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *UpdateLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// func (l *UpdateLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }