Documentation ¶
Index ¶
- Constants
- type Product
- type ProductInterface
- type ProductPersistanceInterface
- type ProductReader
- type ProductService
- func (s *ProductService) Create(name string, price float64) (ProductInterface, error)
- func (s *ProductService) Disable(product ProductInterface) (ProductInterface, error)
- func (s *ProductService) Enable(product ProductInterface) (ProductInterface, error)
- func (s *ProductService) Get(id string) (ProductInterface, error)
- type ProductServiceInterface
- type ProductWriter
Constants ¶
View Source
const ( DISABLED = "disabled" ENABLED = "enabled" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
type ProductInterface ¶
type ProductPersistanceInterface ¶
type ProductPersistanceInterface interface { ProductReader ProductWriter }
interface composition
type ProductReader ¶
type ProductReader interface {
Get(id string) (ProductInterface, error)
}
type ProductService ¶
type ProductService struct {
Persistence ProductPersistanceInterface
}
func NewProductService ¶
func NewProductService(persistence ProductPersistanceInterface) *ProductService
func (*ProductService) Create ¶
func (s *ProductService) Create(name string, price float64) (ProductInterface, error)
func (*ProductService) Disable ¶
func (s *ProductService) Disable(product ProductInterface) (ProductInterface, error)
func (*ProductService) Enable ¶
func (s *ProductService) Enable(product ProductInterface) (ProductInterface, error)
func (*ProductService) Get ¶
func (s *ProductService) Get(id string) (ProductInterface, error)
type ProductServiceInterface ¶
type ProductServiceInterface interface { Get(id string) (ProductInterface, error) Create(name string, price float64) (ProductInterface, error) Enable(product ProductInterface) (ProductInterface, error) Disable(product ProductInterface) (ProductInterface, error) }
type ProductWriter ¶
type ProductWriter interface {
Save(product ProductInterface) (ProductInterface, error)
}
Click to show internal directories.
Click to hide internal directories.