16844d4a42
- Added AI configuration options to .env.example and config.go for OpenAI integration. - Implemented Redis caching for session management in main.go and auth middleware. - Updated smoke logging service to support real smoking time (`smoke_at`) and AI advice retrieval. - Enhanced API routes to include endpoints for AI advice and unlock functionality for non-members. - Improved database schema with new tables for AI advice and unlock records. - Expanded documentation to cover new AI features and Redis caching implementation.
33 lines
1.3 KiB
Go
33 lines
1.3 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" json:"id"`
|
|
UID int `gorm:"column:uid;primaryKey" json:"-"`
|
|
|
|
// smoke_time 在库里是 date 类型(只包含日期,不包含时分秒)。
|
|
SmokeTime *time.Time `gorm:"column:smoke_time;type:date" json:"smoke_time,omitempty"`
|
|
// smoke_at:真实抽烟时间(可补录,精确到时分秒)
|
|
SmokeAt *time.Time `gorm:"column:smoke_at;type:datetime" json:"smoke_at,omitempty"`
|
|
|
|
Remark string `gorm:"column:remark;type:text" json:"remark,omitempty"`
|
|
|
|
// createtime/updatetime/deletetime:秒级 Unix 时间戳(与 gorm 默认字段不同)
|
|
CreateTime *int64 `gorm:"column:createtime" json:"createtime,omitempty"`
|
|
UpdateTime *int64 `gorm:"column:updatetime" json:"updatetime,omitempty"`
|
|
DeleteTime *int64 `gorm:"column:deletetime" json:"deletetime,omitempty"`
|
|
|
|
Level int64 `gorm:"column:level;default:1" json:"level"`
|
|
Num int `gorm:"column:num;default:1" json:"num"`
|
|
}
|
|
|
|
func (SmokeLog) TableName() string {
|
|
return "fa_smoke_log"
|
|
}
|