vproductbus

package
v0.0.0-...-8ad27d5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package vproductbus provides business access to view product domain.

Index

Constants

View Source
const (
	OrderByProductID = "product_id"
	OrderByUserID    = "user_id"
	OrderByName      = "name"
	OrderByCost      = "cost"
	OrderByQuantity  = "quantity"
	OrderByUserName  = "user_name"
)

Set of fields that the results can be ordered by.

Variables

View Source
var DefaultOrderBy = order.NewBy(OrderByProductID, order.ASC)

DefaultOrderBy represents the default way we sort.

Functions

This section is empty.

Types

type Business

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

Business manages the set of APIs for view product access.

func NewBusiness

func NewBusiness(storer Storer) *Business

NewBusiness constructs a vproduct business API for use.

func (*Business) Count

func (b *Business) Count(ctx context.Context, filter QueryFilter) (int, error)

Count returns the total number of products.

func (*Business) Query

func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Product, error)

Query retrieves a list of existing products.

type Product

type Product struct {
	ID          uuid.UUID
	UserID      uuid.UUID
	Name        productbus.Name
	Cost        float64
	Quantity    int
	DateCreated time.Time
	DateUpdated time.Time
	UserName    userbus.Name
}

Product represents an individual product with extended information.

type QueryFilter

type QueryFilter struct {
	ID       *uuid.UUID
	Name     *productbus.Name
	Cost     *float64
	Quantity *int
	UserName *userbus.Name
}

QueryFilter holds the available fields a query can be filtered on. We are using pointer semantics because the With API mutates the value.

type Storer

type Storer interface {
	Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Product, error)
	Count(ctx context.Context, filter QueryFilter) (int, error)
}

Storer interface declares the behavior this package needs to perists and retrieve data.

Directories

Path Synopsis
stores
vproductdb
Package vproductdb provides access to the product view.
Package vproductdb provides access to the product view.

Jump to

Keyboard shortcuts

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