Enhance AI and Redis integration for smoke logging features

- 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.
This commit is contained in:
nepiedg
2026-01-03 02:14:21 +00:00
parent 1c48fbdeaf
commit 16844d4a42
30 changed files with 1662 additions and 9 deletions
+29
View File
@@ -0,0 +1,29 @@
package model
import (
"time"
"gorm.io/gorm"
)
// UserMembership 表示会员订阅记录(DDL 见 docs/sql/users.sql)。
type UserMembership struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
MiniProgramID uint `gorm:"index:idx_membership_user,priority:1;index:idx_membership_status,priority:1" json:"mini_program_id"`
UserID uint `gorm:"index:idx_membership_user,priority:2;index:idx_membership_status,priority:2" json:"user_id"`
Plan string `gorm:"size:30" json:"plan"`
Status string `gorm:"size:20;index:idx_membership_status,priority:3" json:"status"`
StartsAt time.Time `json:"starts_at"`
EndsAt time.Time `gorm:"index:idx_membership_user,priority:3;index:idx_membership_status,priority:4" json:"ends_at"`
}
func (UserMembership) TableName() string {
return "user_memberships"
}