crud

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultApiView = "api"

Variables

View Source
var ErrModelNotChanged = fmt.Errorf("nothing has changed on model")

Functions

func AddCreateHandler

func AddCreateHandler(logger log.Logger, d *httpserver.Definitions, version int, basePath string, handler CreateHandler)

func AddCrudHandlers

func AddCrudHandlers(logger log.Logger, d *httpserver.Definitions, version int, basePath string, handler Handler)

func AddDeleteHandler

func AddDeleteHandler(logger log.Logger, d *httpserver.Definitions, version int, basePath string, handler BaseHandler)

func AddListHandler

func AddListHandler(logger log.Logger, d *httpserver.Definitions, version int, basePath string, handler ListHandler)

func AddReadHandler

func AddReadHandler(logger log.Logger, d *httpserver.Definitions, version int, basePath string, handler BaseHandler)

func AddUpdateHandler

func AddUpdateHandler(logger log.Logger, d *httpserver.Definitions, version int, basePath string, handler UpdateHandler)

func GetApiViewFromHeader

func GetApiViewFromHeader(reqHeaders http.Header) string

func NewCreateHandler

func NewCreateHandler(logger log.Logger, transformer CreateHandler) gin.HandlerFunc

func NewDeleteHandler

func NewDeleteHandler(logger log.Logger, transformer BaseHandler) gin.HandlerFunc

func NewListHandler

func NewListHandler(logger log.Logger, transformer ListHandler) gin.HandlerFunc

func NewReadHandler

func NewReadHandler(logger log.Logger, transformer BaseHandler) gin.HandlerFunc

func NewUpdateHandler

func NewUpdateHandler(logger log.Logger, transformer UpdateHandler) gin.HandlerFunc

Types

type BaseCreateHandler

type BaseCreateHandler interface {
	GetCreateInput() interface{}
	TransformCreate(ctx context.Context, input interface{}, model db_repo.ModelBased) (err error)
}

type BaseHandler

type BaseHandler interface {
	GetRepository() Repository
	GetModel() db_repo.ModelBased
	TransformOutput(ctx context.Context, model db_repo.ModelBased, apiView string) (output interface{}, err error)
}

type BaseListHandler

type BaseListHandler interface {
	List(ctx context.Context, qb *db_repo.QueryBuilder, apiView string) (out interface{}, err error)
}

type BaseUpdateHandler

type BaseUpdateHandler interface {
	GetUpdateInput() interface{}
	TransformUpdate(ctx context.Context, input interface{}, model db_repo.ModelBased) (err error)
}

type CreateHandler

type CreateHandler interface {
	BaseHandler
	BaseCreateHandler
}

type ListHandler

type ListHandler interface {
	BaseHandler
	BaseListHandler
}

type Output

type Output struct {
	Total   int         `json:"total"`
	Results interface{} `json:"results"`
}

type Repository

type Repository interface {
	Create(ctx context.Context, value db_repo.ModelBased) error
	Read(ctx context.Context, id *uint, out db_repo.ModelBased) error
	Update(ctx context.Context, value db_repo.ModelBased) error
	Delete(ctx context.Context, value db_repo.ModelBased) error
	Query(ctx context.Context, qb *db_repo.QueryBuilder, result interface{}) error
	Count(ctx context.Context, qb *db_repo.QueryBuilder, model db_repo.ModelBased) (int, error)
	GetMetadata() db_repo.Metadata
}

type UpdateHandler

type UpdateHandler interface {
	BaseHandler
	BaseUpdateHandler
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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