commands

package
v0.0.0-...-f0852b9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("object is not found")
	ErrAlreadyExists = errors.New("object already exists")
	ErrInvalidData   = errors.New("invalid data provided")

	ErrDishNotFound      = fmt.Errorf("dish %w", ErrNotFound)
	ErrDishAlreadyExists = fmt.Errorf("dish %w", ErrAlreadyExists)

	ErrMenuNotFound      = fmt.Errorf("menu %w", ErrNotFound)
	ErrMenuAlreadyExists = fmt.Errorf("menu %w", ErrAlreadyExists)

	ErrRestaurantNotFound      = fmt.Errorf("restaurant %w", ErrNotFound)
	ErrRestaurantAlreadyExists = fmt.Errorf("restaurant %w", ErrAlreadyExists)

	ErrInternal = errors.New("internal service error")
)

Functions

This section is empty.

Types

type AddDishArgument

type AddDishArgument struct {
	Restaurant uuid.UUID
	Menu       uuid.UUID
	Name       string
	Image      *url.URL
	Price      float64
}

type AddDishCommand

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

AddDishCommand - a command that handles the addition of a new dish to the menu

func NewAddDishCommand

func NewAddDishCommand(
	dishes DishStoragePort,
	menus MenuStoragePort,
	restaurant RestaurantStoragePort,
	logger *slog.Logger,
) *AddDishCommand

func (*AddDishCommand) AddDish

func (cmd *AddDishCommand) AddDish(ctx context.Context, args AddDishArgument) (uuid.UUID, error)

type AddMenuArgument

type AddMenuArgument struct {
	Name       string
	Restaurant uuid.UUID
	Image      *url.URL
}

type AddMenuCommand

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

func NewAddMenuCommand

func NewAddMenuCommand(
	restaurants RestaurantStoragePort,
	menus MenuStoragePort,
	logger *slog.Logger,
) *AddMenuCommand

func (*AddMenuCommand) AddMenu

func (cmd *AddMenuCommand) AddMenu(ctx context.Context, args AddMenuArgument) (uuid.UUID, error)

type AddRestaurantCommand

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

func NewAddRestaurantCommand

func NewAddRestaurantCommand(
	restaurants RestaurantStoragePort,
	logger *slog.Logger,
) *AddRestaurantCommand

func (*AddRestaurantCommand) AddRestaurant

func (cmd *AddRestaurantCommand) AddRestaurant(ctx context.Context, id uuid.UUID) (uuid.UUID, error)

type DeleteDishCommand

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

func NewDeleteDishCommand

func NewDeleteDishCommand(
	dishes DishStoragePort,
	restaurants RestaurantStoragePort,
	menus MenuStoragePort,
	logger *slog.Logger,
) *DeleteDishCommand

func (*DeleteDishCommand) DeleteDish

func (cmd *DeleteDishCommand) DeleteDish(ctx context.Context, restaurant uuid.UUID, dish uuid.UUID) error

type DeleteMenuCommand

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

func NewDeleteMenuCommand

func NewDeleteMenuCommand(
	restaurants RestaurantStoragePort,
	menus MenuStoragePort,
	logger *slog.Logger,
) *DeleteMenuCommand

func (*DeleteMenuCommand) DeleteMenu

func (cmd *DeleteMenuCommand) DeleteMenu(ctx context.Context, restaurant uuid.UUID, menuId uuid.UUID) error

type DishStoragePort

type DishStoragePort interface {
	GetDish(ctx context.Context, id uuid.UUID) (*domain.Dish, error)
	AddDish(ctx context.Context, dish *domain.Dish) error
	DeleteDish(ctx context.Context, id uuid.UUID) error
	UpdateDish(ctx context.Context, dish *domain.Dish) error
}

DishStoragePort - is a port to dish storage

type MenuStoragePort interface {
	GetMenuByRestaurant(ctx context.Context, restaurant uuid.UUID) ([]*domain.Menu, error)
	GetMenu(ctx context.Context, id uuid.UUID) (*domain.Menu, error)
	AddMenu(ctx context.Context, menu *domain.Menu) error
	DeleteMenu(ctx context.Context, id uuid.UUID) error
	UpdateMenu(ctx context.Context, menu *domain.Menu) error
}

MenuStoragePort - is a port to menu storage

type RestaurantStoragePort

type RestaurantStoragePort interface {
	RestaurantExists(ctx context.Context, id uuid.UUID) (bool, error)
	AddRestaurant(ctx context.Context, id uuid.UUID) error
}

RestaurantStoragePort - is a port to restaurant storage

type UpdateDishArgument

type UpdateDishArgument struct {
	Id         uuid.UUID
	Restaurant uuid.UUID
	Name       string
	Image      *url.URL
	Price      float64
}

type UpdateDishCommand

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

func NewUpdateDishCommand

func NewUpdateDishCommand(
	restaurants RestaurantStoragePort,
	menu MenuStoragePort,
	dishes DishStoragePort,
	logger *slog.Logger,
) *UpdateDishCommand

func (*UpdateDishCommand) UpdateDish

func (cmd *UpdateDishCommand) UpdateDish(ctx context.Context, arg UpdateDishArgument) error

type UpdateMenuArgument

type UpdateMenuArgument struct {
	ID         uuid.UUID
	Restaurant uuid.UUID
	Name       string
	Image      *url.URL
}

type UpdateMenuCommand

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

func NewUpdateMenuCommand

func NewUpdateMenuCommand(
	restaurant RestaurantStoragePort,
	menu MenuStoragePort,
	logger *slog.Logger,
) *UpdateMenuCommand

func (*UpdateMenuCommand) UpdateMenu

func (cmd *UpdateMenuCommand) UpdateMenu(ctx context.Context, arg UpdateMenuArgument) error

Jump to

Keyboard shortcuts

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