dblayer

package
v0.0.0-...-990aa43 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrINVALIDPASSWORD = errors.New("Invalid password")

Functions

This section is empty.

Types

type DBLayer

type DBLayer interface {
	GetAllProducts() ([]models.Product, error)
	GetPromos() ([]models.Product, error)
	GetCustomerByName(string, string) (models.Customer, error)
	GetCustomerByID(int) (models.Customer, error)
	GetProduct(int) (models.Product, error)
	AddUser(models.Customer) (models.Customer, error)
	SignInUser(username, password string) (models.Customer, error)
	SignOutUserById(int) error
	GetCustomerOrdersByID(int) ([]models.Order, error)
	AddOrder(models.Order) error
	GetCreditCardCID(int) (string, error)
	SaveCreditCardForCustomer(int, string) error
}

type DBORM

type DBORM struct {
	*gorm.DB
}

func NewORM

func NewORM(dbname, con string) (*DBORM, error)

func (*DBORM) AddOrder

func (db *DBORM) AddOrder(order models.Order) error

func (*DBORM) AddUser

func (db *DBORM) AddUser(customer models.Customer) (models.Customer, error)

func (*DBORM) GetAllProducts

func (db *DBORM) GetAllProducts() (products []models.Product, err error)

func (*DBORM) GetCreditCardCID

func (db *DBORM) GetCreditCardCID(id int) (string, error)

func (*DBORM) GetCustomerByID

func (db *DBORM) GetCustomerByID(id int) (customer models.Customer, err error)

func (*DBORM) GetCustomerByName

func (db *DBORM) GetCustomerByName(firstname string, lastname string) (customer models.Customer, err error)

func (*DBORM) GetCustomerOrdersByID

func (db *DBORM) GetCustomerOrdersByID(id int) (orders []models.Order, err error)

func (*DBORM) GetProduct

func (db *DBORM) GetProduct(id int) (product models.Product, error error)

func (*DBORM) GetPromos

func (db *DBORM) GetPromos() (products []models.Product, err error)

func (*DBORM) SaveCreditCardForCustomer

func (db *DBORM) SaveCreditCardForCustomer(id int, ccid string) error

func (*DBORM) SignInUser

func (db *DBORM) SignInUser(email, pass string) (customer models.Customer, err error)

func (*DBORM) SignOutUserById

func (db *DBORM) SignOutUserById(id int) error

type MockDBLayer

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

func NewMockDBLayer

func NewMockDBLayer(products []models.Product, customers []models.Customer, orders []models.Order) *MockDBLayer

func NewMockDBLayerWithData

func NewMockDBLayerWithData() *MockDBLayer

func (*MockDBLayer) AddOrder

func (mock *MockDBLayer) AddOrder(order models.Order) error

func (*MockDBLayer) AddUser

func (mock *MockDBLayer) AddUser(customer models.Customer) (models.Customer, error)

func (*MockDBLayer) GetAllProducts

func (mock *MockDBLayer) GetAllProducts() ([]models.Product, error)

func (*MockDBLayer) GetCreditCardCID

func (mock *MockDBLayer) GetCreditCardCID(id int) (string, error)

func (*MockDBLayer) GetCustomerByID

func (mock *MockDBLayer) GetCustomerByID(id int) (models.Customer, error)

func (*MockDBLayer) GetCustomerByName

func (mock *MockDBLayer) GetCustomerByName(first, last string) (models.Customer, error)

func (*MockDBLayer) GetCustomerOrdersByID

func (mock *MockDBLayer) GetCustomerOrdersByID(id int) ([]models.Order, error)

func (*MockDBLayer) GetMockCustomersData

func (mock *MockDBLayer) GetMockCustomersData() []models.Customer

func (*MockDBLayer) GetMockOrdersData

func (mock *MockDBLayer) GetMockOrdersData() []models.Order

func (*MockDBLayer) GetMockProductData

func (mock *MockDBLayer) GetMockProductData() []models.Product

func (*MockDBLayer) GetProduct

func (mock *MockDBLayer) GetProduct(id int) (models.Product, error)

func (*MockDBLayer) GetPromos

func (mock *MockDBLayer) GetPromos() ([]models.Product, error)

func (*MockDBLayer) SaveCreditCardForCustomer

func (mock *MockDBLayer) SaveCreditCardForCustomer(int, string) error

func (*MockDBLayer) SetError

func (mock *MockDBLayer) SetError(err error)

func (*MockDBLayer) SignInUser

func (mock *MockDBLayer) SignInUser(email, password string) (models.Customer, error)

func (*MockDBLayer) SignOutUserById

func (mock *MockDBLayer) SignOutUserById(id int) error

Jump to

Keyboard shortcuts

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