Files
wx_service/internal/smoke/model/smoke_ai.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

58 lines
3.0 KiB
Go

package model
import "time"
// SmokeAIAdvice 对应表 fa_smoke_ai_advice(每日 AI 戒烟建议缓存)。
//
// 注意:沿用旧系统字段(createtime/updatetime/deletetime 为秒级时间戳),不使用 gorm.Model。
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"`
Provider string `gorm:"column:provider;size:30;comment:AI提供方" json:"provider,omitempty"`
Model string `gorm:"column:model;size:60;comment:模型名" json:"model,omitempty"`
InputSnapshot []byte `gorm:"column:input_snapshot;type:json;comment:输入快照(JSON)" json:"input_snapshot,omitempty"`
Advice string `gorm:"column:advice;type:mediumtext;comment:AI建议内容" json:"advice"`
TokensIn *int `gorm:"column:tokens_in;comment:输入tokens" json:"tokens_in,omitempty"`
TokensOut *int `gorm:"column:tokens_out;comment:输出tokens" json:"tokens_out,omitempty"`
CostCent *int `gorm:"column:cost_cent;comment:成本(分)" json:"cost_cent,omitempty"`
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 (SmokeAIAdvice) TableName() string {
return "fa_smoke_ai_advice"
}
func (SmokeAIAdvice) TableComment() string {
return "每日AI戒烟建议"
}
// SmokeAIAdviceUnlock 对应表 fa_smoke_ai_advice_unlocks(非会员用户的每日广告解锁记录)。
type SmokeAIAdviceUnlock struct {
ID uint `gorm:"primaryKey;autoIncrement;comment:记录ID" json:"id"`
UID int `gorm:"column:uid;index:idx_smoke_ai_unlock_uid_date,priority:1;uniqueIndex:uniq_smoke_ai_unlock,priority:1" json:"-"`
UnlockDate time.Time `gorm:"column:unlock_date;type:date;index:idx_smoke_ai_unlock_uid_date,priority:2;uniqueIndex:uniq_smoke_ai_unlock,priority:2;comment:解锁日期" json:"unlock_date"`
AdWatchedAt time.Time `gorm:"column:ad_watched_at;comment:广告完成时间" json:"ad_watched_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 (SmokeAIAdviceUnlock) TableName() string {
return "fa_smoke_ai_advice_unlocks"
}
func (SmokeAIAdviceUnlock) TableComment() string {
return "AI戒烟建议-广告解锁"
}