product

package
v0.0.0-...-f15602e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package product is a generated GoMock package.

Package product is a generated GoMock package.

Package product contains product oriented logic.

Package product is a generated GoMock package.

Package product is a generated GoMock package.

Package product is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	ID         IDFilter
	CategoryID category.IDFilter
}

Filter represents product filter.

type ID

type ID int64

ID represents an id for product.

func (ID) ToInt64

func (id ID) ToInt64() int64

ToInt64 convert ID to int64.

type IDFilter

type IDFilter struct {
	Eq  IDs
	Neq IDs
}

IDFilter represents ID filter.

type IDs

type IDs []ID

IDs represents a slice of ID.

func (IDs) ToInt64

func (ids IDs) ToInt64() []int64

ToInt64 convert slice of IDs to slice int64.

type Image

type Image struct {
	ID        ImageID
	CreatedAt time.Time
	UpdatedAt time.Time
	Props     *ImageProps
}

Image represents the product image.

type ImageFilter

type ImageFilter struct {
	ImageID   ImageIDFilter
	ProductID IDFilter
}

ImageFilter represents product image filter.

type ImageID

type ImageID int64

ImageID represents an id for product image.

func (ImageID) ToInt64

func (id ImageID) ToInt64() int64

ToInt64 convert ImageID to int64.

type ImageIDFilter

type ImageIDFilter struct {
	Eq  ImageIDs
	Neq ImageIDs
}

ImageIDFilter represents ImageID filter.

type ImageIDs

type ImageIDs []ImageID

ImageIDs represents a slice of ImageID.

func (ImageIDs) ToInt64

func (ids ImageIDs) ToInt64() []int64

ToInt64 convert slice of ImageIDs to slice int64.

type ImageProps

type ImageProps struct {
	ProductID ID
	Name      string
}

ImageProps represents product image editable fields.

type ImageQueryCriteria

type ImageQueryCriteria struct {
	Filter ImageFilter
}

ImageQueryCriteria represents a criteria for image product query.

type ImageRepository

type ImageRepository interface {
	BulkCreate(ctx context.Context, images Images) (Images, error)
	Get(ctx context.Context, filter *ImageFilter) (*Image, error)
	Query(ctx context.Context, criteria *ImageQueryCriteria) (Images, error)
	Delete(ctx context.Context, filter *ImageFilter) error
}

ImageRepository represents product image repository.

type ImageService

type ImageService interface {
	BulkCreate(ctx context.Context, productID ID, props []*image.StorageProps) (Images, error)
	Delete(ctx context.Context, imageID ImageID) error
}

ImageService represents product image use cases.

type ImageUseCase

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

ImageUseCase represents product image service.

func NewImageUseCase

func NewImageUseCase(
	logger *zap.Logger,
	productRepo Repository,
	imageRepo ImageRepository,
	imageStorage image.Storage,
	txManager repositoryx.TxManager,
) *ImageUseCase

NewImageUseCase create instance of ImageUseCase.

func (ImageUseCase) BulkCreate

func (s ImageUseCase) BulkCreate(
	ctx context.Context,
	productID ID,
	props []*image.StorageProps,
) (Images, error)

BulkCreate product images.

func (ImageUseCase) Delete

func (s ImageUseCase) Delete(ctx context.Context, imageID ImageID) error

Delete image from db and file storage.

type Images

type Images []*Image

Images represents slice of Product.

func (Images) IDs

func (ii Images) IDs() ImageIDs

IDs convert slice of Images to slice ImageIDs.

func (Images) Names

func (ii Images) Names() []string

Names convert slice of Images to slice []string.

type MockImageRepository

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

MockImageRepository is a mock of ImageRepository interface.

func NewMockImageRepository

func NewMockImageRepository(ctrl *gomock.Controller) *MockImageRepository

NewMockImageRepository creates a new mock instance.

func (*MockImageRepository) BulkCreate

func (m *MockImageRepository) BulkCreate(ctx context.Context, images Images) (Images, error)

BulkCreate mocks base method.

func (*MockImageRepository) Delete

func (m *MockImageRepository) Delete(ctx context.Context, filter *ImageFilter) error

Delete mocks base method.

func (*MockImageRepository) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockImageRepository) Get

func (m *MockImageRepository) Get(ctx context.Context, filter *ImageFilter) (*Image, error)

Get mocks base method.

func (*MockImageRepository) Query

func (m *MockImageRepository) Query(ctx context.Context, criteria *ImageQueryCriteria) (Images, error)

Query mocks base method.

type MockImageRepositoryMockRecorder

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

