database

package
v0.0.0-...-4d4b9d2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2017 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB

DB ...

Functions

func AddProduct

func AddProduct(product Product) error

AddProduct .... TODO update this to user images

func InitDB

func InitDB()

InitDB ...

Types

type Cart

type Cart struct {
	Items          []CartItem     `json:"items"`
	PaymentMethod  int            `json:"paymentid"`
	ShippingAdress ShippingAdress `json:"shippingadress"`
}

type CartItem

type CartItem struct {
	ProductID int64 `json:"productid"`
	Quantity  int   `json:"quantity"`
}

type Category

type Category struct {
	ID          int64  `json:"id"`
	UUID        string `json:"uuid"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Picture     string `json:"picture"`
}

Category ..

func GetCategories

func GetCategories() (categories []Category, err error)

func GetCategoryById

func GetCategoryById(id string) (category Category, err error)

func (*Category) AddCategory

func (c *Category) AddCategory() (err error)

AddCategory ....

type Order

type Order struct {
	ID             int64          `json:"id"`
	UUID           string         `json:"uuid"`
	ProductID      int64          `json:"productid"`
	CustomerID     int64          `json:"customer"`
	PaymentID      int64          `json:"payment"`
	ShippingAdress ShippingAdress `json:"shippingadress"`
	Paid           bool           `json:"paid"`
	Fulfilled      bool           `json:"fulfilled"`
	TimePlaced     time.Time      `json:"timestamp"`
	Price          float64        `json:"price"`
	Quantity       int            `json:"quantity"`
}

func AddOrder

func AddOrder(customerid int64, cart Cart) (orders []Order, err error)

func GetUserOrders

func GetUserOrders(userid int64) (orders []Order, err error)

type Payment

type Payment struct {
	ID          int64  `json:"id"`
	UUID        string `json:"uuid"`
	PaymentType string `json:"paymenttype"`
	Allowed     bool   `json:"allowed"`
}

func GetPayment

func GetPayment(id string) (p Payment, err error)

func GetPayments

func GetPayments() (p []Payment, err error)

type Product

type Product struct {
	ID          int64            `json:"id"`
	UUID        string           `json:"uuid"`
	Name        string           `json:"name"`
	Images      []ProductsImages `json:"images"`
	Description string           `json:"description"`

	// Unit price
	Price        float64   `json:"price"`
	ProductStock float64   `json:"stock"`
	UpdateDate   time.Time `json:"update_date"`
	//AvailableSizes  int       `json:"size"`
	//AvailableColor  string    `json:"color"`
	QuantityPerUnit int64    `json:"quantitypreunit"`
	CategoryID      int64    `json:"categoryid"`
	Category        Category `json:"category"`
}

Product describe a ecom

func GetProduct

func GetProduct(uuid string) (product Product, err error)

GetProduct ...

func GetProducts

func GetProducts() (products []Product, err error)

GetProducts ...

type ProductsImages

type ProductsImages struct {
	ID        int64  `json:"id"`
	UUID      string `json:"uuid"`
	ImageUlr  string `json:"image_url"`
	ProductID int64  `json:"productid"`
}

type ShippingAdress

type ShippingAdress struct {
	Contry string `json:"contry"`
	Zip    string `json:"zip"`
	Adress string `json:"adress"`
}

type User

type User struct {
	ID           int64  `json:"id"`
	UUID         string `json:"uuid"`
	Fisrtname    string `json:"firstname"`
	Lastname     string `json:"lastname"`
	Username     string `json:"username"`
	Address      string
	Location     string `json:"location"`
	PhoneNumber  string `json:"phonenumber"`
	Email        string `json:"email"`
	PasswordHash string
	Password     string    `json:"password"`
	JoinedOn     time.Time `json:"joinedon"`
}

User ...

func GetUserByUUID

func GetUserByUUID(uuid string) (User, error)

func (*User) CreateUser

func (user *User) CreateUser() (err error)

CreateUser writes the userdetails to the database

type UserCredential

type UserCredential struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

UserCredential ...

func (*UserCredential) VerifyUser

func (u *UserCredential) VerifyUser() (user User, err error)

VerifyUser ...

Jump to

Keyboard shortcuts

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