domain

package
v0.0.0-...-1294fdc Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProductAddedEvent          = "stores.ProductAdded"
	ProductRebrandedEvent      = "stores.ProductRebranded"
	ProductPriceIncreasedEvent = "stores.ProductPriceIncreased"
	ProductPriceDecreasedEvent = "stores.ProductPriceDecreased"
	ProductRemovedEvent        = "stores.ProductRemoved"
)
View Source
const (
	StoreCreatedEvent               = "stores.StoreCreated"
	StoreParticipationEnabledEvent  = "stores.StoreParticipationEnabled"
	StoreParticipationDisabledEvent = "stores.StoreParticipationDisabled"
	StoreRebrandedEvent             = "stores.StoreRebranded"
)
View Source
const ProductAggregate = "stores.Product"
View Source
const StoreAggregate = "stores.Store"

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")
	ErrNotAPriceIncrease      = errors.Wrap(errors.ErrBadRequest, "the price change would be a decrease")
	ErrNotAPriceDecrease      = errors.Wrap(errors.ErrBadRequest, "the price change would be an increase")
)
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 CatalogProduct

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

type CatalogRepository

type CatalogRepository interface {
	AddProduct(ctx context.Context, productID, storeID, name, description, sku string, price float64) error
	Rebrand(ctx context.Context, productID, name, description string) error
	UpdatePrice(ctx context.Context, productID string, delta float64) error
	RemoveProduct(ctx context.Context, productID string) error
	Find(ctx context.Context, productID string) (*CatalogProduct, error)
	GetCatalog(ctx context.Context, storeID string) ([]*CatalogProduct, error)
}

type MallRepository

type MallRepository interface {
	AddStore(ctx context.Context, storeID, name, location string) error
	SetStoreParticipation(ctx context.Context, storeID string, participating bool) error
	RenameStore(ctx context.Context, storeID, name string) error
	Find(ctx context.Context, storeID string) (*MallStore, error)
	All(ctx context.Context) ([]*MallStore, error)
	AllParticipating(ctx context.Context) ([]*MallStore, error)
}

type MallStore

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

type Product

type Product struct {
	es.Aggregate
	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 NewProduct

func NewProduct(id string) *Product

func (*Product) ApplyEvent

func (p *Product) ApplyEvent(event ddd.Event) error

func (*Product) ApplySnapshot

func (p *Product) ApplySnapshot(snapshot es.Snapshot) error

func (*Product) DecreasePrice

func (p *Product) DecreasePrice(price float64) error

func (*Product) IncreasePrice

func (p *Product) IncreasePrice(price float64) error

func (Product) Key

func (Product) Key() string

Key implements registry.Registerable

func (*Product) Rebrand

func (p *Product) Rebrand(name, description string) error

func (*Product) Remove

func (p *Product) Remove() error

func (Product) ToSnapshot

func (p Product) ToSnapshot() es.Snapshot

type ProductAdded

type ProductAdded struct {
	StoreID     string
	Name        string
	Description string
	SKU         string
	Price       float64
}

func (ProductAdded) Key

func (ProductAdded) Key() string

Key implements registry.Registerable

type ProductPriceChanged

type ProductPriceChanged struct {
	Delta float64
}

type ProductRebranded

type ProductRebranded struct {
	Name        string
	Description string
}

func (ProductRebranded) Key

func (ProductRebranded) Key() string

Key implements registry.Registerable

type ProductRemoved

type ProductRemoved struct{}

func (ProductRemoved) Key

func (ProductRemoved) Key() string

Key implements registry.Registerable

type ProductRepository

type ProductRepository interface {
	Load(ctx context.Context, id string) (*Product, error)
	Save(ctx context.Context, product *Product) error
}

type ProductV1

type ProductV1 struct {
	StoreID     string
	Name        string
	Description string
	SKU         string
	Price       float64
}

func (ProductV1) SnapshotName

func (ProductV1) SnapshotName() string

type Store

type Store struct {
	es.Aggregate
	Name          string
	Location      string
	Participating bool
}

func CreateStore

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

func NewStore

func NewStore(id string) *Store

func (*Store) ApplyEvent

func (s *Store) ApplyEvent(event ddd.Event) error

ApplyEvent implements es.EventApplier

func (*Store) ApplySnapshot

func (s *Store) ApplySnapshot(snapshot es.Snapshot) error

ApplySnapshot implements es.Snapshotter

func (*Store) DisableParticipation

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

func (*Store) EnableParticipation

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

func (Store) Key

func (Store) Key() string

Key implements registry.Registerable

func (*Store) Rebrand

func (s *Store) Rebrand(name string) error

func (Store) ToSnapshot

func (s Store) ToSnapshot() es.Snapshot

ToSnapshot implements es.Snapshotter

type StoreCreated

type StoreCreated struct {
	Name     string
	Location string
}

func (StoreCreated) Key

func (StoreCreated) Key() string

Key implements registry.Registerable

type StoreParticipationToggled

type StoreParticipationToggled struct {
	Participating bool
}

type StoreRebranded

type StoreRebranded struct {
	Name string
}

func (StoreRebranded) Key

func (StoreRebranded) Key() string

Key implements registry.Registerable

type StoreRepository

type StoreRepository interface {
	Load(ctx context.Context, storeID string) (*Store, error)
	Save(ctx context.Context, store *Store) error
}

type StoreV1

type StoreV1 struct {
	Name          string
	Location      string
	Participating bool
}

func (StoreV1) SnapshotName

func (StoreV1) SnapshotName() string

Jump to

Keyboard shortcuts

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