MockImageRepositoryMockRecorder is the mock recorder for MockImageRepository.

func (*MockImageRepositoryMockRecorder) BulkCreate

func (mr *MockImageRepositoryMockRecorder) BulkCreate(ctx, images any) *gomock.Call

BulkCreate indicates an expected call of BulkCreate.

func (*MockImageRepositoryMockRecorder) Delete

func (mr *MockImageRepositoryMockRecorder) Delete(ctx, filter any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockImageRepositoryMockRecorder) Get

func (mr *MockImageRepositoryMockRecorder) Get(ctx, filter any) *gomock.Call

Get indicates an expected call of Get.

func (*MockImageRepositoryMockRecorder) Query

func (mr *MockImageRepositoryMockRecorder) Query(ctx, criteria any) *gomock.Call

Query indicates an expected call of Query.

type MockImageService

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

MockImageService is a mock of ImageService interface.

func NewMockImageService

func NewMockImageService(ctrl *gomock.Controller) *MockImageService

NewMockImageService creates a new mock instance.

func (*MockImageService) BulkCreate

func (m *MockImageService) BulkCreate(ctx context.Context, productID ID, props []*image.StorageProps) (Images, error)

BulkCreate mocks base method.

func (*MockImageService) Delete

func (m *MockImageService) Delete(ctx context.Context, imageID ImageID) error

Delete mocks base method.

func (*MockImageService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

type MockImageServiceMockRecorder

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

MockImageServiceMockRecorder is the mock recorder for MockImageService.

func (*MockImageServiceMockRecorder) BulkCreate

func (mr *MockImageServiceMockRecorder) BulkCreate(ctx, productID, props any) *gomock.Call

BulkCreate indicates an expected call of BulkCreate.

func (*MockImageServiceMockRecorder) Delete

func (mr *MockImageServiceMockRecorder) Delete(ctx, imageID any) *gomock.Call

Delete indicates an expected call of Delete.

type MockRepository

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

MockRepository is a mock of Repository interface.

func NewMockRepository

func NewMockRepository(ctrl *gomock.Controller) *MockRepository

NewMockRepository creates a new mock instance.

func (*MockRepository) Create

func (m *MockRepository) Create(ctx context.Context, props *Props) (*Product, error)

Create mocks base method.

func (*MockRepository) Delete

func (m *MockRepository) Delete(ctx context.Context, filter *Filter) error

Delete mocks base method.

func (*MockRepository) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockRepository) Get

func (m *MockRepository) Get(ctx context.Context, filter *Filter) (*Product, error)

Get mocks base method.

func (*MockRepository) Query

func (m *MockRepository) Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)

Query mocks base method.

func (*MockRepository) Update

func (m *MockRepository) Update(ctx context.Context, productID ID, props *Props) (*Product, error)

Update mocks base method.

type MockRepositoryMockRecorder

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

MockRepositoryMockRecorder is the mock recorder for MockRepository.

func (*MockRepositoryMockRecorder) Create

func (mr *MockRepositoryMockRecorder) Create(ctx, props any) *gomock.Call

Create indicates an expected call of Create.

func (*MockRepositoryMockRecorder) Delete

func (mr *MockRepositoryMockRecorder) Delete(ctx, filter any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockRepositoryMockRecorder) Get

func (mr *MockRepositoryMockRecorder) Get(ctx, filter any) *gomock.Call

Get indicates an expected call of Get.

func (*MockRepositoryMockRecorder) Query

func (mr *MockRepositoryMockRecorder) Query(ctx, criteria any) *gomock.Call

Query indicates an expected call of Query.

func (*MockRepositoryMockRecorder) Update

func (mr *MockRepositoryMockRecorder) Update(ctx, productID, props any) *gomock.Call

Update indicates an expected call of Update.

type MockSearchEngine

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

MockSearchEngine is a mock of SearchEngine interface.

func NewMockSearchEngine

func NewMockSearchEngine(ctrl *gomock.Controller) *MockSearchEngine

NewMockSearchEngine creates a new mock instance.

func (*MockSearchEngine) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSearchEngine) Index

func (m *MockSearchEngine) Index(ctx context.Context, products Products) error

Index mocks base method.

func (*MockSearchEngine) Search

Search mocks base method.

type MockSearchEngineMockRecorder

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

MockSearchEngineMockRecorder is the mock recorder for MockSearchEngine.

func (*MockSearchEngineMockRecorder) Index

func (mr *MockSearchEngineMockRecorder) Index(ctx, products any) *gomock.Call

Index indicates an expected call of Index.

func (*MockSearchEngineMockRecorder) Search

