package configuration import ( "git.sxidc.com/go-framework/baize/binding" "git.sxidc.com/go-framework/baize/binding/response" "git.sxidc.com/go-framework/baize/convenient/value_object" "git.sxidc.com/go-framework/baize/domain" "git.sxidc.com/go-tools/utils/strutils" ) func BindConfiguration(binder *binding.Binder, opts ...Option) { options := new(Options) for _, opt := range opts { opt(options) } configurationTableName := tableName if strutils.IsStringNotEmpty(options.schema) { configurationTableName = tableName + "." + options.schema } dbExecutorType := binding.DBExecutorOperations if strutils.IsStringNotEmpty(options.dbExecutorType) { dbExecutorType = options.dbExecutorType } value_object.BindSimple(binder, &value_object.Simple[any]{ ValueObject: &Entity{}, TableName: configurationTableName, DBExecutorType: dbExecutorType, DomainPath: "/configuration", CreateJsonBody: &AddConfigurationJsonBody{}, DeleteQueryParams: &RemoveConfigurationQueryParams{}, }, value_object.WithDisableQuery[any]()) binding.GetBind(binder, &binding.SimpleBindItem[map[string]any]{ Path: "/configuration/values", RequestParams: &GetConfigurationValuesQueryParams{}, Objects: []domain.Object{&Entity{}}, Infrastructure: binder.ChooseDBExecutor(dbExecutorType), ServiceFunc: nil, ResponseFunc: response.SendMapResponse, }) } type Option func(options *Options) type Options struct { schema string dbExecutorType string } func WithSchema(schema string) Option { return func(options *Options) { options.schema = schema } } func WithDBExecutorType(dbExecutorType string) Option { return func(options *Options) { options.dbExecutorType = dbExecutorType } }