This commit is contained in:
solosw
2026-01-05 14:11:34 +08:00
parent 35ef825371
commit 99b11b04e4
658 changed files with 99266 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package models
import (
"time"
)
// SecondaryProduct 二级商品表(用户上架的商品)
type SecondaryProduct struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
SellerID uint `gorm:"type:int;not null;comment:卖家用户ID" json:"seller_id" binding:"required"`
OriginalProductID *uint `gorm:"type:int;comment:原始商品ID(一级商品ID或二级商品ID" json:"original_product_id"`
OriginalProductType uint8 `gorm:"type:tinyint;not null;comment:原始商品类型:1一级商品,2二级商品" json:"original_product_type" 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:商品图片URLsJSON格式存储" json:"product_images"`
CostPrice float64 `gorm:"type:decimal(10,2);not null;comment:成本价(用户购买时的价格)" json:"cost_price" binding:"required"`
SellingPrice float64 `gorm:"type:decimal(10,2);not null;comment:出售价格" json:"selling_price" binding:"required"`
Quantity int `gorm:"type:int;not null;default:1;comment:出售数量" json:"quantity"`
Status uint8 `gorm:"type:tinyint;not null;default:1;comment:状态:0下架,1上架,2已售出" json:"status"`
ViewCount int `gorm:"type:int;not null;default:0;comment:浏览量" json:"view_count"`
SalesCount int `gorm:"type:int;not null;default:0;" json:"sales_count"`
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"`
CategoryID uint `gorm:"type:int;not null;default:0;comment:商品分类ID" json:"category_id"`
ProductCondition string `gorm:"type varchar(255)" json:"product_condition"`
UserWarehouseID uint `gorm:"type:int;not null" json:"user_warehouse_id"`
// 关联关系
Seller User `gorm:"foreignKey:SellerID" json:"seller,omitempty"`
Category *ProductCategory `gorm:"foreignKey:CategoryID" json:"category,omitempty"`
UserWarehouse *UserWarehouse `gorm:"foreignKey:UserWarehouseID" json:"user_warehouse,omitempty"`
}
func (SecondaryProduct) TableName() string {
return "secondary_products"
}