Files
wx_service/internal/smoke/model/smoke_log.go
T
nepiedg 1ad775be63 Enhance database models with comments and table descriptions
- Added comments to various fields in the database models for better clarity and understanding.
- Implemented TableComment methods for several models to provide descriptive information about their purpose.
- Updated the AutoMigrate function to support setting table comments in the database.
- Improved overall documentation within the code to facilitate future maintenance and development.
2026-01-03 02:35:11 +00:00

37 lines
1.6 KiB
Go

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"`
// 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 "抽烟记录"
}