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.
30 lines
972 B
Go
30 lines
972 B
Go
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"
|
|
}
|
|
|