1234567891011121314151617181920212223242526 |
- package request
- import "time"
- // Product 商品表模型
- type Product struct {
- ID int64 `gorm:"primary_key;not_null;auto_increment;" json:"id"`
- Name string `json:"name"` // 商品名称
- Description string `json:"description"` // 商品描述
- Price int32 `json:"price"` // 商品价格
- StockQuantity int32 `json:"stock_quantity"` // 库存数量
- CreatedAt time.Time `json:"created_at"`
- UpdatedAt *time.Time `json:"updated_at"`
- CategoryID int64 `json:"category_id"`
- Category Category `gorm:"foreignKey:CategoryID" json:"category"`
- Images []Image `gorm:"foreignKey:ProductID" json:"images"`
- }
- // Image 图片表模型
- type Image struct {
- ID int64 `gorm:"primary_key;not_null;auto_increment;" json:"id"`
- URL string `json:"url"` // 图片 URL
- ProductID int64 `json:"product_id"`
- CreatedAt time.Time `json:"created_at"`
- UpdatedAt *time.Time `json:"updated_at"`
- }
|