You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
66 lines
2.0 KiB
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// Product 保健品表
|
|
type Product struct {
|
|
gorm.Model
|
|
Name string `gorm:"size:100" json:"name"`
|
|
Category string `gorm:"size:50;index" json:"category"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
Efficacy string `gorm:"type:text" json:"efficacy"` // 功效说明
|
|
Suitable string `gorm:"type:text" json:"suitable"` // 适用人群/体质
|
|
Price float64 `json:"price"`
|
|
ImageURL string `gorm:"size:255" json:"image_url"`
|
|
MallURL string `gorm:"size:255" json:"mall_url"` // 商城链接
|
|
IsActive bool `gorm:"default:true" json:"is_active"`
|
|
}
|
|
|
|
// ConstitutionProduct 体质-产品关联表
|
|
type ConstitutionProduct struct {
|
|
gorm.Model
|
|
ConstitutionType string `gorm:"size:20;index" json:"constitution_type"`
|
|
ProductID uint `gorm:"index" json:"product_id"`
|
|
Priority int `json:"priority"` // 推荐优先级
|
|
Reason string `gorm:"size:200" json:"reason"` // 推荐理由
|
|
}
|
|
|
|
// SymptomProduct 症状-产品关联表
|
|
type SymptomProduct struct {
|
|
gorm.Model
|
|
Keyword string `gorm:"size:50;index" json:"keyword"` // 症状关键词
|
|
ProductID uint `gorm:"index" json:"product_id"`
|
|
Priority int `json:"priority"`
|
|
}
|
|
|
|
// PurchaseHistory 购买历史表(商城同步)
|
|
type PurchaseHistory struct {
|
|
gorm.Model
|
|
UserID uint `gorm:"index" json:"user_id"`
|
|
OrderNo string `gorm:"size:50" json:"order_no"` // 商城订单号
|
|
ProductID uint `json:"product_id"`
|
|
ProductName string `gorm:"size:100" json:"product_name"`
|
|
PurchasedAt time.Time `json:"purchased_at"`
|
|
Source string `gorm:"size:20" json:"source"` // mall=保健品商城
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (Product) TableName() string {
|
|
return "products"
|
|
}
|
|
|
|
func (ConstitutionProduct) TableName() string {
|
|
return "constitution_products"
|
|
}
|
|
|
|
func (SymptomProduct) TableName() string {
|
|
return "symptom_products"
|
|
}
|
|
|
|
func (PurchaseHistory) TableName() string {
|
|
return "purchase_histories"
|
|
}
|
|
|