package model import ( "gorm.io/gorm" "hepa-calc-api/global" "time" ) // BaseDiseaseClass 基础-疾病分类 type BaseDiseaseClass struct { DiseaseClassId int64 `gorm:"column:disease_class_id;type:bigint(19);primary_key;comment:主键id" json:"disease_class_id"` AppIden string `gorm:"column:app_iden;type:varchar(50);comment:app唯一标识" json:"app_iden"` DiseaseClassName string `gorm:"column:disease_class_name;type:varchar(255);comment:疾病分类名称" json:"disease_class_name"` Sort int `gorm:"column:sort;type:int(5);default:0;comment:排序值" json:"sort"` Model } func (m *BaseDiseaseClass) TableName() string { return "base_disease_class" } func (m *BaseDiseaseClass) BeforeCreate(tx *gorm.DB) error { if m.DiseaseClassId == 0 { m.DiseaseClassId = 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 }