action

package
v2.0.0-beta10 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCriteriaBuilder = func(c wool.Ctx, excludeFields ...string) *repository.Criteria {
	criteria := db.BuildCriteria(c.Req().URL.RawQuery, excludeFields...)
	if criteria.Index == nil {
		criteria.SetIndex(0)
	}
	if criteria.Size == nil {
		criteria.SetSize(20)
	}

	return criteria
}

Functions

This section is empty.

Types

type CRUD

func NewCRUD

func NewCRUD[CreateDTO any, UpdateDTO any, Entity repository.Entity, ResponseDTO any](
	read repository.ReadRepository[Entity],
	write repository.WriteRepository[Entity],
	createDTO DTOFactory[CreateDTO],
	updateDTO DTOFactory[UpdateDTO],
	createMapper RequestMapper[CreateDTO, Entity],
	updateMapper RequestMapper[UpdateDTO, Entity],
	responseMapper ResponseMapper[Entity, ResponseDTO],
) CRUD

type CreateAction

type CreateAction[DTO any, Entity repository.Entity] struct {
	WriteRepository repository.WriteRepository[Entity]
	DTOFactory      DTOFactory[DTO]
	Mapper          RequestMapper[DTO, Entity]
}

func (*CreateAction[DTO, Entity]) Create

func (a *CreateAction[DTO, Entity]) Create(c wool.Ctx) error

type DTOFactory

type DTOFactory[DTO any] interface {
	NewDTO() DTO
}

func NewDTOFactory

func NewDTOFactory[DTO any]() DTOFactory[DTO]

type DTOFactoryFunc

type DTOFactoryFunc[DTO any] func() DTO

func (DTOFactoryFunc[DTO]) NewDTO

func (f DTOFactoryFunc[DTO]) NewDTO() DTO

type DeleteAction

type DeleteAction[Entity repository.Entity] struct {
	WriteRepository repository.WriteRepository[Entity]
}

func (*DeleteAction[Entity]) Delete

func (a *DeleteAction[Entity]) Delete(c wool.Ctx) error

type ListAction

type ListAction[Entity repository.Entity, DTO any] struct {
	ReadRepository  repository.ReadRepository[Entity]
	ResponseMapper  ResponseMapper[Entity, DTO]
	CriteriaBuilder func(c wool.Ctx) *repository.Criteria
}

func (*ListAction[Entity, DTO]) List

func (a *ListAction[Entity, DTO]) List(c wool.Ctx) error

type ListResponse

type ListResponse struct {
	Data  any   `json:"data"`
	Total int64 `json:"total"`
	Index int64 `json:"index"`
	Size  int64 `json:"size"`
}

type RequestMapper

type RequestMapper[DTO any, Entity repository.Entity] interface {
	ToEntity(id uuid.UUID, dto DTO) (Entity, error)
}

type RequestMapperFunc

type RequestMapperFunc[DTO any, Entity repository.Entity] func(id uuid.UUID, dto DTO) (Entity, error)

func (RequestMapperFunc[DTO, Entity]) ToEntity

func (m RequestMapperFunc[DTO, Entity]) ToEntity(id uuid.UUID, dto DTO) (Entity, error)

type ResponseMapper

type ResponseMapper[Entity repository.Entity, DTO any] interface {
	ToResponse(entity Entity) DTO
}

type ResponseMapperFunc

type ResponseMapperFunc[Entity repository.Entity, DTO any] func(entity Entity) DTO

func (ResponseMapperFunc[Entity, DTO]) ToResponse

func (m ResponseMapperFunc[Entity, DTO]) ToResponse(entity Entity) DTO

type TakeAction

type TakeAction[Entity repository.Entity, DTO any] struct {
	ReadRepository repository.ReadRepository[Entity]
	ResponseMapper ResponseMapper[Entity, DTO]
}

func (*TakeAction[Entity, DTO]) Take

func (a *TakeAction[Entity, DTO]) Take(c wool.Ctx) error

type UpdateAction

type UpdateAction[DTO any, Entity repository.Entity] struct {
	WriteRepository repository.WriteRepository[Entity]
	DTOFactory      DTOFactory[DTO]
	Mapper          RequestMapper[DTO, Entity]
}

func (*UpdateAction[DTO, Entity]) PartiallyUpdate

func (a *UpdateAction[DTO, Entity]) PartiallyUpdate(c wool.Ctx) error

Jump to

Keyboard shortcuts

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