supplement

package
v0.0.0-...-51c216c Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound          = errors.New("supplement not found")
	ErrAlreadyExists     = errors.New("supplement already exists")
	ErrInvalidSupplement = errors.New("invalid supplement")
)

Functions

This section is empty.

Types

type Supplement

type Supplement struct {
	Gtin          string  `json:"gtin"`
	Name          string  `json:"name"`
	Brand         string  `json:"brand"`
	Flavor        string  `json:"flavor"`
	Carbohydrates float32 `json:"carbohydrates"`
	Electrolytes  float32 `json:"electrolytes"`
	Maltodextrose float32 `json:"maltodextrose"`
	Fructose      float32 `json:"fructose"`
	Caffeine      float32 `json:"caffeine"`
	Sodium        float32 `json:"sodium"`
	Protein       float32 `json:"protein"`
}

type SupplementRepository

type SupplementRepository interface {
	FindByGtin(ctx context.Context, gtin string) (*Supplement, error)
	Create(ctx context.Context, supplement Supplement) error
	Update(ctx context.Context, supplement Supplement) error
	Delete(ctx context.Context, supplement Supplement) error
	ListAll(ctx context.Context) ([]Supplement, error)
}

type SupplementService

type SupplementService struct {
	// contains filtered or unexported fields
}

func NewSupplementService

func NewSupplementService(repository SupplementRepository) *SupplementService

func (*SupplementService) Create

func (service *SupplementService) Create(ctx context.Context, supplement Supplement) error

func (*SupplementService) Delete

func (service *SupplementService) Delete(ctx context.Context, gtin string) error

func (*SupplementService) FindByGtin

func (service *SupplementService) FindByGtin(ctx context.Context, gtin string) (*Supplement, error)

func (*SupplementService) ListAll

func (service *SupplementService) ListAll(ctx context.Context) ([]Supplement, error)

TODO: Add pagination, sorting, and filtering

func (*SupplementService) Update

func (service *SupplementService) Update(ctx context.Context, gtin string, other UpdatableSupplement) error

type UpdatableSupplement

type UpdatableSupplement struct {
	Name          *string  `json:"name,omitempty"`
	Brand         *string  `json:"brand,omitempty"`
	Flavor        *string  `json:"flavor,omitempty"`
	Carbohydrates *float32 `json:"carbohydrates,omitempty"`
	Electrolytes  *float32 `json:"electrolytes,omitempty"`
	Maltodextrose *float32 `json:"maltodextrose,omitempty"`
	Fructose      *float32 `json:"fructose,omitempty"`
	Caffeine      *float32 `json:"caffeine,omitempty"`
	Sodium        *float32 `json:"sodium,omitempty"`
	Protein       *float32 `json:"protein,omitempty"`
}

Directories

Path Synopsis
persistence

Jump to

Keyboard shortcuts

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