product

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VariantCreationErrKey              = "error.variant.creation"
	CreationErrKey                     = "error.product.creation"
	ErrProductIDCantBeEmpty            = errors.NewIllegalInputError("err.product.id.shouldNotEmpty", "product id should not empty")
	ErrProductCategoryRefCantBeEmpty   = errors.NewIllegalInputError("err.product.categoryRef.shouldNotEmpty", "product categoryRef should not empty")
	ErrProductNameCantBeEmpty          = errors.NewIllegalInputError("err.product.name.shouldNotEmpty", "product name should not empty")
	ErrProductAtLeastHaveOneVariant    = errors.NewIllegalInputError("err.product.variants.shouldHasOneOrMoreVariant", "product variant should have at least 1 variant")
	ErrVariantIDCantBeEmpty            = errors.NewIllegalInputError("err.variant.id.shouldNotEmpty", "variant id should not empty")
	ErrVariantPriceMustGreaterThanZero = errors.NewIllegalInputError("err.variant.price.shouldMoreThanZero", "variant price should greater than 0")
	ErrVariantNameCantBeEmpty          = errors.NewIllegalInputError("err.variant.name.shouldNotEmpty", "variant name should not empty")
)

Functions

func IllegalProductCreationInputErr

func IllegalProductCreationInputErr(err error) error

func IllegalVariantCreationInputErr

func IllegalVariantCreationInputErr(err error) error

Types

type Product

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

func NewProduct

func NewProduct(id string, categoryRef string, name string, variants []*Variant) (item *Product, err error)

func (*Product) AddManyVariant

func (i *Product) AddManyVariant(variants []*Variant)

func (*Product) AddVariant

func (i *Product) AddVariant(variant *Variant)

func (Product) CategoryRef

func (i Product) CategoryRef() string

func (Product) ID

func (i Product) ID() string

func (Product) Name

func (i Product) Name() string

func (Product) Variants

func (i Product) Variants() []*Variant

type Repository

type Repository interface {
	Create(ctx context.Context, entity *Product) error
	Update(ctx context.Context, id string, entity *Product) error
	Load(ctx context.Context, id string) (entity *Product, err error)
}

type Variant

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

func NewVariant

func NewVariant(id string, code string, name string, price float64) (variant *Variant, err error)

func (Variant) Code

func (v Variant) Code() string

func (Variant) ID

func (v Variant) ID() string

func (Variant) Name

func (v Variant) Name() string

func (Variant) Price

func (v Variant) Price() float64

Jump to

Keyboard shortcuts

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