hospital-admin-api/api/model/doctorExpertise.go

34 lines
923 B
Go

package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// DoctorExpertise 医生专长表
type DoctorExpertise struct {
DoctorExpertiseId int64 `gorm:"column:doctor_expertise_id;type:bigint(19);primary_key;comment:主键id" json:"doctor_expertise_id"`
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id" json:"doctor_id"`
ExpertiseId int64 `gorm:"column:expertise_id;type:bigint(19);comment:专长id" json:"expertise_id"`
Model
}
func (m *DoctorExpertise) TableName() string {
return "gdxz_doctor_expertise"
}
func (m *DoctorExpertise) BeforeCreate(tx *gorm.DB) error {
if m.DoctorExpertiseId == 0 {
m.DoctorExpertiseId = 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
}