37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"hospital-admin-api/global"
|
|
"time"
|
|
)
|
|
|
|
// HealthPackageProduct 健康包-关联商品
|
|
type HealthPackageProduct struct {
|
|
PackageProductId int64 `gorm:"column:package_product_id;type:bigint(19);comment:主键id" json:"package_product_id"`
|
|
PackageId int64 `gorm:"column:package_id;type:bigint(19);comment:健康包id" json:"package_id"`
|
|
ProductId int64 `gorm:"column:product_id;type:bigint(19);primary_key;comment:商品id" json:"product_id"`
|
|
ProductName string `gorm:"column:product_name;type:varchar(255);comment:商品名称" json:"product_name"`
|
|
Quantity int `gorm:"column:quantity;type:int(1);default:1;comment:数量" json:"quantity"`
|
|
DiscountProductPrice float64 `gorm:"column:discount_product_price;type:decimal(10,2) unsigned;default:0.00;comment:折扣商品价格" json:"discount_product_price"`
|
|
Model
|
|
}
|
|
|
|
func (m *HealthPackageProduct) TableName() string {
|
|
return "gdxz_health_package_product"
|
|
}
|
|
|
|
func (m *HealthPackageProduct) BeforeCreate(tx *gorm.DB) error {
|
|
if m.PackageProductId == 0 {
|
|
m.PackageProductId = global.Snowflake.Generate().Int64()
|
|
}
|
|
|
|
m.CreatedAt = LocalTime(time.Now())
|
|
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
|
|
|
m.UpdatedAt = LocalTime(time.Now())
|
|
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
|
|
|
return nil
|
|
}
|