product

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseRepository

type DatabaseRepository interface {
	GetCategory(id entities.ID) (*entities.Category, error)
	ListCategories() ([]*entities.Category, error)
	CreateCategory(e *entities.Category) (*entities.Category, error)
	UpdateCategory(e *entities.Category) (*entities.Category, error)
	DeleteCategory(id entities.ID) error

	GetManufacturer(id entities.ID) (*entities.Manufacturer, error)
	ListManufacturers() ([]*entities.Manufacturer, error)
	CreateManufacturer(e *entities.Manufacturer) (*entities.Manufacturer, error)
	UpdateManufacturer(e *entities.Manufacturer) (*entities.Manufacturer, error)
	DeleteManufacturer(id entities.ID) error

	GetProduct(id entities.ID) (*entities.Product, error)
	ListProducts() ([]*entities.Product, error)
	CreateProduct(e *entities.Product) (*entities.Product, error)
	UpdateProduct(e *entities.Product) (*entities.Product, error)
	UpdateProductImages(id entities.ID, images []*entities.Image) ([]*entities.Image, error)
	DeleteProduct(id entities.ID) error

	GetService(id entities.ID) (*entities.Service, error)
	ListServices(optionalServiceCategoryID entities.ID) ([]*entities.Service, error)
	CreateService(e *entities.Service) (*entities.Service, error)
	UpdateService(e *entities.Service) (*entities.Service, error)
	DeleteService(id entities.ID) error

	GetServiceCategory(id entities.ID) (*entities.ServiceCategory, error)
	ListServiceCategories() ([]*entities.ServiceCategory, error)
	CreateServiceCategory(e *entities.ServiceCategory) (*entities.ServiceCategory, error)
	UpdateServiceCategory(e *entities.ServiceCategory) (*entities.ServiceCategory, error)
	DeleteServiceCategory(id entities.ID) error

	GetImage(id entities.ID) (*entities.Image, error)
	UpdateImage(id entities.ID, ownerID entities.ID, newOrder int) ([]*entities.Image, error)
	DeleteImage(id entities.ID) error
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(db DatabaseRepository, imageProxy imageproxy.Service, imageStorage StorageRepository) *Service

func (*Service) AddProductImages

func (s *Service) AddProductImages(productID entities.ID, images map[string][]byte, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Product, error)

AddProductImages adds multiple images to a product

func (*Service) CreateCategory

func (s *Service) CreateCategory(category *entities.Category) (*entities.Category, error)

CreateCategory creates a new category

func (*Service) CreateManufacturer

func (s *Service) CreateManufacturer(manufacturer *entities.Manufacturer) (*entities.Manufacturer, error)

CreateManufacturer creates a new manufacturer

func (*Service) CreateProduct

func (s *Service) CreateProduct(product *entities.Product) (*entities.Product, error)

CreateProduct creates a new product

func (*Service) CreateService added in v1.1.0

func (s *Service) CreateService(service *entities.Service) (*entities.Service, error)

CreateService creates a new service

func (*Service) CreateServiceCategory added in v1.1.0

func (s *Service) CreateServiceCategory(serviceCategory *entities.ServiceCategory) (*entities.ServiceCategory, error)

CreateServiceCategory creates a new service category

func (*Service) DeleteCategory

func (s *Service) DeleteCategory(id entities.ID) error

DeleteCategory deletes a single category by ID

func (*Service) DeleteCategoryImage

func (s *Service) DeleteCategoryImage(categoryID entities.ID) error

DeleteCategoryImage cleares the image of the category

func (*Service) DeleteManufacturer

func (s *Service) DeleteManufacturer(id entities.ID) error

DeleteManufacturer deletes a single manufacturer by ID

func (*Service) DeleteManufacturerImage

func (s *Service) DeleteManufacturerImage(manufacturerID entities.ID) error

DeleteManufacturerImage cleares the image of the manufacturer

func (*Service) DeleteProduct

func (s *Service) DeleteProduct(id entities.ID) error

DeleteProduct deletes a single product by ID

func (*Service) DeleteProductImage

func (s *Service) DeleteProductImage(productID, imageID entities.ID) error

DeleteProductImage deletes a single image for a product

func (*Service) DeleteService added in v1.1.0

func (s *Service) DeleteService(id entities.ID) error

DeleteService deletes a single service by ID

func (*Service) DeleteServiceCategory added in v1.1.0

func (s *Service) DeleteServiceCategory(id entities.ID) error

DeleteServiceCategory deletes a single serviceCategory by ID

func (*Service) GetCategory

func (s *Service) GetCategory(id entities.ID, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Category, error)

GetCategory fetches a single category by ID

func (*Service) GetManufacturer

func (s *Service) GetManufacturer(id entities.ID, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Manufacturer, error)

GetManufacturer fetches a single manufacturer by ID

func (*Service) GetProduct

func (s *Service) GetProduct(id entities.ID, resolved bool, imageConfigs map[string]imageproxy.ImageConfig) (*entities.ResolvedProduct, error)

GetProduct fetches a single product by ID

func (*Service) GetService added in v1.1.0

func (s *Service) GetService(id entities.ID) (*entities.Service, error)

GetService fetches a single service by ID

func (*Service) GetServiceCategory added in v1.1.0

func (s *Service) GetServiceCategory(id entities.ID, resolved bool) (*entities.ResolvedServiceCategory, error)

GetServiceCategory fetches a single service category by ID

func (*Service) ListCategories

func (s *Service) ListCategories(imageConfigs map[string]imageproxy.ImageConfig) ([]*entities.Category, error)

ListCategories fetches all categories

func (*Service) ListManufacturers

func (s *Service) ListManufacturers(imageConfigs map[string]imageproxy.ImageConfig) ([]*entities.Manufacturer, error)

ListManufacturers fetches all manufacturers

func (*Service) ListProducts

func (s *Service) ListProducts(imageConfigs map[string]imageproxy.ImageConfig) ([]*entities.Product, error)

ListProducts fetches all products

func (*Service) ListServiceCategories added in v1.1.0

func (s *Service) ListServiceCategories(resolved bool) ([]*entities.ResolvedServiceCategory, error)

ListServiceCategories fetches all service categories

func (*Service) UpdateCategory

func (s *Service) UpdateCategory(category *entities.Category) (*entities.Category, error)

UpdateCategory persists the provided category

func (*Service) UpdateManufacturer

func (s *Service) UpdateManufacturer(manufacturer *entities.Manufacturer) (*entities.Manufacturer, error)

UpdateManufacturer persists the provided manufacturer

func (*Service) UpdateProduct

func (s *Service) UpdateProduct(product *entities.Product) (*entities.Product, error)

UpdateProduct persists the provided product

func (*Service) UpdateProductImage

func (s *Service) UpdateProductImage(productID, imageID entities.ID, order int) ([]*entities.Image, error)

Update product image

func (*Service) UpdateService added in v1.1.0

func (s *Service) UpdateService(service *entities.Service) (*entities.Service, error)

UpdateService persists the provided service

func (*Service) UpdateServiceCategory added in v1.1.0

func (s *Service) UpdateServiceCategory(serviceCategory *entities.ServiceCategory) (*entities.ServiceCategory, error)

UpdateServiceCategory persists the provided service category

func (*Service) UpsertCategoryImage

func (s *Service) UpsertCategoryImage(categoryID entities.ID, imageName string, imageContent []byte, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Category, error)

UpsertCategoryImage adds/updates the image of the category with the provided one.

func (*Service) UpsertManufacturerImage

func (s *Service) UpsertManufacturerImage(manufacturerID entities.ID, imageName string, imageContent []byte, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Manufacturer, error)

UpsertManufacturerImage adds/updates the image of the manufacturer with the provided one.

type StorageRepository

type StorageRepository interface {
	SaveFile(filename string, content []byte) error
	DeleteFile(filename string) error
}

type Usecase

type Usecase interface {
	GetCategory(id entities.ID, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Category, error)
	ListCategories(imageConfigs map[string]imageproxy.ImageConfig) ([]*entities.Category, error)
	CreateCategory(e *entities.Category) (*entities.Category, error)
	UpdateCategory(e *entities.Category) (*entities.Category, error)
	DeleteCategory(id entities.ID) error
	UpsertCategoryImage(categoryID entities.ID, imageName string, imageContent []byte, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Category, error)
	DeleteCategoryImage(categoryID entities.ID) error

	GetManufacturer(id entities.ID, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Manufacturer, error)
	ListManufacturers(imageConfigs map[string]imageproxy.ImageConfig) ([]*entities.Manufacturer, error)
	CreateManufacturer(e *entities.Manufacturer) (*entities.Manufacturer, error)
	UpdateManufacturer(e *entities.Manufacturer) (*entities.Manufacturer, error)
	DeleteManufacturer(id entities.ID) error
	UpsertManufacturerImage(manufacturerID entities.ID, imageName string, imageContent []byte, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Manufacturer, error)
	DeleteManufacturerImage(manufacturerID entities.ID) error

	GetProduct(id entities.ID, resolved bool, imageConfigs map[string]imageproxy.ImageConfig) (*entities.ResolvedProduct, error)
	ListProducts(imageConfigs map[string]imageproxy.ImageConfig) ([]*entities.Product, error)
	CreateProduct(e *entities.Product) (*entities.Product, error)
	UpdateProduct(e *entities.Product) (*entities.Product, error)
	DeleteProduct(id entities.ID) error
	AddProductImages(id entities.ID, images map[string][]byte, imageConfigs map[string]imageproxy.ImageConfig) (*entities.Product, error)
	UpdateProductImage(productID, imageID entities.ID, order int) ([]*entities.Image, error)
	DeleteProductImage(productID, imageID entities.ID) error

	GetService(id entities.ID) (*entities.Service, error)
	CreateService(e *entities.Service) (*entities.Service, error)
	UpdateService(e *entities.Service) (*entities.Service, error)
	DeleteService(id entities.ID) error

	GetServiceCategory(id entities.ID, resolved bool) (*entities.ResolvedServiceCategory, error)
	ListServiceCategories(resolved bool) ([]*entities.ResolvedServiceCategory, error)
	CreateServiceCategory(e *entities.ServiceCategory) (*entities.ServiceCategory, error)
	UpdateServiceCategory(e *entities.ServiceCategory) (*entities.ServiceCategory, error)
	DeleteServiceCategory(id entities.ID) error
}

Jump to

Keyboard shortcuts

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