package model import ( "gorm.io/gorm" "hospital-admin-api/global" "time" ) // DoctorWithdrawalOrder 医生提现-关联订单表 type DoctorWithdrawalOrder struct { WithdrawalOrderId int64 `gorm:"column:withdrawal_order_id;type:bigint(19);primary_key;comment:主键id" json:"withdrawal_order_id"` WithdrawalId int64 `gorm:"column:withdrawal_id;type:bigint(19);comment:提现表id;NOT NULL" json:"withdrawal_id"` DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"` OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:订单-问诊id;NOT NULL" json:"order_inquiry_id"` OrderInquiry *OrderInquiry `gorm:"foreignKey:OrderInquiryId;references:order_inquiry_id" json:"order_inquiry"` // 问诊 UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生 Model } func (m *DoctorWithdrawalOrder) TableName() string { return "gdxz_doctor_withdrawal_order" } func (m *DoctorWithdrawalOrder) BeforeCreate(tx *gorm.DB) error { if m.WithdrawalOrderId == 0 { m.WithdrawalOrderId = 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 }