ca7595b113
- summaryBounds:本月/近30天滚动双口径(stock-in/out Summary ?window=rolling30) - security(SEC-001):新增 ownership.go ensureShopRef 写入侧防线(stock-in/out/finance/ 盘点建单的 warehouse/partner/product 外键归属校验);读取侧全部 Preload 补 shop_id 作用域,finance Summary JOIN 补租户条件;回归测试 CrossTenantRefs - security(SEC-002):release 模式 JWT 密钥为空/默认值时拒绝启动 - gofmt 对齐若干 model/cmd 文件 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
48 lines
2.5 KiB
Go
48 lines
2.5 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 商品编码:同店内唯一。(shop_id, code) 联合唯一索引 uk_shop_code 由 autoMigrate 显式建(见 main.go),
|
|
// 不在此用 tag 声明——ShopID 在共用 TenantBase 上,tag 只能建单列索引会破坏多租户隔离。
|
|
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"`
|
|
// 特有产品的批次属性:每个 product = 一个特有产品/序列号,生产日期/批次归此(单一来源)
|
|
ProductionDate *Date `gorm:"type:date" json:"production_date"`
|
|
BatchNo string `gorm:"size:50" json:"batch_no"`
|
|
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:"-"`
|
|
|
|
// 商品属性字典外键(可空,公开页展示用)
|
|
OriginID *uint64 `json:"origin_id"`
|
|
ShelfLifeID *uint64 `json:"shelf_life_id"`
|
|
StorageID *uint64 `json:"storage_id"`
|
|
DescriptionDocID *uint64 `json:"description_doc_id"`
|
|
|
|
Category *ProductCategory `gorm:"foreignKey:CategoryID" json:"category,omitempty"`
|
|
Images []ProductImage `gorm:"foreignKey:ProductID" json:"images,omitempty"`
|
|
Origin *ProductOriginOption `gorm:"foreignKey:OriginID" json:"origin,omitempty"`
|
|
ShelfLife *ProductShelfLifeOption `gorm:"foreignKey:ShelfLifeID" json:"shelf_life,omitempty"`
|
|
Storage *ProductStorageOption `gorm:"foreignKey:StorageID" json:"storage,omitempty"`
|
|
DescriptionDoc *ProductDescriptionDoc `gorm:"foreignKey:DescriptionDocID" json:"description_doc,omitempty"`
|
|
}
|