diff --git a/internal/model/shop.go b/internal/model/shop.go new file mode 100644 index 0000000..7986694 --- /dev/null +++ b/internal/model/shop.go @@ -0,0 +1,33 @@ +package model + +import "time" + +// ProductCategory 商品分类 +type ProductCategory struct { + ID uint `gorm:"primaryKey" json:"id"` + Name string `gorm:"size:100;not null" json:"name"` + Icon string `gorm:"size:50" json:"icon"` + Sort int `gorm:"default:0" json:"sort"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +} + +// Product 商品模型(跨境电商网站使用) +type Product struct { + ID uint `gorm:"primaryKey" json:"id"` + Name string `gorm:"size:200;not null" json:"name"` + Description string `gorm:"type:text" json:"description"` + Price float64 `gorm:"type:decimal(10,2);not null" json:"price"` + OriginalPrice float64 `gorm:"type:decimal(10,2)" json:"original_price"` + Image string `gorm:"size:255" json:"image"` + Images string `gorm:"type:text" json:"images"` // JSON: 图片数组 + CategoryID uint `gorm:"index" json:"category_id"` + Stock int `gorm:"default:0" json:"stock"` + Rating float64 `gorm:"type:decimal(2,1);default:5.0" json:"rating"` + Sales int `gorm:"default:0" json:"sales"` + Tags string `gorm:"type:text" json:"tags"` // JSON: 标签数组 + Sort int `gorm:"default:0" json:"sort"` + Status int `gorm:"default:1;not null" json:"status"` // 1=上架 + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +}