This commit is contained in:
User
2025-01-03 21:26:43 +03:00
parent 55afc6215f
commit 387fcae36b
34 changed files with 23138 additions and 2 deletions

View File

@@ -0,0 +1 @@
package products

View File

@@ -0,0 +1,10 @@
package products
type Product struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Price float64 `json:"price"`
Stock int `json:"stock"`
Images []string `json:"images"`
}

View File

@@ -0,0 +1 @@
package products

View File

@@ -0,0 +1,27 @@
package products
// Product - структура для товара
type Product struct {
Name string
Price float64
}
// ProductService - сервис для работы с товарами
type ProductService struct {
products []Product
}
// NewProductService - создание нового экземпляра ProductService
func NewProductService() *ProductService {
return &ProductService{}
}
// AddProduct - добавление товара в сервис
func (s *ProductService) AddProduct(product Product) {
s.products = append(s.products, product)
}
// GetAllProducts - получение списка всех товаров
func (s *ProductService) GetAllProducts() []Product {
return s.products
}