domain

package
v0.0.0-...-3a9fddd Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProductNameIsBlank     = errors.Wrap(errors.ErrBadRequest, "the product name cannot be blank")
	ErrProductPriceIsNegative = errors.Wrap(errors.ErrBadRequest, "the product price cannot be negative")
)
View Source
var (
	ErrStoreNameIsBlank               = errors.Wrap(errors.ErrBadRequest, "the store name cannot be blank")
	ErrStoreLocationIsBlank           = errors.Wrap(errors.ErrBadRequest, "the store location cannot be blank")
	ErrStoreIsAlreadyParticipating    = errors.Wrap(errors.ErrBadRequest, "the store is already participating")
	ErrStoreIsAlreadyNotParticipating = errors.Wrap(errors.ErrBadRequest, "the store is already not participating")
)

Functions

This section is empty.

Types

type ParticipatingStoreRepository

type ParticipatingStoreRepository interface {
	FindAll(ctx context.Context) ([]*Store, error)
}

type Product

type Product struct {
	ID          string
	StoreID     string
	Name        string
	Description string
	SKU         string
	Price       float64
}

func CreateProduct

func CreateProduct(id, storeID, name, description, sku string, price float64) (*Product, error)

type ProductRepository

type ProductRepository interface {
	FindProduct(ctx context.Context, id string) (*Product, error)
	AddProduct(ctx context.Context, product *Product) error
	RemoveProduct(ctx context.Context, id string) error
	GetCatalog(ctx context.Context, storeID string) ([]*Product, error)
}

type Store

type Store struct {
	ID            string
	Name          string
	Location      string
	Participating bool
}

func CreateStore

func CreateStore(id, name, location string) (store *Store, err error)

func (*Store) DisableParticipation

func (s *Store) DisableParticipation() (err error)

func (*Store) EnableParticipation

func (s *Store) EnableParticipation() (err error)

type StoreRepository

type StoreRepository interface {
	Save(ctx context.Context, store *Store) error
	Update(ctx context.Context, store *Store) error
	Delete(ctx context.Context, storeID string) error
	Find(ctx context.Context, storeID string) (*Store, error)
	FindAll(ctx context.Context) ([]*Store, error)
}

Jump to

Keyboard shortcuts

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