fix
This commit is contained in:
parent
0bec257730
commit
a340da2359
|
@ -11,22 +11,22 @@ import (
|
|||
"fusenapi/server/ldap-admin/internal/types"
|
||||
)
|
||||
|
||||
func AddLdapOrginationMemberHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func AddLdapOrganizationMemberHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.AddLdapOrginationMemberReq
|
||||
var req types.AddLdapOrganizationMemberReq
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewAddLdapOrginationMemberLogic(r.Context(), svcCtx)
|
||||
l := logic.NewAddLdapOrganizationMemberLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.AddLdapOrginationMember(&req, userinfo)
|
||||
resp := l.AddLdapOrganizationMember(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
|
@ -11,22 +11,22 @@ import (
|
|||
"fusenapi/server/ldap-admin/internal/types"
|
||||
)
|
||||
|
||||
func UpdateLdapOrginationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func CreateLdapOrganizationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.UpdateLdapOrginationReq
|
||||
var req types.CreateLdapOrganizationReq
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewUpdateLdapOrginationLogic(r.Context(), svcCtx)
|
||||
l := logic.NewCreateLdapOrganizationLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.UpdateLdapOrgination(&req, userinfo)
|
||||
resp := l.CreateLdapOrganization(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
|
@ -11,22 +11,22 @@ import (
|
|||
"fusenapi/server/ldap-admin/internal/types"
|
||||
)
|
||||
|
||||
func CreateLdapOrginationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func DeleteLdapOrganizationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.CreateLdapOrginationReq
|
||||
var req types.DeleteLdapOrganizationReq
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewCreateLdapOrginationLogic(r.Context(), svcCtx)
|
||||
l := logic.NewDeleteLdapOrganizationLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.CreateLdapOrgination(&req, userinfo)
|
||||
resp := l.DeleteLdapOrganization(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
|
@ -11,7 +11,7 @@ import (
|
|||
"fusenapi/server/ldap-admin/internal/types"
|
||||
)
|
||||
|
||||
func GetLdapOrginationsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func GetLdapOrganizationsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.Request
|
||||
|
@ -21,12 +21,12 @@ func GetLdapOrginationsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewGetLdapOrginationsLogic(r.Context(), svcCtx)
|
||||
l := logic.NewGetLdapOrganizationsLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.GetLdapOrginations(&req, userinfo)
|
||||
resp := l.GetLdapOrganizations(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
|
@ -0,0 +1,35 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"fusenapi/server/ldap-admin/internal/logic"
|
||||
"fusenapi/server/ldap-admin/internal/svc"
|
||||
"fusenapi/server/ldap-admin/internal/types"
|
||||
)
|
||||
|
||||
func RemoveLdapOrganizationMemberHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.RemoveLdapOrganizationMemberReq
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewRemoveLdapOrganizationMemberLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.RemoveLdapOrganizationMember(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"fusenapi/server/ldap-admin/internal/logic"
|
||||
"fusenapi/server/ldap-admin/internal/svc"
|
||||
"fusenapi/server/ldap-admin/internal/types"
|
||||
)
|
||||
|
||||
func RemoveLdapOrginationMemberHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.RemoveLdapOrginationMemberReq
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewRemoveLdapOrginationMemberLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.RemoveLdapOrginationMember(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,23 +44,23 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/ldap-admin/get_ldap_orginations",
|
||||
Handler: GetLdapOrginationsHandler(serverCtx),
|
||||
Path: "/api/ldap-admin/get_ldap_organizations",
|
||||
Handler: GetLdapOrganizationsHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/ldap-admin/create_ldap_orgination",
|
||||
Handler: CreateLdapOrginationHandler(serverCtx),
|
||||
Path: "/api/ldap-admin/create_ldap_organization",
|
||||
Handler: CreateLdapOrganizationHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/ldap-admin/delete_ldap_orgination",
|
||||
Handler: DeleteLdapOrginationHandler(serverCtx),
|
||||
Path: "/api/ldap-admin/delete_ldap_organization",
|
||||
Handler: DeleteLdapOrganizationHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/ldap-admin/update_ldap_orgination",
|
||||
Handler: UpdateLdapOrginationHandler(serverCtx),
|
||||
Path: "/api/ldap-admin/update_ldap_organization",
|
||||
Handler: UpdateLdapOrganizationHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
|
@ -84,13 +84,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/ldap-admin/add_ldap_orgination_member",
|
||||
Handler: AddLdapOrginationMemberHandler(serverCtx),
|
||||
Path: "/api/ldap-admin/add_ldap_organization_member",
|
||||
Handler: AddLdapOrganizationMemberHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/ldap-admin/remove_ldap_orgination_member",
|
||||
Handler: RemoveLdapOrginationMemberHandler(serverCtx),
|
||||
Path: "/api/ldap-admin/remove_ldap_organization_member",
|
||||
Handler: RemoveLdapOrganizationMemberHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
@ -11,22 +11,22 @@ import (
|
|||
"fusenapi/server/ldap-admin/internal/types"
|
||||
)
|
||||
|
||||
func DeleteLdapOrginationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func UpdateLdapOrganizationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.DeleteLdapOrginationReq
|
||||
var req types.UpdateLdapOrganizationReq
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewDeleteLdapOrginationLogic(r.Context(), svcCtx)
|
||||
l := logic.NewUpdateLdapOrganizationLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.DeleteLdapOrgination(&req, userinfo)
|
||||
resp := l.UpdateLdapOrganization(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
|
@ -13,14 +13,14 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddLdapOrginationMemberLogic struct {
|
||||
type AddLdapOrganizationMemberLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAddLdapOrginationMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLdapOrginationMemberLogic {
|
||||
return &AddLdapOrginationMemberLogic{
|
||||
func NewAddLdapOrganizationMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLdapOrganizationMemberLogic {
|
||||
return &AddLdapOrganizationMemberLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
|
@ -28,13 +28,13 @@ func NewAddLdapOrginationMemberLogic(ctx context.Context, svcCtx *svc.ServiceCon
|
|||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *AddLdapOrginationMemberLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *AddLdapOrganizationMemberLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *AddLdapOrginationMemberLogic) AddLdapOrginationMember(req *types.AddLdapOrginationMemberReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrginationDN = strings.Trim(req.OrginationDN, " ")
|
||||
func (l *AddLdapOrganizationMemberLogic) AddLdapOrganizationMember(req *types.AddLdapOrganizationMemberReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrganizationDN = strings.Trim(req.OrganizationDN, " ")
|
||||
req.UserDN = strings.Trim(req.UserDN, " ")
|
||||
if len(req.OrginationDN) <= 3 || req.OrginationDN[:3] != "ou=" {
|
||||
if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的目标组织DN")
|
||||
}
|
||||
if len(req.UserDN) <= 3 || req.UserDN[:3] != "cn=" {
|
||||
|
@ -45,6 +45,6 @@ func (l *AddLdapOrginationMemberLogic) AddLdapOrginationMember(req *types.AddLda
|
|||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *AddLdapOrginationMemberLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *AddLdapOrganizationMemberLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
|
@ -14,14 +14,14 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateLdapOrginationLogic struct {
|
||||
type CreateLdapOrganizationLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLdapOrginationLogic {
|
||||
return &CreateLdapOrginationLogic{
|
||||
func NewCreateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateLdapOrganizationLogic {
|
||||
return &CreateLdapOrganizationLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
|
@ -29,32 +29,32 @@ func NewCreateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
|||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *CreateLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *CreateLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
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, " ")
|
||||
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, " ")
|
||||
req.BusinessCategory = strings.Trim(req.BusinessCategory, " ")
|
||||
if req.OrginationOu == "" {
|
||||
if req.OrganizationOu == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,organization_ou不能为空")
|
||||
}
|
||||
if len(strings.Split(req.OrginationOu, ",")) != 1 {
|
||||
if len(strings.Split(req.OrganizationOu, ",")) != 1 {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,不合法的organization_ou")
|
||||
}
|
||||
if req.ParentOrginationDN == "" {
|
||||
if req.ParentOrganizationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,parentOrganization_dn不能为空")
|
||||
}
|
||||
if req.BusinessCategory == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "参数错误,business_category不能为空")
|
||||
}
|
||||
//组装organization dn
|
||||
organizationDN := "ou=" + req.OrginationOu + "," + req.ParentOrginationDN
|
||||
organizationDN := "ou=" + req.OrganizationOu + "," + req.ParentOrganizationDN
|
||||
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", "groupOfUniqueNames"},
|
||||
"cn": {req.BusinessCategory},
|
||||
"ou": {req.OrginationOu},
|
||||
"ou": {req.OrganizationOu},
|
||||
"businessCategory": {req.BusinessCategory},
|
||||
"uniqueMember": {l.svcCtx.Config.Ldap.RootDN}, //创建groupOfUniqueNames对象类型需要至少一个member,把root加进去
|
||||
})
|
||||
|
@ -66,6 +66,6 @@ func (l *CreateLdapOrginationLogic) CreateLdapOrgination(req *types.CreateLdapOr
|
|||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *CreateLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *CreateLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
|
@ -14,14 +14,14 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteLdapOrginationLogic struct {
|
||||
type DeleteLdapOrganizationLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLdapOrginationLogic {
|
||||
return &DeleteLdapOrginationLogic{
|
||||
func NewDeleteLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLdapOrganizationLogic {
|
||||
return &DeleteLdapOrganizationLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
|
@ -29,19 +29,16 @@ func NewDeleteLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
|||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *DeleteLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *DeleteLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *DeleteLdapOrginationLogic) DeleteLdapOrgination(req *types.DeleteLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrginationDN = strings.Trim(req.OrginationDN, " ")
|
||||
if req.OrginationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "组织DN不能为空")
|
||||
}
|
||||
if len(req.OrginationDN) <= 3 || req.OrginationDN[:3] != "ou=" {
|
||||
func (l *DeleteLdapOrganizationLogic) DeleteLdapOrganization(req *types.DeleteLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrganizationDN = strings.Trim(req.OrganizationDN, " ")
|
||||
if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的组织DN")
|
||||
}
|
||||
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
|
||||
if err := ldapServer.Delete(req.OrginationDN); err != nil {
|
||||
if err := ldapServer.Delete(req.OrganizationDN); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "删除ldap组织失败,", err.Error())
|
||||
}
|
||||
|
@ -49,6 +46,6 @@ func (l *DeleteLdapOrginationLogic) DeleteLdapOrgination(req *types.DeleteLdapOr
|
|||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *DeleteLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *DeleteLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
|
@ -16,14 +16,14 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetLdapOrginationsLogic struct {
|
||||
type GetLdapOrganizationsLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetLdapOrginationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLdapOrginationsLogic {
|
||||
return &GetLdapOrginationsLogic{
|
||||
func NewGetLdapOrganizationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLdapOrganizationsLogic {
|
||||
return &GetLdapOrganizationsLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
|
@ -31,7 +31,7 @@ func NewGetLdapOrginationsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *GetLdapOrginationsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *GetLdapOrganizationsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
type DNItem struct {
|
||||
Attribute map[string]interface{} `json:"attribute"`
|
||||
|
@ -41,7 +41,7 @@ type DNItem struct {
|
|||
Child []*DNItem `json:"child"`
|
||||
}
|
||||
|
||||
func (l *GetLdapOrginationsLogic) GetLdapOrginations(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
//从ldap获取组织架构数据
|
||||
rootCn := strings.Split(l.svcCtx.Config.Ldap.RootDN, ",")
|
||||
if len(rootCn) == 0 {
|
||||
|
@ -120,6 +120,6 @@ func (l *GetLdapOrginationsLogic) GetLdapOrginations(req *types.Request, userinf
|
|||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *GetLdapOrginationsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *GetLdapOrganizationsLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
|
@ -12,14 +12,14 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type RemoveLdapOrginationMemberLogic struct {
|
||||
type RemoveLdapOrganizationMemberLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewRemoveLdapOrginationMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveLdapOrginationMemberLogic {
|
||||
return &RemoveLdapOrginationMemberLogic{
|
||||
func NewRemoveLdapOrganizationMemberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveLdapOrganizationMemberLogic {
|
||||
return &RemoveLdapOrganizationMemberLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
|
@ -27,10 +27,10 @@ func NewRemoveLdapOrginationMemberLogic(ctx context.Context, svcCtx *svc.Service
|
|||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *RemoveLdapOrginationMemberLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *RemoveLdapOrganizationMemberLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *RemoveLdapOrginationMemberLogic) RemoveLdapOrginationMember(req *types.RemoveLdapOrginationMemberReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
func (l *RemoveLdapOrganizationMemberLogic) RemoveLdapOrganizationMember(req *types.RemoveLdapOrganizationMemberReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
|
||||
|
@ -38,6 +38,6 @@ func (l *RemoveLdapOrginationMemberLogic) RemoveLdapOrginationMember(req *types.
|
|||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *RemoveLdapOrginationMemberLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *RemoveLdapOrganizationMemberLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
|
@ -14,14 +14,14 @@ import (
|
|||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateLdapOrginationLogic struct {
|
||||
type UpdateLdapOrganizationLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLdapOrginationLogic {
|
||||
return &UpdateLdapOrginationLogic{
|
||||
func NewUpdateLdapOrganizationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLdapOrganizationLogic {
|
||||
return &UpdateLdapOrganizationLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
|
@ -29,19 +29,19 @@ func NewUpdateLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
|||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *UpdateLdapOrginationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// func (l *UpdateLdapOrganizationLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *UpdateLdapOrginationLogic) UpdateLdapOrgination(req *types.UpdateLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrginationDN = strings.Trim(req.OrginationDN, " ")
|
||||
if req.OrginationDN == "" {
|
||||
func (l *UpdateLdapOrganizationLogic) UpdateLdapOrganization(req *types.UpdateLdapOrganizationReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
req.OrganizationDN = strings.Trim(req.OrganizationDN, " ")
|
||||
if req.OrganizationDN == "" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "组织DN不能为空")
|
||||
}
|
||||
if len(req.OrginationDN) <= 3 || req.OrginationDN[:3] != "ou=" {
|
||||
if len(req.OrganizationDN) <= 3 || req.OrganizationDN[:3] != "ou=" {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "无效的组织DN")
|
||||
}
|
||||
ldapServer := ldap_lib.NewLdap(l.svcCtx.Ldap, l.svcCtx.Config.Ldap.BaseDN, l.svcCtx.Config.Ldap.RootDN)
|
||||
if err := ldapServer.Update(req.OrginationDN, map[string][]string{
|
||||
if err := ldapServer.Update(req.OrganizationDN, map[string][]string{
|
||||
"cn": {req.BusinessCategory},
|
||||
"businessCategory": {req.BusinessCategory},
|
||||
}); err != nil {
|
||||
|
@ -52,6 +52,6 @@ func (l *UpdateLdapOrginationLogic) UpdateLdapOrgination(req *types.UpdateLdapOr
|
|||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *UpdateLdapOrginationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// func (l *UpdateLdapOrganizationLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
|
@ -73,18 +73,18 @@ type MenuItem struct {
|
|||
Status int64 `json:"status"`
|
||||
}
|
||||
|
||||
type CreateLdapOrginationReq struct {
|
||||
OrginationOu string `json:"orgination_ou"` //组织ou
|
||||
BusinessCategory string `json:"business_category"` //组织分类名称
|
||||
ParentOrginationDN string `json:"parent_orgination_dn"` //父级dn
|
||||
type CreateLdapOrganizationReq struct {
|
||||
OrganizationOu string `json:"organization_ou"` //组织ou
|
||||
BusinessCategory string `json:"business_category"` //组织分类名称
|
||||
ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn
|
||||
}
|
||||
|
||||
type DeleteLdapOrginationReq struct {
|
||||
OrginationDN string `json:"orgination_dn"` //组织dn
|
||||
type DeleteLdapOrganizationReq struct {
|
||||
OrganizationDN string `json:"organization_dn"` //组织dn
|
||||
}
|
||||
|
||||
type UpdateLdapOrginationReq struct {
|
||||
OrginationDN string `json:"orgination_dn"` //组织dn
|
||||
type UpdateLdapOrganizationReq struct {
|
||||
OrganizationDN string `json:"organization_dn"` //组织dn
|
||||
BusinessCategory string `json:"business_category"` //组织分类名称
|
||||
}
|
||||
|
||||
|
@ -124,14 +124,14 @@ type GetLdapUserInfoRsp struct {
|
|||
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
|
||||
}
|
||||
|
||||
type AddLdapOrginationMemberReq struct {
|
||||
OrginationDN string `json:"orgination_dn"` //目标组织DN
|
||||
UserDN string `json:"user_dn"` //用户DN
|
||||
type AddLdapOrganizationMemberReq struct {
|
||||
OrganizationDN string `json:"organization_dn"` //目标组织DN
|
||||
UserDN string `json:"user_dn"` //用户DN
|
||||
}
|
||||
|
||||
type RemoveLdapOrginationMemberReq struct {
|
||||
OrginationDN string `json:"orgination_dn"` //目标组织DN
|
||||
UserDN string `json:"user_dn"` //用户DN
|
||||
type RemoveLdapOrganizationMemberReq struct {
|
||||
OrganizationDN string `json:"organization_dn"` //目标组织DN
|
||||
UserDN string `json:"user_dn"` //用户DN
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
|
|
|
@ -31,17 +31,17 @@ service ldap-admin {
|
|||
@handler GetMenusHandler
|
||||
get /api/ldap-admin/get_menus(GetMenusReq) returns (response);
|
||||
//获取ldap组织列表
|
||||
@handler GetLdapOrginationsHandler
|
||||
get /api/ldap-admin/get_ldap_orginations(request) returns (response);
|
||||
@handler GetLdapOrganizationsHandler
|
||||
get /api/ldap-admin/get_ldap_organizations(request) returns (response);
|
||||
//增加ldap组织
|
||||
@handler CreateLdapOrginationHandler
|
||||
post /api/ldap-admin/create_ldap_orgination(CreateLdapOrginationReq) returns (response);
|
||||
@handler CreateLdapOrganizationHandler
|
||||
post /api/ldap-admin/create_ldap_organization(CreateLdapOrganizationReq) returns (response);
|
||||
//删除ldap组织
|
||||
@handler DeleteLdapOrginationHandler
|
||||
post /api/ldap-admin/delete_ldap_orgination(DeleteLdapOrginationReq) returns (response);
|
||||
@handler DeleteLdapOrganizationHandler
|
||||
post /api/ldap-admin/delete_ldap_organization(DeleteLdapOrganizationReq) returns (response);
|
||||
//修改ldap组织
|
||||
@handler UpdateLdapOrginationHandler
|
||||
post /api/ldap-admin/update_ldap_orgination(UpdateLdapOrginationReq) returns (response);
|
||||
@handler UpdateLdapOrganizationHandler
|
||||
post /api/ldap-admin/update_ldap_organization(UpdateLdapOrganizationReq) returns (response);
|
||||
//添加ldap用户到员工基本组中
|
||||
@handler CreateLdapUserHandler
|
||||
post /api/ldap-admin/create_ldap_user(CreateLdapUserReq) returns (response);
|
||||
|
@ -55,11 +55,11 @@ service ldap-admin {
|
|||
@handler GetLdapUserInfoHandler
|
||||
get /api/ldap-admin/get_ldap_user_info(GetLdapUserInfoReq) returns (response);
|
||||
//ldap组织添加成员
|
||||
@handler AddLdapOrginationMemberHandler
|
||||
post /api/ldap-admin/add_ldap_orgination_member(AddLdapOrginationMemberReq) returns (response);
|
||||
@handler AddLdapOrganizationMemberHandler
|
||||
post /api/ldap-admin/add_ldap_organization_member(AddLdapOrganizationMemberReq) returns (response);
|
||||
//ldap组织移除成员
|
||||
@handler RemoveLdapOrginationMemberHandler
|
||||
post /api/ldap-admin/remove_ldap_orgination_member(RemoveLdapOrginationMemberReq) returns (response);
|
||||
@handler RemoveLdapOrganizationMemberHandler
|
||||
post /api/ldap-admin/remove_ldap_organization_member(RemoveLdapOrganizationMemberReq) returns (response);
|
||||
}
|
||||
|
||||
type GetApisReq {
|
||||
|
@ -128,18 +128,18 @@ type MenuItem {
|
|||
Status int64 `json:"status"`
|
||||
}
|
||||
//增加ldap组织
|
||||
type CreateLdapOrginationReq {
|
||||
OrginationOu string `json:"orgination_ou"` //组织ou
|
||||
BusinessCategory string `json:"business_category"` //组织分类名称
|
||||
ParentOrginationDN string `json:"parent_orgination_dn"` //父级dn
|
||||
type CreateLdapOrganizationReq {
|
||||
OrganizationOu string `json:"organization_ou"` //组织ou
|
||||
BusinessCategory string `json:"business_category"` //组织分类名称
|
||||
ParentOrganizationDN string `json:"parent_organization_dn"` //父级dn
|
||||
}
|
||||
//删除ldap组织
|
||||
type DeleteLdapOrginationReq {
|
||||
OrginationDN string `json:"orgination_dn"` //组织dn
|
||||
type DeleteLdapOrganizationReq {
|
||||
OrganizationDN string `json:"organization_dn"` //组织dn
|
||||
}
|
||||
//修改ldap组织
|
||||
type UpdateLdapOrginationReq {
|
||||
OrginationDN string `json:"orgination_dn"` //组织dn
|
||||
type UpdateLdapOrganizationReq {
|
||||
OrganizationDN string `json:"organization_dn"` //组织dn
|
||||
BusinessCategory string `json:"business_category"` //组织分类名称
|
||||
}
|
||||
//添加ldap用户到员工基本组中
|
||||
|
@ -178,12 +178,12 @@ type GetLdapUserInfoRsp {
|
|||
Status int64 `json:"status,options=0|1"` //状态 1正常0离职
|
||||
}
|
||||
//ldap组织添加成员
|
||||
type AddLdapOrginationMemberReq {
|
||||
OrginationDN string `json:"orgination_dn"` //目标组织DN
|
||||
UserDN string `json:"user_dn"` //用户DN
|
||||
type AddLdapOrganizationMemberReq {
|
||||
OrganizationDN string `json:"organization_dn"` //目标组织DN
|
||||
UserDN string `json:"user_dn"` //用户DN
|
||||
}
|
||||
//ldap组织移除成员
|
||||
type RemoveLdapOrginationMemberReq {
|
||||
OrginationDN string `json:"orgination_dn"` //目标组织DN
|
||||
UserDN string `json:"user_dn"` //用户DN
|
||||
type RemoveLdapOrganizationMemberReq {
|
||||
OrganizationDN string `json:"organization_dn"` //目标组织DN
|
||||
UserDN string `json:"user_dn"` //用户DN
|
||||
}
|
Loading…
Reference in New Issue
Block a user