package model import ( "gorm.io/gorm" "hospital-open-api/global" "time" ) // DiseaseClassExpertise 疾病分类表-医生专长 type DiseaseClassExpertise struct { ExpertiseId int64 `gorm:"column:expertise_id;type:bigint(19);primary_key;comment:主键id" json:"expertise_id"` ExpertiseName string `gorm:"column:expertise_name;type:varchar(255);comment:专长名称" json:"expertise_name"` ExpertiseSort int `gorm:"column:expertise_sort;type:int(11);default:0;comment:排序(越大排序越靠前)" json:"expertise_sort"` Model } func (m *DiseaseClassExpertise) TableName() string { return "gdxz_disease_class_expertise" } func (m *DiseaseClassExpertise) BeforeCreate(tx *gorm.DB) error { if m.ExpertiseId == 0 { m.ExpertiseId = 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 }