diff --git a/server/ldap-admin/internal/logic/deleteldaporginationlogic.go b/server/ldap-admin/internal/logic/deleteldaporginationlogic.go index f335462e..499d3fe8 100644 --- a/server/ldap-admin/internal/logic/deleteldaporginationlogic.go +++ b/server/ldap-admin/internal/logic/deleteldaporginationlogic.go @@ -3,6 +3,8 @@ package logic import ( "fusenapi/utils/auth" "fusenapi/utils/basic" + "fusenapi/utils/ldap_lib" + "strings" "context" @@ -31,10 +33,16 @@ func NewDeleteLdapOrginationLogic(ctx context.Context, svcCtx *svc.ServiceContex // } func (l *DeleteLdapOrginationLogic) DeleteLdapOrgination(req *types.DeleteLdapOrginationReq, userinfo *auth.UserInfo) (resp *basic.Response) { - // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) - // userinfo 传入值时, 一定不为null - - return resp.SetStatus(basic.CodeOK) + req.OrginationDN = strings.Trim(req.OrginationDN, " ") + if req.OrginationDN == "" { + 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 { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeServiceErr, "删除ldap组织失败,", err.Error()) + } + return resp.SetStatusWithMessage(basic.CodeOK, "删除成功") } // 处理逻辑后 w,r 如:重定向, resp 必须重新处理