Documentation ¶
Index ¶
- Variables
- type Supplement
- type SupplementRepository
- type SupplementService
- func (service *SupplementService) Create(ctx context.Context, supplement Supplement) error
- func (service *SupplementService) Delete(ctx context.Context, gtin string) error
- func (service *SupplementService) FindByGtin(ctx context.Context, gtin string) (*Supplement, error)
- func (service *SupplementService) ListAll(ctx context.Context) ([]Supplement, error)
- func (service *SupplementService) Update(ctx context.Context, gtin string, other UpdatableSupplement) error
- type UpdatableSupplement
Constants ¶
This section is empty.
Variables ¶
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"` }
Click to show internal directories.
Click to hide internal directories.