package model import ( "apsClient/pkg/snowflake" "time" ) type CommonModel struct { ID uint `gorm:"primary_key" json:"ID,string"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` } func (c *CommonModel) BeforeCreate() { if c.ID == 0 { c.ID = uint(snowflake.GenerateID()) } }