36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-admin-api/global"
|
||
"time"
|
||
)
|
||
|
||
// OrderPrescriptionIcd 订单-处方关联疾病表
|
||
type OrderPrescriptionIcd struct {
|
||
PrescriptionIcdId int64 `gorm:"column:prescription_icd_id;type:bigint(19);primary_key;comment:主键id" json:"prescription_icd_id"`
|
||
OrderPrescriptionId int64 `gorm:"column:order_prescription_id;type:bigint(19);comment:订单-处方id" json:"order_prescription_id"`
|
||
IcdId int64 `gorm:"column:icd_id;type:bigint(19);comment:疾病id(icd)" json:"icd_id"`
|
||
IcdName string `gorm:"column:icd_name;type:varchar(255);comment:疾病名称(icd)" json:"icd_name"`
|
||
IcdCode string `gorm:"column:icd_code;type:varchar(255);comment:icd编码" json:"icd_code"`
|
||
Model
|
||
}
|
||
|
||
func (m *OrderPrescriptionIcd) TableName() string {
|
||
return "gdxz_order_prescription_icd"
|
||
}
|
||
|
||
func (m *OrderPrescriptionIcd) BeforeCreate(tx *gorm.DB) error {
|
||
if m.PrescriptionIcdId == 0 {
|
||
m.PrescriptionIcdId = 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
|
||
}
|