Adapt to old_id
This commit is contained in:
@@ -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 != ""
|
||||
}
|
||||
Reference in New Issue
Block a user