usecase

package
v0.0.0-...-4b66723 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrapper

func Wrapper[TEntity any, TRequest any, TResult any](ctx *Context[TRequest], callback Callback[TEntity, TRequest, TResult]) (*TResult, int64, error)

Types

type Callback

type Callback[TEntity any, TRequest any, TResult any] func(ctx *Context[TRequest]) (*TResult, int64, error)

type Context

type Context[T any] struct {
	Ctx     context.Context
	Log     *zap.Logger
	DB      *gorm.DB
	Request T
}

func NewContext

func NewContext[T any](ctx context.Context, log *zap.Logger, db *gorm.DB, request T) *Context[T]

type Crud

type Crud[T any] struct {
	Log        *zap.Logger
	DB         *gorm.DB
	Repository repository.CruderRepository[T]
}

func NewCrud

func NewCrud[T any](log *zap.Logger, db *gorm.DB, repository repository.CruderRepository[T]) *Crud[T]

func (*Crud[T]) GetById

func (uc *Crud[T]) GetById(ctx context.Context, request model.GetByIDRequest[int]) (*[]T, int64, error)

func (*Crud[T]) GetFirstById

func (uc *Crud[T]) GetFirstById(ctx context.Context, request model.GetByIDRequest[int]) (*T, int64, error)

func (*Crud[T]) List

func (uc *Crud[T]) List(ctx context.Context, request model.ListRequest) (*[]T, int64, error)

type CruderUseCase

type CruderUseCase[T any] interface {
	List(ctx context.Context, request model.ListRequest) (*[]T, int64, error)
	GetById(ctx context.Context, request model.GetByIDRequest[int]) (*[]T, int64, error)
	GetFirstById(ctx context.Context, request model.GetByIDRequest[int]) (*T, int64, error)
}

Jump to

Keyboard shortcuts

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