cart

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: 8 Imported by: 0

Documentation

Overview

Package cart contains user cart oriented logic.

Package cart is a generated GoMock package.

Package cart is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cart

type Cart struct {
	ID     ID
	UserID user.ID

	CreatedAt time.Time
	UpdatedAt time.Time

	Props   *Props
	Product *product.Product
}

Cart represents the cart.

type Carts

type Carts []*Cart

Carts slice of Cart.

type Filter

type Filter struct {
	ID     IDFilter
	UserID user.IDFilter
}

Filter represents cart filter.

type ID

type ID int64

ID represents an id for cart.

type IDFilter

type IDFilter struct {
	Eq  IDs
	Neq IDs
}

IDFilter represents ID filter.

type IDs

type IDs []ID

IDs defines a slice of ID.

func (IDs) ToInt64

func (ids IDs) ToInt64() []int64

ToInt64 convert slice of IDs to slice int64.

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) 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) (*Cart, 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) Save

func (m *MockRepository) Save(ctx context.Context, props *Props) (*Cart, error)

Save mocks base method.

type MockRepositoryMockRecorder

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

MockRepositoryMockRecorder is the mock recorder for MockRepository.

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) Save

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

Save indicates an expected call of Save.

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) Delete

func (m *MockService) Delete(ctx context.Context, filter *Filter) 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) Query

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

Query mocks base method.

func (*MockService) Save

func (m *MockService) Save(ctx context.Context, props *Props) (*Cart, error)

Save mocks base method.

type MockServiceMockRecorder

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

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) Delete

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

Delete indicates an expected call of Delete.

func (*MockServiceMockRecorder) Query

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

Query indicates an expected call of Query.

func (*MockServiceMockRecorder) Save

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

Save indicates an expected call of Save.

type Props

type Props struct {
	ProductID product.ID
	Amount    int64
}

Props represents cart editable fields.

type QueryCriteria

type QueryCriteria struct {
	Filter Filter
}

QueryCriteria represents a criteria for cart query.

type QueryResult

type QueryResult struct {
	Items Carts
}

QueryResult represents a result for cart query.

type Repository

type Repository interface {
	Get(ctx context.Context, filter *Filter) (*Cart, error)
	Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)
	Save(ctx context.Context, props *Props) (*Cart, error)
	Delete(ctx context.Context, filter *Filter) error
}

Repository represents cart repository.

type Service

type Service interface {
	Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)
	Save(ctx context.Context, props *Props) (*Cart, error)
	Delete(ctx context.Context, filter *Filter) error
}

Service represents cart use cases.

type UseCase

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

UseCase represents cart service.

func NewUseCase

func NewUseCase(cartRepo Repository, productRepo product.Repository) *UseCase

NewUseCase create instance of UseCase.

func (UseCase) Delete

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

Delete carts.

func (UseCase) Query

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

Query carts.

func (UseCase) Save

func (s UseCase) Save(ctx context.Context, props *Props) (*Cart, error)

Save cart.

Directories

Path Synopsis
Package pg contains implementations for cart repositories
Package pg contains implementations for cart repositories

Jump to

Keyboard shortcuts

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