feat: add order and order_item models
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user