50 lines
768 B
Go
50 lines
768 B
Go
package model
|
|
|
|
type Product struct {
|
|
ID int
|
|
Name string
|
|
Category string
|
|
Price float64
|
|
Quantity int
|
|
}
|
|
|
|
type ProductInput struct {
|
|
Name string
|
|
Category string
|
|
Price float64
|
|
Quantity int
|
|
}
|
|
|
|
type Inventory struct {
|
|
products []Product
|
|
nextID int
|
|
}
|
|
|
|
func NewInventory() *Inventory {
|
|
return &Inventory{}
|
|
}
|
|
|
|
func (e *Inventory) AdicionarProduto(i *ProductInput) *Product {
|
|
e.nextID += 1
|
|
|
|
product := Product{
|
|
ID: e.nextID,
|
|
Name: i.Name,
|
|
Category: i.Category,
|
|
Price: i.Price,
|
|
Quantity: i.Quantity,
|
|
}
|
|
|
|
e.products = append(e.products, product)
|
|
|
|
return &product
|
|
}
|
|
|
|
func (e *Inventory) ListarProdutos() []Product {
|
|
return e.products
|
|
}
|
|
|
|
func (e *Inventory) AtualizarProduto() {}
|
|
|
|
func (e *Inventory) DeletarProduto() {}
|