generic

package
v0.6.75 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromParam added in v0.5.10

func FromParam[T any](ctx *fiber.Ctx, param string) (*T, error)

func FromQuery added in v0.5.10

func FromQuery[T any](ctx *fiber.Ctx, param string) (*T, error)

func SetEndpoints

func SetEndpoints[T any](group string, router fiber.Router, database *gorm.DB, logger *zap.SugaredLogger) (IStore[T], IService[T], IHandler[T])

Types

type Handler

type Handler[T any] struct {
	Service IService[T]
	Logger  *zap.SugaredLogger
}

func (*Handler[T]) Create

func (s *Handler[T]) Create(c *fiber.Ctx) error

func (*Handler[T]) Delete

func (s *Handler[T]) Delete(c *fiber.Ctx) error

func (*Handler[T]) Get

func (s *Handler[T]) Get(c *fiber.Ctx) error

func (*Handler[T]) List

func (s *Handler[T]) List(c *fiber.Ctx) error

type IHandler

type IHandler[T any] interface {
	Get(c *fiber.Ctx) error
	Create(c *fiber.Ctx) error
	Delete(c *fiber.Ctx) error
	List(c *fiber.Ctx) error
}

func NewHandler

func NewHandler[T any](service IService[T], logger *zap.SugaredLogger) IHandler[T]

type IService

type IService[T any] interface {
	Get(id any) (*T, error)
	Create(obj *T) error
	Delete(id any) error
	List(start, limit int) ([]T, error)
}

func NewService

func NewService[T any](store IStore[T], logger *zap.SugaredLogger) IService[T]

type IStore

type IStore[T any] interface {
	Get(id any) (*T, error)
	Create(obj *T) error
	Delete(id any) error
	List(start, limit int) ([]T, error)
}

func NewStore

func NewStore[T any](db *gorm.DB) IStore[T]

type Service

type Service[T any] struct {
	Store  IStore[T]
	Logger *zap.SugaredLogger
}

func (*Service[T]) Create

func (s *Service[T]) Create(obj *T) error

func (*Service[T]) Delete

func (s *Service[T]) Delete(id any) error

func (*Service[T]) Get

func (s *Service[T]) Get(id any) (*T, error)

func (*Service[T]) List

func (s *Service[T]) List(start, limit int) ([]T, error)

type Store

type Store[T any] struct {
	// contains filtered or unexported fields
}

func (*Store[T]) Create

func (s *Store[T]) Create(obj *T) error

func (*Store[T]) Delete

func (s *Store[T]) Delete(id any) error

func (*Store[T]) Get

func (s *Store[T]) Get(id any) (*T, error)

func (*Store[T]) List

func (s *Store[T]) List(start, limit int) ([]T, error)

Jump to

Keyboard shortcuts

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