This commit is contained in:
2025-07-28 01:46:39 +08:00
parent b03129667a
commit 357639462a
219 changed files with 21634 additions and 8138 deletions

View File

@@ -0,0 +1,32 @@
package entities
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// ProductPackageItem 产品组合包项目
type ProductPackageItem struct {
ID string `gorm:"primaryKey;type:varchar(36)"`
PackageID string `gorm:"type:varchar(36);not null;index" comment:"组合包产品ID"`
ProductID string `gorm:"type:varchar(36);not null;index" comment:"子产品ID"`
SortOrder int `gorm:"default:0" comment:"排序"`
// 关联关系
Package *Product `gorm:"foreignKey:PackageID" comment:"组合包产品"`
Product *Product `gorm:"foreignKey:ProductID" comment:"子产品"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
DeletedAt gorm.DeletedAt `gorm:"index"`
}
// BeforeCreate GORM钩子创建前自动生成UUID
func (ppi *ProductPackageItem) BeforeCreate(tx *gorm.DB) error {
if ppi.ID == "" {
ppi.ID = uuid.New().String()
}
return nil
}