Ver código fonte

去除不必要的参数

yjp 1 ano atrás
pai
commit
cb520d47f2

+ 1 - 6
binding/bind_item.go

@@ -123,12 +123,7 @@ func (item *BindItem[O]) bind(binder *Binder, middlewares ...api.Handler) {
 			// 执行业务函数
 			statusCode := http.StatusOK
 
-			i := binder.i
-			if item.Infrastructure != nil {
-				i = item.Infrastructure
-			}
-
-			outputModel, err := item.ServiceFunc(c, params, domainObjects, i)
+			outputModel, err := item.ServiceFunc(c, params, domainObjects, binder.i)
 			if err != nil {
 				statusCode = fserr.ParseCode(err).HttpCode
 			}

+ 0 - 8
binding/binder.go

@@ -16,11 +16,3 @@ func NewBinder(router api.Router, i *infrastructure.Infrastructure) *Binder {
 		i:      i,
 	}
 }
-
-func (b *Binder) Router() api.Router {
-	return b.router
-}
-
-func (b *Binder) Infrastructure() *infrastructure.Infrastructure {
-	return b.i
-}

+ 0 - 3
binding/simple_bind_item.go

@@ -58,9 +58,6 @@ type SimpleBindItem[O any] struct {
 	// 与FormObjectsFunc字段二选一使用,如果都指定,会按照FormObjectsFunc字段处理
 	Objects []domain.Object
 
-	// 基础设施实例,可以通过Application取到
-	Infrastructure *infrastructure.Infrastructure
-
 	// 应用服务泛型函数
 	ServiceFunc ServiceFunc[O]
 }

+ 4 - 5
convenient/domain/configuration/api.go

@@ -35,11 +35,10 @@ func BindConfiguration(binder *binding.Binder, opts ...Option) {
 	}, value_object.WithDisableQuery[any]())
 
 	binding.GetBind(binder, &binding.SimpleBindItem[map[string]any]{
-		Path:           "/configuration/values",
-		ResponseFunc:   response.SendMapResponse,
-		RequestParams:  &GetConfigurationValuesQueryParams{},
-		Objects:        []domain.Object{&Entity{}},
-		Infrastructure: binder.Infrastructure(),
+		Path:          "/configuration/values",
+		ResponseFunc:  response.SendMapResponse,
+		RequestParams: &GetConfigurationValuesQueryParams{},
+		Objects:       []domain.Object{&Entity{}},
 		ServiceFunc: func(c *api.Context, params request.Params, objects []domain.Object, i *infrastructure.Infrastructure) (map[string]any, error) {
 			dbExecutor := i.DBExecutor()