models

package
v0.0.0-...-1535c92 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	gorm.Model
	Customer   Customer
	Address    string `json:"address" gorm:"column:address"`
	CustomerID uint   `json:"customer_id" gorm:"column:customer_id"`
	IsMain     bool   `json:"main_address" gorm:"column:is_main"`
}

Address customer address

func (Address) TableName

func (Address) TableName() string

TableName table name for Customer

type Cart

type Cart struct {
	gorm.Model
	Customer       Customer
	Status         CartStatus `json:"cart-status" gorm:"column:cart_status"`
	CustomerID     uint       `json:"customer_id" gorm:"column:customer_id"`
	ExpirationDate time.Time  `json:"expiration" gorm:"column:expiration"`
}

Cart shopping cart

func (Cart) TableName

func (Cart) TableName() string

TableName table name for Customer

type CartItem

type CartItem struct {
	gorm.Model
	Product   Product
	Cart      Cart
	CartID    uint    `json:"cart_id" gorm:"column:cart_id"`
	ProductID uint    `json:"product_id" gorm:"column:product_id"`
	Quantity  int     `json:"quantity" gorm:"column:quantity"`
	UnitPrice float64 `gorm:"column:price" json:"unit_price"`
}

CartItem link between cart and a product

func (CartItem) TableName

func (CartItem) TableName() string

TableName table name for Customer

type CartStatus

type CartStatus int64

CartStatus enumeration

const (
	Cart_Status_Active CartStatus = iota
	Cart_Status_Complete
	Cart_Status_Closed
)

func (*CartStatus) Scan

func (u *CartStatus) Scan(value interface{}) error

func (CartStatus) String

func (cartStatus CartStatus) String() string

func (CartStatus) Value

func (u CartStatus) Value() (driver.Value, error)

type ChargeRequest

type ChargeRequest struct {
	OrderID     int    `json:"order_id"`
	UseExisting bool   `json:"use_existing"`
	SaveCard    bool   `json:"save_card"`
	Token       string `json:"token"`
}

ChargeRequest charge request

type CreateOrderRequest

type CreateOrderRequest struct {
	ProductID int `json:"product_id"`
	Quantity  int `json:"quantity"`
}

CreateOrderRequest create order

type Customer

type Customer struct {
	gorm.Model
	Name      string  `json:"name" sql:"-"`
	FirstName string  `gorm:"column:firstname" json:"firstname"  validate:"required"`
	LastName  string  `gorm:"column:lastname" json:"lastname"  validate:"required"`
	Email     string  `gorm:"column:email" json:"email"  validate:"required,email"`
	Password  string  `gorm:"column:password" json:"password"  validate:"required"`
	LoggedIn  bool    `gorm:"column:loggedin" json:"loggedin"`
	Orders    []Order `json:"orders"`
}

Customer customer data

func (Customer) TableName

func (Customer) TableName() string

TableName table name for Customer

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"`
}

LoginResponse login response

type Order

type Order struct {
	gorm.Model
	Cart              Cart
	DeliveryAddress   Address
	CartID            int         `json:"cart_id" gorm:"column:cart_id"`
	DeliveryAddressID int         `json:"address_id" gorm:"column:address_id"`
	PurchaseDate      time.Time   `gorm:"column:purchase_date" json:"purchase_date"`
	PaymentID         int         `json:"payment_id" gorm:"column:payment_id"`
	Status            OrderStatus `json:"status" gorm:"column:status"`
	TotalPrice        float64     `gorm:"column:total_price" json:"total_price"`
}

Order order data

func (Order) TableName

func (Order) TableName() string

TableName table name for Order

type OrderStatus

type OrderStatus int64

OrderStatus enumeration

const (
	Order_Status_Init OrderStatus = iota
	Order_Status_Pending
	Order_Status_Complete
	Order_Status_Failed
)

func (*OrderStatus) Scan

func (u *OrderStatus) Scan(value interface{}) error

func (OrderStatus) String

func (orderStatus OrderStatus) String() string

func (OrderStatus) Value

func (u OrderStatus) Value() (driver.Value, error)

type Payment

type Payment struct {
	gorm.Model
	Order    Order
	Status   string `gorm:"column:status;type:varchar(128)"`
	StripeID string `gorm:"column:stripe_id;type:varchar(250)"`
}

Payment payment data

func (Payment) TableName

func (Payment) TableName() string

TableName table name for Payment

type Product

type Product struct {
	gorm.Model
	Image       string  `json:"img"`
	SmallImage  string  `gorm:"column:smallimg" json:"small_img"`
	ImagAlt     string  `json:"imgalt" gorm:"column:imgalt"`
	Price       float64 `json:"price"`
	Promotion   float64 `json:"promotion"` //sql.NullFloat64
	PoructName  string  `gorm:"column:productname" json:"productname"`
	Description string
}

Product product data

func (Product) TableName

func (Product) TableName() string

TableName table name for Product

Jump to

Keyboard shortcuts

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