fix(backend): 商品编码改用最大序号生成不复用软删号 + 加 (shop_id,code) 唯一约束,根治重复编码
Deploy Server / release-deploy-server (push) Successful in 53s

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ4DskSRKsSiheQonFtQvx
This commit is contained in:
wangjia
2026-06-21 10:51:34 +08:00
parent 71ed15b40b
commit 1a1d9aa15e
6 changed files with 151 additions and 40 deletions
+2
View File
@@ -10,6 +10,8 @@ type ProductCategory struct {
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"`