func (mr *MockSearchEngineMockRecorder) Search(ctx, criteria any) *gomock.Call

Search indicates an expected call of Search.

type MockService

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

MockService is a mock of Service interface.

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance.

func (*MockService) Create

func (m *MockService) Create(ctx context.Context, props *Props) (*Product, error)

Create mocks base method.

func (*MockService) Delete

func (m *MockService) Delete(ctx context.Context, productID ID) error

Delete mocks base method.

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockService) Get

func (m *MockService) Get(ctx context.Context, filter *Filter) (*Product, error)

Get mocks base method.

func (*MockService) Query

func (m *MockService) Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)

Query mocks base method.

func (*MockService) Update

func (m *MockService) Update(ctx context.Context, productID ID, props *Props) (*Product, error)

Update mocks base method.

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) Create

func (mr *MockServiceMockRecorder) Create(ctx, props any) *gomock.Call

Create indicates an expected call of Create.

func (*MockServiceMockRecorder) Delete

func (mr *MockServiceMockRecorder) Delete(ctx, productID any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockServiceMockRecorder) Get

func (mr *MockServiceMockRecorder) Get(ctx, filter any) *gomock.Call

Get indicates an expected call of Get.

func (*MockServiceMockRecorder) Query

func (mr *MockServiceMockRecorder) Query(ctx, criteria any) *gomock.Call

Query indicates an expected call of Query.

func (*MockServiceMockRecorder) Update

func (mr *MockServiceMockRecorder) Update(ctx, productID, props any) *gomock.Call

Update indicates an expected call of Update.

type Ordering

type Ordering struct {
	Price *repositoryx.Order
}

Ordering represents order criteria.

type Product

type Product struct {
	ID        ID
	CreatedAt time.Time
	UpdatedAt time.Time
	Images    Images
	Props     *Props
}

Product represents the product.

type Products

type Products []*Product

Products represents slice of Product.

type Props

type Props struct {
	CategoryID  category.ID
	Name        string
	Description string
	Amount      int64
	Price       int64
}

Props is a user-defined product properties.

type QueryCriteria

type QueryCriteria struct {
	Filter     Filter
	Ordering   Ordering
	Pagination paging.Pagination
}

QueryCriteria represents criteria for products query.

type QueryResult

type QueryResult struct {
	Items Products
	Count int
}

QueryResult represents a result for products query.

type Repository

type Repository interface {
	Create(ctx context.Context, props *Props) (*Product, error)
	Update(ctx context.Context, productID ID, props *Props) (*Product, error)
	Delete(ctx context.Context, filter *Filter) error
	Get(ctx context.Context, filter *Filter) (*Product, error)
	Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)
}

Repository represents product repository.

type SearchEngine

type SearchEngine interface {
	Search(ctx context.Context, criteria *SearchQueryCriteria) (*SearchQueryResult, error)
	Index(ctx context.Context, products Products) error
}

SearchEngine represents product search engine.

type SearchQueryCriteria

type SearchQueryCriteria struct {
	Search     string
	Pagination paging.Pagination
}

SearchQueryCriteria represents criteria for products search.

type SearchQueryResult

type SearchQueryResult struct {
	Count int
}

SearchQueryResult represents a result for products search.

type Service

type Service interface {
	Get(ctx context.Context, filter *Filter) (*Product, error)
	Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)
	Create(ctx context.Context, props *Props) (*Product, error)
	Update(ctx context.Context, productID ID, props *Props) (*Product, error)
	Delete(ctx context.Context, productID ID) error
}

Service represents product use cases.

type UseCase

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

UseCase represents product service.

func NewUseCase

func NewUseCase(
	productRepo Repository,
	productImageRepo ImageRepository,
	imageStorage image.Storage,
	txManager repositoryx.TxManager,
) *UseCase

NewUseCase create instance of UseCase.

func (UseCase) Create

func (s UseCase) Create(ctx context.Context, props *Props) (*Product, error)

Create product.

func (UseCase) Delete

func (s UseCase) Delete(ctx context.Context, productID ID) error

Delete product.

func (UseCase) Get

func (s UseCase) Get(ctx context.Context, filter *Filter) (*Product, error)

Get product.

func (UseCase) Query

func (s UseCase) Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)

Query products.

func (UseCase) Update

func (s UseCase) Update(ctx context.Context, productID ID, props *Props) (*Product, error)

Update product.

Directories

Path Synopsis
Package ms provides the repositories implemented with the Meilisearch
Package ms provides the repositories implemented with the Meilisearch
Package pg contains implementations for product repositories
Package pg contains implementations for product repositories

Jump to

Keyboard shortcuts

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