package models import ( "time" ) // PrimaryProduct 一级商品表(管理员发布的官方商品) type PrimaryProduct struct { ID uint `gorm:"primaryKey;autoIncrement" json:"id"` CategoryID uint `gorm:"type:int;not null;comment:分类ID" json:"category_id" binding:"required"` ProductName string `gorm:"type:varchar(200);not null;comment:商品名称" json:"product_name" binding:"required"` ProductDescription string `gorm:"type:text;comment:商品描述" json:"product_description"` ProductImages string `gorm:"type:text;comment:商品图片URLs,逗号分割" json:"product_images"` OriginalPrice float64 `gorm:"type:decimal(10,2);not null;comment:原价" json:"original_price" binding:"required"` CurrentPrice float64 `gorm:"type:decimal(10,2);not null;comment:现价" json:"current_price" binding:"required"` StockQuantity int `gorm:"type:int;not null;default:0;comment:库存数量" json:"stock_quantity"` SalesCount int `gorm:"type:int;not null;default:0;comment:销量" json:"sales_count"` ViewCount int `gorm:"type:int;not null;default:0;comment:浏览量" json:"view_count"` Status uint8 `gorm:"type:tinyint;not null;default:1;comment:状态:0下架,1上架" json:"status"` IsHot int8 `gorm:"type:tinyint;not null;default:0;comment:是否为热门商品:0否,1是" json:"is_hot"` SortOrder int `gorm:"type:int;not null;default:0;comment:排序序号" json:"sort_order"` CreatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" json:"updated_at"` // 关联关系 - 注意:不要在关联字段上加验证标签 Category ProductCategory `gorm:"foreignKey:CategoryID" json:"category,omitempty"` } func (PrimaryProduct) TableName() string { return "primary_products" }