products

package
v0.0.0-...-5661f94 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Product

type Product struct {
	ID          int       `json:"_" gorm:"autoIncrement,primaryKey"`
	Sku         string    `json:"sku"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Category    string    `json:"category"`
	MerchantID  string    `json:"merchantId"`
	Brand       string    `json:"brand"`
	Price       float64   `json:"price"`
	ImageURL    string    `json:"imageUrl"`
	TimeAdded   time.Time `json:"timeAdded"`
}

type ProductRepo

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

ProductRepo is the default implementation for Repository inteface.

func NewRepository

func NewRepository(db *gorm.DB, tracer opentracing.Tracer) *ProductRepo

NewRepository returns a new product repository object.

func (*ProductRepo) GetProductBySKU

func (r *ProductRepo) GetProductBySKU(ctx context.Context, sku string) (*Product, error)

func (*ProductRepo) SaveProduct

func (r *ProductRepo) SaveProduct(ctx context.Context, product *Product) error

SaveProduct saves a new product to the database.

type Repository

type Repository interface {
	SaveProduct(ctx context.Context, product *Product) error
	GetProductBySKU(ctx context.Context, sku string) (*Product, error)
}

Repository is the interface that describes a product repository object.

Jump to

Keyboard shortcuts

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