package model import ( "time" "gorm.io/gorm" ) // Product 产品模型 // Logan.Li type Product struct { ID uint `json:"id" gorm:"primaryKey"` Name string `json:"name" gorm:"size:100;not null"` Code string `json:"code" gorm:"size:50;uniqueIndex"` Version string `json:"version" gorm:"size:50"` Description string `json:"description" gorm:"type:text"` Features string `json:"features" gorm:"type:text"` // JSON 格式存储功能列表 Price float64 `json:"price" gorm:"type:decimal(10,2)"` PriceModel string `json:"price_model" gorm:"size:50;default:'subscription'"` // subscription / perpetual / trial Status int `json:"status" gorm:"default:1"` // 1: 上架, 0: 下架 Licenses []License `json:"licenses,omitempty" gorm:"foreignKey:ProductID"` Plans []Plan `json:"plans,omitempty" gorm:"foreignKey:ProductID"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"` } // TableName 指定表名 // Logan.Li func (Product) TableName() string { return "products" }