e9a6543a8b
- 新增 util.ToPinyin(),使用 go-pinyin 生成全拼和首字母 - Product model 新增 name_pinyin / name_initials 列(AutoMigrate) - 启动时自动回填存量商品拼音 - Create / Update / FindOrCreate 写入时同步生成拼音 - 库存搜索 SQL 加入拼音/首字母 LIKE 条件 - 前端去掉 300ms 防抖,改为回车/点击搜索按钮触发 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
33 lines
1.4 KiB
Go
33 lines
1.4 KiB
Go
package model
|
|
|
|
type ProductCategory struct {
|
|
TenantBase
|
|
Name string `gorm:"size:100;not null" json:"name"`
|
|
ParentID *uint64 `json:"parent_id"`
|
|
SortOrder int `gorm:"default:0" json:"sort_order"`
|
|
}
|
|
|
|
type Product struct {
|
|
TenantBase
|
|
PublicID string `gorm:"size:36;uniqueIndex" json:"public_id"`
|
|
Code string `gorm:"size:50" json:"code"`
|
|
Barcode string `gorm:"size:100" json:"barcode"`
|
|
Name string `gorm:"size:200;not null" json:"name"`
|
|
Series string `gorm:"size:100" json:"series"`
|
|
Spec string `gorm:"size:100" json:"spec"`
|
|
Unit string `gorm:"size:20" json:"unit"`
|
|
CategoryID *uint64 `json:"category_id"`
|
|
Brand string `gorm:"size:100" json:"brand"`
|
|
PurchasePrice float64 `gorm:"type:decimal(12,2)" json:"purchase_price"`
|
|
SalePrice float64 `gorm:"type:decimal(12,2)" json:"sale_price"`
|
|
MinStock int `gorm:"default:0" json:"min_stock"`
|
|
Description string `gorm:"type:text" json:"description"`
|
|
CustomFields JSON `gorm:"type:json" json:"custom_fields,omitempty"`
|
|
Remark string `gorm:"size:500" json:"remark"`
|
|
NamePinyin string `gorm:"size:400;index" json:"-"`
|
|
NameInitials string `gorm:"size:100;index" json:"-"`
|
|
|
|
Category *ProductCategory `gorm:"foreignKey:CategoryID" json:"category,omitempty"`
|
|
Images []ProductImage `gorm:"foreignKey:ProductID" json:"images,omitempty"`
|
|
}
|