53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package models
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type OrderStatus string
|
|
|
|
const (
|
|
Received OrderStatus = "Received"
|
|
AwaitingPayment OrderStatus = "AwaitingPayment"
|
|
Payed OrderStatus = "Payed"
|
|
ReadyForPickup OrderStatus = "ReadyForPickup"
|
|
Shipped OrderStatus = "Shipped"
|
|
Cancelled OrderStatus = "Cancelled"
|
|
)
|
|
|
|
type AddressInfo struct {
|
|
FirstName string `json:"firstname"`
|
|
LastName string `json:"lastname"`
|
|
Address string `json:"address"`
|
|
PostalCode string `json:"postalcode"`
|
|
City string `json:"city"`
|
|
Country string `json:"country"`
|
|
}
|
|
|
|
type Shipping struct {
|
|
Id string `json:"name"`
|
|
Name string `json:"name"`
|
|
Price float64 `json:"price"`
|
|
}
|
|
|
|
type Order struct {
|
|
gorm.Model
|
|
Status OrderStatus `json:"status"`
|
|
Token string `json:"token" binding:"required" gorm:"not null"`
|
|
CartItems []CartItem `json:"cartitems"`
|
|
Email string `json:"email"`
|
|
Comment string `json:"comment"`
|
|
Shipping
|
|
}
|
|
|
|
type CartItem struct {
|
|
gorm.Model
|
|
SessionId string `json:"sessionid" binding:"required" gorm:"not null"`
|
|
ShopItemId uint
|
|
ShopItem ShopItem `json:"shopitem" gorm:"foreignKey:ShopItemId"` //gorm one2one
|
|
ItemVariantId uint
|
|
ItemVariant ItemVariant `json:"itemvariant" gorm:"foreignKey:ItemVariantId"` //gorm one2one
|
|
Quantity int `json:"quantity" binding:"required"`
|
|
OrderId uint
|
|
}
|