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

View Source
const (
	ShoppingListCreatedEvent   = "depot.ShoppingListCreated"
	ShoppingListCanceledEvent  = "depot.ShoppingListCanceled"
	ShoppingListAssignedEvent  = "depot.ShoppingListAssigned"
	ShoppingListCompletedEvent = "depot.ShoppingListCompleted"
)
View Source
const ShoppingListAggregate = "depot.ShoppingList"

Variables

View Source
var (
	ErrShoppingCannotBeCanceled  = errors.Wrap(errors.ErrBadRequest, "the shopping list cannot be canceled")
	ErrShoppingCannotBeAssigned  = errors.Wrap(errors.ErrBadRequest, "the shopping list cannot be assigned")
	ErrShoppingCannotBeCompleted = errors.Wrap(errors.ErrBadRequest, "the shopping list cannot be completed")
)

Functions

This section is empty.

Types

type Bot

type Bot struct {
	ID     string
	Name   string
	Status BotStatus
}

type BotStatus

type BotStatus string
const (
	BotUnknown  BotStatus = ""
	BotIsIdle   BotStatus = "idle"
	BotIsActive BotStatus = "active"
)

func ToBotStatus

func ToBotStatus(status string) BotStatus

func (BotStatus) String

func (s BotStatus) String() string

type Item

type Item struct {
	ProductName string
	Quantity    int
}

type Items

type Items map[string]*Item

type OrderRepository

type OrderRepository interface {
	Ready(ctx context.Context, orderID string) error
}

type Product

type Product struct {
	ID      string
	StoreID string
	Name    string
}

type ProductRepository

type ProductRepository interface {
	Find(ctx context.Context, productID string) (*Product, error)
}

type ShoppingList

type ShoppingList struct {
	ddd.Aggregate
	OrderID       string
	Stops         Stops
	AssignedBotID string
	Status        ShoppingListStatus
}

func CreateShopping

func CreateShopping(id, orderID string) *ShoppingList

func NewShoppingList

func NewShoppingList(id string) *ShoppingList

func (*ShoppingList) AddItem

func (sl *ShoppingList) AddItem(store *Store, product *Product, quantity int) error

func (*ShoppingList) Assign

func (sl *ShoppingList) Assign(id string) error

func (*ShoppingList) Cancel

func (sl *ShoppingList) Cancel() error

func (*ShoppingList) Complete

func (sl *ShoppingList) Complete() error

func (ShoppingList) Key

func (ShoppingList) Key() string

type ShoppingListAssigned

type ShoppingListAssigned struct {
	ShoppingList *ShoppingList
	BotID        string
}

func (ShoppingListAssigned) Key

type ShoppingListCanceled

type ShoppingListCanceled struct {
	ShoppingList *ShoppingList
}

func (ShoppingListCanceled) Key

type ShoppingListCompleted

type ShoppingListCompleted struct {
	ShoppingList *ShoppingList
}

func (ShoppingListCompleted) Key

type ShoppingListCreated

type ShoppingListCreated struct {
	ShoppingList *ShoppingList
}

func (ShoppingListCreated) Key

type ShoppingListRepository

type ShoppingListRepository interface {
	Find(ctx context.Context, shoppingListID string) (*ShoppingList, error)
	Save(ctx context.Context, list *ShoppingList) error
	Update(ctx context.Context, list *ShoppingList) error
}

type ShoppingListStatus

type ShoppingListStatus string
const (
	ShoppingListUnknown     ShoppingListStatus = ""
	ShoppingListIsAvailable ShoppingListStatus = "available"
	ShoppingListIsAssigned  ShoppingListStatus = "assigned"
	ShoppingListIsActive    ShoppingListStatus = "active"
	ShoppingListIsCompleted ShoppingListStatus = "completed"
	ShoppingListIsCanceled  ShoppingListStatus = "canceled"
)

func ToShoppingListStatus

func ToShoppingListStatus(status string) ShoppingListStatus

func (ShoppingListStatus) String

func (s ShoppingListStatus) String() string

type Stop

type Stop struct {
	StoreName     string
	StoreLocation string
	Items         Items
}

func (*Stop) AddItem

func (s *Stop) AddItem(product *Product, quantity int) error

type Stops

type Stops map[string]*Stop

type Store

type Store struct {
	ID       string
	Name     string
	Location string
}

type StoreRepository

type StoreRepository interface {
	Find(ctx context.Context, id string) (*Store, error)
}

Jump to

Keyboard shortcuts

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