entity

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: GPL-3.0 Imports: 13 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[string]) binding.ServiceFunc[string]

func CreateTx

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

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 GetByID

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

func Query

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

func Update

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

func UpdateTx

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

Types

type Callbacks

type Callbacks[O any] struct {
	BeforeDBOperate func(e entity.Entity, i *infrastructure.Infrastructure, dbExecutor database.Executor) error
	AfterDBOperate  func(e entity.Entity, i *infrastructure.Infrastructure, dbExecutor database.Executor) error
	OnSuccessReturn func(e entity.Entity, i *infrastructure.Infrastructure, output O) (O, error)
	OnErrorReturn   func(e entity.Entity, 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[string]) 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 WithDisableQueryByID

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

func WithDisableUpdate

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

func WithGetByIDCallbacks

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

func WithGetByIDMiddlewares

func WithGetByIDMiddlewares[I any](middlewares []api.Handler) 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]

func WithUpdateCallbacks

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

func WithUpdateMiddlewares

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

func WithUpdateTx

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

type Options

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

type Simple

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

	// 数据库Schema
	Schema string

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

	// 删除使用的请求参数,注意是WithID类型
	DeleteQueryParams request.IDRequestParam

	// 更新使用的请求参数,注意是WithID类型
	UpdateJsonBody request.IDRequestParam

	// 查询使用的请求参数,注意是Query类型
	QueryQueryParams request.QueryRequestParams

	// 根据ID查询使用的请求参数,注意是WithID类型
	GetByIDQueryParams request.IDRequestParam
	// contains filtered or unexported fields
}

Simple 实体CRUD的Bind参数 I 为查询相关接口返回的Info类型

Jump to

Keyboard shortcuts

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