feat: add order and order_item models

This commit is contained in:
2026-06-23 09:43:20 +03:00
parent a73d147e12
commit 66070c2e73
17 changed files with 32 additions and 1 deletions
+25
View File
@@ -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"`
}