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:
@@ -9,8 +9,11 @@ type SmokeAIAdvice struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement;comment:记录ID" json:"id"`
|
||||
UID int `gorm:"column:uid;index:idx_smoke_ai_advice_uid_date,priority:1;uniqueIndex:uniq_smoke_ai_advice,priority:1" json:"-"`
|
||||
|
||||
AdviceDate time.Time `gorm:"column:advice_date;type:date;index:idx_smoke_ai_advice_uid_date,priority:2;uniqueIndex:uniq_smoke_ai_advice,priority:2;comment:建议日期" json:"advice_date"`
|
||||
PromptVersion string `gorm:"column:prompt_version;size:30;default:v1;uniqueIndex:uniq_smoke_ai_advice,priority:3;comment:提示词版本" json:"prompt_version"`
|
||||
// Type 用于区分 AI 使用场景(例如:daily_advice / next_smoke_time)。
|
||||
Type string `gorm:"column:type;size:30;default:daily_advice;index:idx_smoke_ai_advice_uid_date,priority:2;uniqueIndex:uniq_smoke_ai_advice,priority:2;comment:用途类型" json:"type"`
|
||||
|
||||
AdviceDate time.Time `gorm:"column:advice_date;type:date;index:idx_smoke_ai_advice_uid_date,priority:3;uniqueIndex:uniq_smoke_ai_advice,priority:3;comment:建议日期" json:"advice_date"`
|
||||
PromptVersion string `gorm:"column:prompt_version;size:30;default:v1;uniqueIndex:uniq_smoke_ai_advice,priority:4;comment:提示词版本" json:"prompt_version"`
|
||||
|
||||
Provider string `gorm:"column:provider;size:30;comment:AI提供方" json:"provider,omitempty"`
|
||||
Model string `gorm:"column:model;size:60;comment:模型名" json:"model,omitempty"`
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// SmokeAINextSmoke 对应表 fa_smoke_ai_next_smoke(AI 生成的“下次抽烟时间节点”)。
|
||||
//
|
||||
// 说明:
|
||||
// - 该表只保存“时间节点”本身(每个时间点一条记录),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下次抽烟时间节点"
|
||||
}
|
||||
Reference in New Issue
Block a user