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: 3 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 {
	ddd.AggregateBase
	StoreID     string
	Name        string
	Description string
	SKU         string
	Price       float64
}

func CreateProduct

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

func (*Product) Remove

func (p *Product) Remove() error

type ProductAdded

type ProductAdded struct {
	Product *Product
}

func (ProductAdded) EventName

func (ProductAdded) EventName() string

type ProductRemoved

type ProductRemoved struct {
	Product *Product
}

func (ProductRemoved) EventName

func (ProductRemoved) EventName() string

type ProductRepository

type ProductRepository interface {
	Find(ctx context.Context, id string) (*Product, error)
	Save(ctx context.Context, product *Product) error
	Delete(ctx context.Context, id string) error
	GetCatalog(ctx context.Context, storeID string) ([]*Product, error)
}

type Store

type Store struct {
	ddd.AggregateBase
	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 StoreCreated

type StoreCreated struct {
	Store *Store
}

func (StoreCreated) EventName

func (StoreCreated) EventName() string

type StoreParticipationDisabled

type StoreParticipationDisabled struct {
	Store *Store
}

func (StoreParticipationDisabled) EventName

func (StoreParticipationDisabled) EventName() string

type StoreParticipationEnabled

type StoreParticipationEnabled struct {
	Store *Store
}

func (StoreParticipationEnabled) EventName

func (StoreParticipationEnabled) EventName() string

type StoreRepository

type StoreRepository interface {
	Save(ctx context.Context, store *Store) error
	Find(ctx context.Context, storeID string) (*Store, error)
	Update(ctx context.Context, store *Store) error
	Delete(ctx context.Context, storeID string) 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