application

package
v0.0.0-...-2e8993e Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DISABLED = "disabled"
	ENABLED  = "enabled"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IProduct

type IProduct interface {
	IsValid() (bool, error)
	Enable() error
	Disable() error
	GetID() string
	GetName() string
	GetStatus() string
	GetPrice() float64
}

type IProductPersistence

type IProductPersistence interface {
	IProductReader
	IProductWriter
}

type IProductReader

type IProductReader interface {
	Get(id string) (IProduct, error)
}

type IProductService

type IProductService interface {
	Get(id string) (IProduct, error)
	Create(name string, price float64) (IProduct, error)
	Enable(product IProduct) (IProduct, error)
	Disable(product IProduct) (IProduct, error)
}

type IProductWriter

type IProductWriter interface {
	Save(product IProduct) (IProduct, error)
}

type Product

type Product struct {
	ID     string  `valid:"uuidv4"`
	Name   string  `valid:"required"`
	Price  float64 `valid:"float,optional"`
	Status string  `valid:"required"`
}

func NewProduct

func NewProduct() *Product

func (*Product) Disable

func (p *Product) Disable() error

func (*Product) Enable

func (p *Product) Enable() error

func (*Product) GetID

func (p *Product) GetID() string

func (*Product) GetName

func (p *Product) GetName() string

func (*Product) GetPrice

func (p *Product) GetPrice() float64

func (*Product) GetStatus

func (p *Product) GetStatus() string

func (*Product) IsValid

func (p *Product) IsValid() (bool, error)

type ProductService

type ProductService struct {
	Persistence IProductPersistence
}

func NewProductService

func NewProductService(persistence IProductPersistence) *ProductService

func (*ProductService) Create

func (s *ProductService) Create(name string, price float64) (IProduct, error)

func (*ProductService) Disable

func (s *ProductService) Disable(product IProduct) (IProduct, error)

func (*ProductService) Enable

func (s *ProductService) Enable(product IProduct) (IProduct, error)

func (*ProductService) Get

func (s *ProductService) Get(id string) (IProduct, error)

Directories

Path Synopsis
Package mock_application is a generated GoMock package.
Package mock_application is a generated GoMock package.

Jump to

Keyboard shortcuts

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