order

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

Documentation

Overview

Package order contains user order oriented logic.

Package order is a generated GoMock package.

Package order is a generated GoMock package.

Package order is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusStrings

func StatusStrings() []string

StatusStrings returns a slice of all String values of the enum

Types

type Filter

type Filter struct {
	ID     IDFilter
	UserID user.IDFilter
}

Filter represents order filter.

type ID

type ID int64

ID represents an id for order.

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 MockProductRepository

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

MockProductRepository is a mock of ProductRepository interface.

func NewMockProductRepository

func NewMockProductRepository(ctrl *gomock.Controller) *MockProductRepository

NewMockProductRepository creates a new mock instance.

func (*MockProductRepository) BulkCreateTx

func (m *MockProductRepository) BulkCreateTx(ctx context.Context, products Products) (Products, error)

BulkCreateTx mocks base method.

func (*MockProductRepository) EXPECT

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

type MockProductRepositoryMockRecorder

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

MockProductRepositoryMockRecorder is the mock recorder for MockProductRepository.

func (*MockProductRepositoryMockRecorder) BulkCreateTx

func (mr *MockProductRepositoryMockRecorder) BulkCreateTx(ctx, products any) *gomock.Call

BulkCreateTx indicates an expected call of BulkCreateTx.

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, order *Order) (*Order, error)

Create 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) (*Order, error)

Get mocks base method.

func (*MockRepository) Query

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

Query 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, order any) *gomock.Call

Create indicates an expected call of Create.

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.

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) (*Order, error)

Create 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) (*Order, error)

Get mocks base method.

func (*MockService) Query

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

Query 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 any) *gomock.Call

Create indicates an expected call of Create.

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.

type Order

type Order struct {
	ID        ID
	UserID    user.ID
	CreatedAt time.Time
	UpdatedAt time.Time
	Props     *Props
}

Order represents the order.

type Orders

type Orders []*Order

Orders represents slice of Order.

type Product

type Product struct {
	ID        ProductID
	OrderID   ID
	ProductID product.ID
	CreatedAt time.Time
	UpdatedAt time.Time
	Props     *ProductProps
}

Product represents the order product.

type ProductFilter

type ProductFilter struct {
	ID        ProductIDFilter
	OrderID   IDFilter
	ProductID product.IDFilter
}

ProductFilter represents order product filter.

type ProductID

type ProductID int64

ProductID represents an id for order product.

func (ProductID) ToInt64

func (id ProductID) ToInt64() int64

ToInt64 convert ProductID to int64.

type ProductIDFilter

type ProductIDFilter struct {
	Eq  ProductIDs
	Neq ProductIDs
}

ProductIDFilter represents ProductID filter.

type ProductIDs

type ProductIDs []ProductID

ProductIDs represents a slice of ProductID.

func (ProductIDs) ToInt64

func (ids ProductIDs) ToInt64() []int64

ToInt64 convert slice of IDs to slice int64.

type ProductProps

type ProductProps struct {
	Amount int64
	Price  int64
}

ProductProps represents order product editable fields.

type ProductQueryCriteria

type ProductQueryCriteria struct {
	Filter ProductFilter
}

ProductQueryCriteria represents a criteria for order product query.

type ProductRepository

type ProductRepository interface {
	BulkCreateTx(ctx context.Context, products Products) (Products, error)
}

ProductRepository represents order product repository.

type Products

type Products []*Product

Products represents slice of Product.

type Props

type Props struct {
	Status Status
}

Props represents order editable fields.

type QueryCriteria

type QueryCriteria struct {
	Filter     Filter
	Pagination paging.Pagination
}

QueryCriteria represents criteria for service query.

type QueryResult

type QueryResult struct {
	Items Orders
	Count int
}

QueryResult represents a result for order query.

type Repository

type Repository interface {
	Create(ctx context.Context, order *Order) (*Order, error)
	Get(ctx context.Context, filter *Filter) (*Order, error)
	Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)
}

Repository represents order repository.

type Service

type Service interface {
	Get(ctx context.Context, filter *Filter) (*Order, error)
	Query(ctx context.Context, criteria *QueryCriteria) (*QueryResult, error)
	Create(ctx context.Context) (*Order, error)
}

Service represents order use cases.

type Status

type Status uint8

Status represents order's status.

const (
	StatusCreated  Status = iota + 1 // CREATED
	StatusAccepted                   // ACCEPTED
	StatusCanceled                   // CANCELED
)

func StatusString

func StatusString(s string) (Status, error)

StatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func StatusValues

func StatusValues() []Status

StatusValues returns all values of the enum

func (Status) IsAStatus

func (i Status) IsAStatus() bool

IsAStatus returns "true" if the value is listed in the enum definition. "false" otherwise

func (*Status) Scan

func (i *Status) Scan(value interface{}) error

func (Status) String

func (i Status) String() string

func (Status) Value

func (i Status) Value() (driver.Value, error)

type UseCase

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

UseCase represents order service.

func NewUseCase

func NewUseCase(
	repository Repository,
	cartRepository cart.Repository,
	productRepository product.Repository,
	orderProductRepository ProductRepository,
	txManager repositoryx.TxManager,
) *UseCase

NewUseCase create instance of UseCase.

func (UseCase) Create

func (uc UseCase) Create(ctx context.Context) (*Order, error)

Create order.

func (UseCase) Get

func (uc UseCase) Get(ctx context.Context, filter *Filter) (*Order, error)

Get order.

func (UseCase) Query

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

Query orders.

Directories

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

Jump to

Keyboard shortcuts

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