Adapt to old_id

This commit is contained in:
2025-08-02 20:44:09 +08:00
parent 719cd14269
commit 14c3a23752
7 changed files with 72 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import (
// Product 产品实体
type Product struct {
ID string `gorm:"primaryKey;type:varchar(36)" comment:"产品ID"`
OldID *string `gorm:"type:varchar(36);index" comment:"旧产品ID用于兼容"`
Name string `gorm:"type:varchar(100);not null" comment:"产品名称"`
Code string `gorm:"type:varchar(50);uniqueIndex;not null" comment:"产品编号"`
Description string `gorm:"type:text" comment:"产品简介"`
@@ -94,4 +95,22 @@ func (p *Product) SetAsPackage() {
func (p *Product) IsCombo() bool {
return p.IsPackage
}
// SetOldID 设置旧ID
func (p *Product) SetOldID(oldID string) {
p.OldID = &oldID
}
// GetOldID 获取旧ID
func (p *Product) GetOldID() string {
if p.OldID != nil {
return *p.OldID
}
return ""
}
// HasOldID 检查是否有旧ID
func (p *Product) HasOldID() bool {
return p.OldID != nil && *p.OldID != ""
}