Enhance smoking tracking features with AI next smoke time suggestions

- Added new API endpoint `GET /api/v1/smoke/next_smoke_time` to provide AI-generated suggestions for the next smoking time based on user data.
- Introduced a new database table `fa_smoke_ai_next_smoke` to store structured AI time node suggestions.
- Updated smoke handler and service to integrate the new AI next smoke time functionality.
- Enhanced documentation to reflect the new API endpoint and its usage, including details on how to generate AI time nodes.
This commit is contained in:
nepiedg
2026-01-20 07:08:52 +00:00
parent dc54c4e934
commit 6cf7eb2294
15 changed files with 1394 additions and 27 deletions
@@ -0,0 +1,32 @@
package model
import "time"
// SmokeAINextSmoke 对应表 fa_smoke_ai_next_smokeAI 生成的“下次抽烟时间节点”)。
//
// 说明:
// - 该表只保存“时间节点”本身(每个时间点一条记录),AI 元信息复用 fa_smoke_ai_advice(通过 AIAdviceID 关联)。
// - 沿用旧系统字段(createtime/updatetime/deletetime 为秒级时间戳),不使用 gorm.Model。
type SmokeAINextSmoke struct {
ID uint `gorm:"primaryKey;autoIncrement;comment:记录ID" json:"id"`
UID int `gorm:"column:uid;index:idx_smoke_ai_next_uid_date,priority:1;comment:用户ID" json:"-"`
PlanDate time.Time `gorm:"column:plan_date;type:date;index:idx_smoke_ai_next_uid_date,priority:2;comment:计划日期(当天)" json:"plan_date"`
AIAdviceID uint `gorm:"column:ai_advice_id;index:idx_smoke_ai_next_advice,priority:1;comment:关联AI建议ID(fa_smoke_ai_advice.id)" json:"ai_advice_id"`
// NodeType: not_before / suggested / node
NodeType string `gorm:"column:node_type;size:20;index:idx_smoke_ai_next_advice,priority:2;uniqueIndex:uniq_smoke_ai_next_node,priority:2;comment:节点类型" json:"node_type"`
NodeAt time.Time `gorm:"column:node_at;type:datetime;uniqueIndex:uniq_smoke_ai_next_node,priority:3;comment:时间点" json:"node_at"`
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"`
}
func (SmokeAINextSmoke) TableName() string {
return "fa_smoke_ai_next_smoke"
}
func (SmokeAINextSmoke) TableComment() string {
return "AI下次抽烟时间节点"
}