hospital-admin-api/api/model/productPlatformAmount.go
2023-12-21 15:16:20 +08:00

35 lines
1.1 KiB
Go

package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// ProductPlatformAmount 商品-库存表-处方平台
type ProductPlatformAmount struct {
AmountId int64 `gorm:"column:amount_id;type:bigint(19);primary_key;comment:主键id" json:"amount_id"`
ProductPlatformId int64 `gorm:"column:product_platform_id;type:bigint(19);comment:处方平台商品id" json:"product_platform_id"`
ProductPlatformCode string `gorm:"column:product_platform_code;type:varchar(100);comment:处方平台商品编码" json:"product_platform_code"`
Stock uint `gorm:"column:stock;type:int(11) unsigned;default:0;comment:现有库存" json:"stock"`
Model
}
func (m *ProductPlatformAmount) TableName() string {
return "gdxz_product_platform_amount"
}
func (m *ProductPlatformAmount) BeforeCreate(tx *gorm.DB) error {
if m.AmountId == 0 {
m.AmountId = 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
}