35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"hospital-admin-api/global"
|
|
"time"
|
|
)
|
|
|
|
// InquiryCaseProduct 问诊病例-用药意向表
|
|
type InquiryCaseProduct struct {
|
|
CaseProductId int64 `gorm:"column:case_product_id;type:bigint(19);primary_key;comment:主键id" json:"case_product_id"`
|
|
InquiryCaseId int64 `gorm:"column:inquiry_case_id;type:bigint(19);comment:病例id" json:"inquiry_case_id"`
|
|
ProductId int64 `gorm:"column:product_id;type:bigint(19);comment:商品id" json:"product_id"`
|
|
CaseProductNum int `gorm:"column:case_product_num;type:int(11);default:1;comment:药品数量" json:"case_product_num"`
|
|
Model
|
|
}
|
|
|
|
func (m *InquiryCaseProduct) TableName() string {
|
|
return "gdxz_inquiry_case_product"
|
|
}
|
|
|
|
func (m *InquiryCaseProduct) BeforeCreate(tx *gorm.DB) error {
|
|
if m.CaseProductId == 0 {
|
|
m.CaseProductId = 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
|
|
}
|