products

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 5 Imported by: 0

README

products

Contains domain related entities and business logic implementations. The business functionality should be exported using Service interface that contains necessary functions to work with the entity.

Every domain/client should have it's own testing package (productstest) that can be used to mock the functionality of this package, usualy generated using external tools like mockery.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProductNameBlank = errors.New("Name can't be blank")

ErrProductNameBlank validation error.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	Keyword string
}

Filter for search.

type Product

type Product struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Store     string    `json:"store"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Product respresent a record stored in products table.

func (Product) Validate

func (t Product) Validate() error

Validate product.

type Service

type Service interface {
	Search(ctx context.Context, products *[]Product, filter Filter) error
	Create(ctx context.Context, product *Product) error
	Update(ctx context.Context, product *Product, changes rel.Changeset) error
	Delete(ctx context.Context, product *Product)
}

Service instance for product's domain. Any operation done to any of object within this domain should use this service.

func New

func New(repository rel.Repository) Service

New Products service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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