Files
elysium/internal/products/service.go
2025-01-03 21:26:43 +03:00

28 lines
727 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}