package models import ( "time" "gorm.io/gorm" ) // UserAnswerRecord 用户答题记录 type UserAnswerRecord struct { gorm.Model UserID uint `gorm:"index;not null" json:"user_id"` // 用户ID QuestionID uint `gorm:"index;not null" json:"question_id"` // 题目ID IsCorrect bool `gorm:"not null" json:"is_correct"` // 是否答对 AnsweredAt time.Time `gorm:"not null" json:"answered_at"` // 答题时间 } // TableName 指定表名 func (UserAnswerRecord) TableName() string { return "user_answer_records" } // UserStatistics 用户统计数据 type UserStatistics struct { TotalQuestions int `json:"total_questions"` // 题库总数 AnsweredQuestions int `json:"answered_questions"` // 已答题数 CorrectAnswers int `json:"correct_answers"` // 答对题数 Accuracy float64 `json:"accuracy"` // 正确率 }