package model import "time" // SmokeLog 对应数据库表 fa_smoke_log(戒烟/抽烟记录)。 // // 注意:这个表的字段命名来自旧系统(createtime/updatetime/deletetime 为秒级时间戳), // 因此这里不使用 gorm.Model 的 created_at/updated_at/deleted_at。 type SmokeLog struct { // 复合主键(id, uid),其中 id 自增。 ID int `gorm:"column:id;primaryKey;autoIncrement;comment:记录ID" json:"id"` UID int `gorm:"column:uid;primaryKey" json:"-"` // smoke_time 在库里是 date 类型(只包含日期,不包含时分秒)。 SmokeTime *time.Time `gorm:"column:smoke_time;type:date;comment:抽烟日期" json:"smoke_time,omitempty"` // smoke_at:真实抽烟时间(可补录,精确到时分秒) SmokeAt *time.Time `gorm:"column:smoke_at;type:datetime;comment:真实抽烟时间(精确到秒)" json:"smoke_at,omitempty"` Remark string `gorm:"column:remark;type:text;comment:原因/备注" json:"remark,omitempty"` ReasonTags StringSlice `gorm:"column:reason_tags;type:json;comment:结构化原因标签(JSON数组)" json:"reason_tags,omitempty"` // createtime/updatetime/deletetime:秒级 Unix 时间戳(与 gorm 默认字段不同) CreateTime *int64 `gorm:"column:createtime;comment:创建时间(秒)" json:"createtime,omitempty"` UpdateTime *int64 `gorm:"column:updatetime;comment:更新时间(秒)" json:"updatetime,omitempty"` DeleteTime *int64 `gorm:"column:deletetime;comment:删除时间(秒)" json:"deletetime,omitempty"` Level int64 `gorm:"column:level;default:1;comment:烟瘾程度" json:"level"` Num int `gorm:"column:num;default:1;comment:抽烟数量" json:"num"` } func (SmokeLog) TableName() string { return "fa_smoke_log" } func (SmokeLog) TableComment() string { return "抽烟记录" }