value_object_crud

package
v0.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindSimple

func BindSimple[I any](binder *binding.Binder, simple *Simple[I], opts ...Option[I])

func Create

func Create(tableName string, callbacks *Callbacks[any]) binding.ServiceFunc[any]

func CreateTx

func CreateTx(tableName string, callbacks *Callbacks[any]) binding.ServiceFunc[any]

func Delete

func Delete(tableName string, callbacks *Callbacks[any]) binding.ServiceFunc[any]

func DeleteTx

func DeleteTx(tableName string, callbacks *Callbacks[any]) binding.ServiceFunc[any]

func Query

func Query[O any](tableName string, callbacks *Callbacks[response.InfosData[O]], conditionFieldCallback ConditionFieldCallback) binding.ServiceFunc[response.InfosData[O]]

Types

type Callbacks

type Callbacks[O any] struct {
	BeforeDBOperate func(valueObject value_object.ValueObject, i *infrastructure.Infrastructure, dbExecutor database.Executor) error
	AfterDBOperate  func(valueObject value_object.ValueObject, i *infrastructure.Infrastructure, dbExecutor database.Executor) error
	OnSuccessReturn func(valueObject value_object.ValueObject, i *infrastructure.Infrastructure, output O) (O, error)
	OnErrorReturn   func(valueObject value_object.ValueObject, err error, i *infrastructure.Infrastructure, defaultErrOutput O) (O, error)
}

type ConditionFieldCallback

type ConditionFieldCallback func(conditions *sql.Conditions, fieldName string, columnName string, value any) (hasDeal bool)

type Option

type Option[I any] func(options *Options[I])

func WithCreateCallbacks

func WithCreateCallbacks[I any](callbacks *Callbacks[any]) Option[I]

func WithCreateMiddlewares

func WithCreateMiddlewares[I any](middlewares []api.Handler) Option[I]

func WithCreateTx

func WithCreateTx[I any]() Option[I]

func WithDeleteCallbacks

func WithDeleteCallbacks[I any](callbacks *Callbacks[any]) Option[I]

func WithDeleteMiddlewares

func WithDeleteMiddlewares[I any](middlewares []api.Handler) Option[I]

func WithDeleteTx

func WithDeleteTx[I any]() Option[I]

func WithDisableCreate

func WithDisableCreate[I any]() Option[I]

func WithDisableDelete

func WithDisableDelete[I any]() Option[I]

func WithDisableQuery

func WithDisableQuery[I any]() Option[I]

func WithQueryCallbacks

func WithQueryCallbacks[I any](callbacks *Callbacks[response.InfosData[I]]) Option[I]

func WithQueryConditionFieldCallback

func WithQueryConditionFieldCallback[I any](callback ConditionFieldCallback) Option[I]

func WithQueryMiddlewares

func WithQueryMiddlewares[I any](middlewares []api.Handler) Option[I]

type Options

type Options[I any] struct {
	// contains filtered or unexported fields
}

type Simple

type Simple[I any] struct {
	// 使用的领域实体,注意是ValueObject类型
	ValueObject value_object.ValueObject

	// 数据库schema
	Schema string

	// 创建使用的请求参数
	CreateJsonBody request.Params

	// 删除使用的请求参数
	DeleteJsonBody request.Params

	// 查询使用的请求参数,注意是Query类型
	QueryQueryParams request.QueryRequestParams
	// contains filtered or unexported fields
}

Simple 值对象CRD的Bind参数 I 为查询相关接口返回的Info类型

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL