This commit is contained in:
laodaming
2023-11-17 10:33:40 +08:00
parent 0bec257730
commit a340da2359
16 changed files with 158 additions and 161 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}
}

View File

@@ -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),
},
},
)

View File

@@ -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)