product.go 1012 B

1234567891011121314151617181920212223242526
  1. package request
  2. import "time"
  3. // Product 商品表模型
  4. type Product struct {
  5. ID int64 `gorm:"primary_key;not_null;auto_increment;" json:"id"`
  6. Name string `json:"name"` // 商品名称
  7. Description string `json:"description"` // 商品描述
  8. Price int32 `json:"price"` // 商品价格
  9. StockQuantity int32 `json:"stock_quantity"` // 库存数量
  10. CreatedAt time.Time `json:"created_at"`
  11. UpdatedAt *time.Time `json:"updated_at"`
  12. CategoryID int64 `json:"category_id"`
  13. Category Category `gorm:"foreignKey:CategoryID" json:"category"`
  14. Images []Image `gorm:"foreignKey:ProductID" json:"images"`
  15. }
  16. // Image 图片表模型
  17. type Image struct {
  18. ID int64 `gorm:"primary_key;not_null;auto_increment;" json:"id"`
  19. URL string `json:"url"` // 图片 URL
  20. ProductID int64 `json:"product_id"`
  21. CreatedAt time.Time `json:"created_at"`
  22. UpdatedAt *time.Time `json:"updated_at"`
  23. }