|
@@ -1,7 +1,6 @@
|
|
|
package entity_crud
|
|
|
|
|
|
import (
|
|
|
- "git.sxidc.com/go-framework/baize/framework/core/api"
|
|
|
"git.sxidc.com/go-framework/baize/framework/core/api/response"
|
|
|
"git.sxidc.com/go-framework/baize/framework/gateway"
|
|
|
"git.sxidc.com/go-tools/utils/http_client"
|
|
@@ -83,8 +82,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
builder.PostRouteWithTenantIDAndCreateUserInfo("/"+simple.ServiceShortName+domainPath+"/create",
|
|
|
func(requestBuilder *gateway.RequestBuilder) {
|
|
|
if createOptions.responseSuccessCallback != nil {
|
|
|
- requestBuilder.ResponseSuccessCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) {
|
|
|
- err := createOptions.responseSuccessCallback(c, historyRequests, resultMap)
|
|
|
+ requestBuilder.ResponseSuccessCallback(func(c *gateway.RequestBuilderContext) {
|
|
|
+ err := createOptions.responseSuccessCallback(c)
|
|
|
if err != nil {
|
|
|
requestBuilder.ResponseError(err)
|
|
|
return
|
|
@@ -93,8 +92,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
}
|
|
|
|
|
|
if createOptions.responseErrorCallback != nil {
|
|
|
- requestBuilder.ResponseErrorCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, err error) {
|
|
|
- retErr := createOptions.responseErrorCallback(c, historyRequests, resultMap, err)
|
|
|
+ requestBuilder.ResponseErrorCallback(func(c *gateway.RequestBuilderContext, err error) {
|
|
|
+ retErr := createOptions.responseErrorCallback(c, err)
|
|
|
if retErr != nil {
|
|
|
requestBuilder.ResponseError(retErr)
|
|
|
return
|
|
@@ -108,17 +107,17 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
Url: simple.ServiceVersionedUrl + domainPath + "/create",
|
|
|
},
|
|
|
gateway.WithBeforeRequestCallback(
|
|
|
- func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) error {
|
|
|
+ func(c *gateway.RequestBuilderContext) error {
|
|
|
if createOptions.beforeBuilderCallback != nil {
|
|
|
- return createOptions.beforeBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ return createOptions.beforeBuilderCallback(c)
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
}),
|
|
|
gateway.WithRequestResponseCallback(
|
|
|
- func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, response *http_client.Response) error {
|
|
|
+ func(c *gateway.RequestBuilderContext, response *http_client.Response) error {
|
|
|
if createOptions.afterBuilderCallback != nil {
|
|
|
- err := createOptions.afterBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := createOptions.afterBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -126,8 +125,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
|
|
|
return nil
|
|
|
})).
|
|
|
- ResponseErrorCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, err error) {
|
|
|
- response.SendIDResponse(requestBuilder.Context(), http.StatusOK, "", err)
|
|
|
+ ResponseErrorCallback(func(c *gateway.RequestBuilderContext, err error) {
|
|
|
+ response.SendIDResponse(c.ApiContext(), http.StatusOK, "", err)
|
|
|
}).
|
|
|
Request()
|
|
|
}, createMiddlewares...)
|
|
@@ -140,8 +139,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
builder.DeleteRouteWithDeleteUserInfo("/"+simple.ServiceShortName+domainPath+"/delete",
|
|
|
func(requestBuilder *gateway.RequestBuilder) {
|
|
|
if deleteOptions.responseSuccessCallback != nil {
|
|
|
- requestBuilder.ResponseSuccessCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) {
|
|
|
- err := deleteOptions.responseSuccessCallback(c, historyRequests, resultMap)
|
|
|
+ requestBuilder.ResponseSuccessCallback(func(c *gateway.RequestBuilderContext) {
|
|
|
+ err := deleteOptions.responseSuccessCallback(c)
|
|
|
if err != nil {
|
|
|
requestBuilder.ResponseError(err)
|
|
|
return
|
|
@@ -150,8 +149,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
}
|
|
|
|
|
|
if deleteOptions.responseErrorCallback != nil {
|
|
|
- requestBuilder.ResponseErrorCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, err error) {
|
|
|
- retErr := deleteOptions.responseErrorCallback(c, historyRequests, resultMap, err)
|
|
|
+ requestBuilder.ResponseErrorCallback(func(c *gateway.RequestBuilderContext, err error) {
|
|
|
+ retErr := deleteOptions.responseErrorCallback(c, err)
|
|
|
if retErr != nil {
|
|
|
requestBuilder.ResponseError(retErr)
|
|
|
return
|
|
@@ -165,9 +164,9 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
Url: simple.ServiceVersionedUrl + domainPath + "/delete",
|
|
|
},
|
|
|
gateway.WithBeforeRequestCallback(
|
|
|
- func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) error {
|
|
|
+ func(c *gateway.RequestBuilderContext) error {
|
|
|
if deleteOptions.beforeBuilderCallback != nil {
|
|
|
- err := deleteOptions.beforeBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := deleteOptions.beforeBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -176,9 +175,9 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
return nil
|
|
|
}),
|
|
|
gateway.WithRequestResponseCallback(
|
|
|
- func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, response *http_client.Response) error {
|
|
|
+ func(c *gateway.RequestBuilderContext, response *http_client.Response) error {
|
|
|
if deleteOptions.afterBuilderCallback != nil {
|
|
|
- err := deleteOptions.afterBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := deleteOptions.afterBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -197,8 +196,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
builder.PutRouteWithUpdateUserInfo("/"+simple.ServiceShortName+domainPath+"/update",
|
|
|
func(requestBuilder *gateway.RequestBuilder) {
|
|
|
if updateOptions.responseSuccessCallback != nil {
|
|
|
- requestBuilder.ResponseSuccessCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) {
|
|
|
- err := updateOptions.responseSuccessCallback(c, historyRequests, resultMap)
|
|
|
+ requestBuilder.ResponseSuccessCallback(func(c *gateway.RequestBuilderContext) {
|
|
|
+ err := updateOptions.responseSuccessCallback(c)
|
|
|
if err != nil {
|
|
|
requestBuilder.ResponseError(err)
|
|
|
return
|
|
@@ -207,8 +206,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
}
|
|
|
|
|
|
if updateOptions.responseErrorCallback != nil {
|
|
|
- requestBuilder.ResponseErrorCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, err error) {
|
|
|
- retErr := updateOptions.responseErrorCallback(c, historyRequests, resultMap, err)
|
|
|
+ requestBuilder.ResponseErrorCallback(func(c *gateway.RequestBuilderContext, err error) {
|
|
|
+ retErr := updateOptions.responseErrorCallback(c, err)
|
|
|
if retErr != nil {
|
|
|
requestBuilder.ResponseError(retErr)
|
|
|
return
|
|
@@ -221,9 +220,9 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
&gateway.PutRequest{
|
|
|
Url: simple.ServiceVersionedUrl + domainPath + "/update",
|
|
|
},
|
|
|
- gateway.WithBeforeRequestCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) error {
|
|
|
+ gateway.WithBeforeRequestCallback(func(c *gateway.RequestBuilderContext) error {
|
|
|
if updateOptions.beforeBuilderCallback != nil {
|
|
|
- err := updateOptions.beforeBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := updateOptions.beforeBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -232,9 +231,9 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
return nil
|
|
|
}),
|
|
|
gateway.WithRequestResponseCallback(
|
|
|
- func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, response *http_client.Response) error {
|
|
|
+ func(c *gateway.RequestBuilderContext, response *http_client.Response) error {
|
|
|
if updateOptions.afterBuilderCallback != nil {
|
|
|
- err := updateOptions.afterBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := updateOptions.afterBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -253,8 +252,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
builder.GetRouteWithTenantID("/"+simple.ServiceShortName+domainPath+"/query",
|
|
|
func(requestBuilder *gateway.RequestBuilder) {
|
|
|
if queryOptions.responseSuccessCallback != nil {
|
|
|
- requestBuilder.ResponseSuccessCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) {
|
|
|
- err := queryOptions.responseSuccessCallback(c, historyRequests, resultMap)
|
|
|
+ requestBuilder.ResponseSuccessCallback(func(c *gateway.RequestBuilderContext) {
|
|
|
+ err := queryOptions.responseSuccessCallback(c)
|
|
|
if err != nil {
|
|
|
requestBuilder.ResponseError(err)
|
|
|
return
|
|
@@ -263,8 +262,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
}
|
|
|
|
|
|
if queryOptions.responseErrorCallback != nil {
|
|
|
- requestBuilder.ResponseErrorCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, err error) {
|
|
|
- retErr := queryOptions.responseErrorCallback(c, historyRequests, resultMap, err)
|
|
|
+ requestBuilder.ResponseErrorCallback(func(c *gateway.RequestBuilderContext, err error) {
|
|
|
+ retErr := queryOptions.responseErrorCallback(c, err)
|
|
|
if retErr != nil {
|
|
|
requestBuilder.ResponseError(retErr)
|
|
|
return
|
|
@@ -277,9 +276,9 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
&gateway.GetRequest{
|
|
|
Url: simple.ServiceVersionedUrl + domainPath + "/query",
|
|
|
},
|
|
|
- gateway.WithBeforeRequestCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) error {
|
|
|
+ gateway.WithBeforeRequestCallback(func(c *gateway.RequestBuilderContext) error {
|
|
|
if queryOptions.beforeBuilderCallback != nil {
|
|
|
- err := queryOptions.beforeBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := queryOptions.beforeBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -288,9 +287,9 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
return nil
|
|
|
}),
|
|
|
gateway.WithRequestResponseCallback(
|
|
|
- func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, response *http_client.Response) error {
|
|
|
+ func(c *gateway.RequestBuilderContext, response *http_client.Response) error {
|
|
|
if queryOptions.afterBuilderCallback != nil {
|
|
|
- err := queryOptions.afterBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := queryOptions.afterBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -309,8 +308,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
builder.GetRoute("/"+simple.ServiceShortName+domainPath+"/get",
|
|
|
func(requestBuilder *gateway.RequestBuilder) {
|
|
|
if getByIDOptions.responseSuccessCallback != nil {
|
|
|
- requestBuilder.ResponseSuccessCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) {
|
|
|
- err := getByIDOptions.responseSuccessCallback(c, historyRequests, resultMap)
|
|
|
+ requestBuilder.ResponseSuccessCallback(func(c *gateway.RequestBuilderContext) {
|
|
|
+ err := getByIDOptions.responseSuccessCallback(c)
|
|
|
if err != nil {
|
|
|
requestBuilder.ResponseError(err)
|
|
|
return
|
|
@@ -319,8 +318,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
}
|
|
|
|
|
|
if getByIDOptions.responseErrorCallback != nil {
|
|
|
- requestBuilder.ResponseErrorCallback(func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, err error) {
|
|
|
- retErr := getByIDOptions.responseErrorCallback(c, historyRequests, resultMap, err)
|
|
|
+ requestBuilder.ResponseErrorCallback(func(c *gateway.RequestBuilderContext, err error) {
|
|
|
+ retErr := getByIDOptions.responseErrorCallback(c, err)
|
|
|
if retErr != nil {
|
|
|
requestBuilder.ResponseError(retErr)
|
|
|
return
|
|
@@ -334,9 +333,9 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
Url: simple.ServiceVersionedUrl + domainPath + "/get",
|
|
|
},
|
|
|
gateway.WithBeforeRequestCallback(
|
|
|
- func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) error {
|
|
|
+ func(c *gateway.RequestBuilderContext) error {
|
|
|
if getByIDOptions.beforeBuilderCallback != nil {
|
|
|
- err := getByIDOptions.beforeBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := getByIDOptions.beforeBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -345,9 +344,9 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
return nil
|
|
|
}),
|
|
|
gateway.WithRequestResponseCallback(
|
|
|
- func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, response *http_client.Response) error {
|
|
|
+ func(c *gateway.RequestBuilderContext, response *http_client.Response) error {
|
|
|
if getByIDOptions.afterBuilderCallback != nil {
|
|
|
- err := getByIDOptions.afterBuilderCallback(c, historyRequests, resultMap)
|
|
|
+ err := getByIDOptions.afterBuilderCallback(c)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
@@ -360,8 +359,8 @@ func (simple *Simple) bind(builder *gateway.Builder) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-type RequestBuilderCallback func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any) error
|
|
|
-type RequestBuilderErrorCallback func(c *api.Context, historyRequests []gateway.Request, resultMap map[string]any, err error) error
|
|
|
+type RequestBuilderCallback func(c *gateway.RequestBuilderContext) error
|
|
|
+type RequestBuilderErrorCallback func(c *gateway.RequestBuilderContext, err error) error
|
|
|
|
|
|
type GlobalOption func(options *GlobalOptions)
|
|
|
type CreateOption func(options *CreateOptions)
|