package model import ( "time" "gorm.io/gorm" ) type Product struct { ID uint `gorm:"primarykey;comment:商品ID" json:"id"` CreatedAt time.Time `gorm:"comment:创建时间" json:"created_at"` UpdatedAt time.Time `gorm:"comment:更新时间" json:"updated_at"` DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"-"` Name string `gorm:"size:200;not null;comment:商品名" json:"name"` Description string `gorm:"type:text;comment:商品描述" json:"description"` Price float64 `gorm:"type:decimal(10,2);not null;comment:价格" json:"price"` Stock int `gorm:"default:0;comment:库存" json:"stock"` ImageURL string `gorm:"size:500;comment:图片URL" json:"image_url"` Category string `gorm:"size:50;comment:分类" json:"category"` Status int `gorm:"default:1;comment:状态(1上架/0下架)" json:"status"` } func (Product) TableName() string { return "products" } func (Product) TableComment() string { return "商品" }