order

package
v0.0.0-...-bc4bf74 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = errors.New("order does not exist")

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Repo Repo
}

func (*Handler) Create

func (h *Handler) Create(w http.ResponseWriter, r *http.Request)

func (*Handler) DeleteByID

func (h *Handler) DeleteByID(w http.ResponseWriter, r *http.Request)

func (*Handler) GetByID

func (h *Handler) GetByID(w http.ResponseWriter, r *http.Request)

func (*Handler) List

func (h *Handler) List(w http.ResponseWriter, r *http.Request)

func (*Handler) UpdateByID

func (h *Handler) UpdateByID(w http.ResponseWriter, r *http.Request)

type LineItem

type LineItem struct {
	ItemID   uuid.UUID `json:"item_id"`
	Quantity uint      `json:"quantity"`
	Price    uint      `json:"price"`
}

type Order

type Order struct {
	OrderID     uint64     `json:"order_id"`
	CustomerID  uuid.UUID  `json:"customer_id"`
	LineItems   []LineItem `json:"line_items"`
	CreatedAt   *time.Time `json:"created_at"`
	ShippedAt   *time.Time `json:"shipped_at"`
	CompletedAt *time.Time `json:"completed_at"`
}

type PaginationOptions

type PaginationOptions struct {
	Count  uint64
	Cursor uint64
}

type RedisRepo

type RedisRepo struct {
	Client *redis.Client
}

func (*RedisRepo) DeleteByID

func (r *RedisRepo) DeleteByID(ctx context.Context, id uint64) error

func (*RedisRepo) FindAll

func (r *RedisRepo) FindAll(ctx context.Context, page PaginationOptions) (Results, error)

func (*RedisRepo) FindByID

func (r *RedisRepo) FindByID(ctx context.Context, id uint64) (Order, error)

func (*RedisRepo) Insert

func (r *RedisRepo) Insert(ctx context.Context, order Order) error

func (*RedisRepo) Update

func (r *RedisRepo) Update(ctx context.Context, order Order) error

type Repo

type Repo interface {
	Insert(ctx context.Context, order Order) error
	FindByID(ctx context.Context, id uint64) (Order, error)
	DeleteByID(ctx context.Context, id uint64) error
	Update(ctx context.Context, order Order) error
	FindAll(ctx context.Context, page PaginationOptions) (Results, error)
}

type Results

type Results struct {
	Orders []Order
	Cursor uint64
}

Jump to

Keyboard shortcuts

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