orders

package
v0.0.0-...-5bc4066 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MariaDBOrderRepository

type MariaDBOrderRepository struct {
	OrderRepository
	// contains filtered or unexported fields
}

func NewMariaDBOrderRepository

func NewMariaDBOrderRepository(host string, dbName string, username string, password string) (*MariaDBOrderRepository, error)

Construct a new repository connected to MariaDB

func (*MariaDBOrderRepository) CreateOrder

func (repo *MariaDBOrderRepository) CreateOrder(order *Order) error

Writes the given order to the database.

func (*MariaDBOrderRepository) GetOrder

func (repo *MariaDBOrderRepository) GetOrder(orderId string) (*Order, error)

Returns the order with the given ID from the database. If not found, then nil.

func (*MariaDBOrderRepository) MarkOrderDelivered

func (repo *MariaDBOrderRepository) MarkOrderDelivered(orderId string) error

Sets the 'delivered' field for the given order ID. Returns an error if the order doesn't exist.

type Order

type Order struct {
	OrderId       string
	ItemId        string
	ItemName      string
	Price         int64
	DeliveryPrice int64
	TokenAddress  string
	TokenId       int64
	Delivered     bool
}

A DTO object representing a row in the database

type OrderRepository

type OrderRepository interface {
	GetOrder(orderId string) (*Order, error)
	CreateOrder(order *Order) (string, error)
	MarkOrderDelivered(orderId string) error
}

Jump to

Keyboard shortcuts

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