主要变更: - 数据库ID字段统一从 uint 改为 int64,提升数据容量和兼容性 - 重构答题检查逻辑,采用策略模式替代 switch-case - 新增 PracticeProgress 模型,支持练习进度持久化 - 优化错题本系统,自动记录答题进度和错误历史 - 添加 lib/pq PostgreSQL 驱动依赖 - 移除错题标签管理 API(待后续迁移) - 前端类型定义同步更新,适配后端模型变更 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
20 lines
644 B
Go
20 lines
644 B
Go
package models
|
|
|
|
import (
|
|
"gorm.io/datatypes"
|
|
)
|
|
|
|
// PracticeProgress 练习进度记录(每道题目一条记录)
|
|
type PracticeProgress struct {
|
|
ID int64 `gorm:"primarykey" json:"id"`
|
|
CurrentQuestionID int64 `gorm:"not null" json:"current_question_id"`
|
|
UserID int64 `gorm:"not null;uniqueIndex:idx_user_question" json:"user_id"`
|
|
Type string `gorm:"type:varchar(255);not null" json:"type"`
|
|
UserAnswerRecords datatypes.JSON `gorm:"type:jsonp" json:"answers"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (PracticeProgress) TableName() string {
|
|
return "practice_progress"
|
|
}
|