Files
fishfish/backend/models/order.go
T

26 lines
859 B
Go

package models
import (
"time"
)
type Order struct {
ID uint `json:"id" gorm:"primaryKey"`
UserID uint `json:"user_id" gorm:"not null;index"`
Status string `json:"status" gorm:"not null"`
DeliveryAddress string `json:"delivery_address" gorm:"not null"`
TotalPrice float64 `json:"total_price" gorm:"not null"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Items []OrderItem `json:"items"`
}
type OrderItem struct {
ID uint `json:"id" gorm:"primaryKey"`
OrderID uint `json:"order_id" gorm:"not null;index"`
ItemID uint `json:"item_id" gorm:"not null;index"`
Quantity float64 `json:"quantity" gorm:"not null"`
Price float64 `json:"price" gorm:"not null"`
Item Item `json:"item" gorm:"foreignKey:ItemID"`
}