33 lines
1.7 KiB
Go
33 lines
1.7 KiB
Go
package learning
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
)
|
|
|
|
// UserExam 用户考试记录模型
|
|
type UserExam struct {
|
|
global.GVA_MODEL
|
|
UserId uint `json:"userId" form:"userId" gorm:"column:user_id;comment:关联用户ID;not null;" binding:"required"`
|
|
ExamId uint `json:"examId" form:"examId" gorm:"column:exam_id;comment:关联考试ID;not null;" binding:"required"`
|
|
AttemptNumber int `json:"attemptNumber" form:"attemptNumber" gorm:"column:attempt_number;comment:尝试次数;default:1;"`
|
|
StartTime time.Time `json:"startTime" form:"startTime" gorm:"column:start_time;comment:开始时间;"`
|
|
EndTime time.Time `json:"endTime" form:"endTime" gorm:"column:end_time;comment:结束时间;"`
|
|
Duration int `json:"duration" form:"duration" gorm:"column:duration;comment:实际用时(分钟);"`
|
|
TotalScore int `json:"totalScore" form:"totalScore" gorm:"column:total_score;comment:总得分;"`
|
|
CorrectCount int `json:"correctCount" form:"correctCount" gorm:"column:correct_count;comment:正确题目数;"`
|
|
WrongCount int `json:"wrongCount" form:"wrongCount" gorm:"column:wrong_count;comment:错误题目数;"`
|
|
Status string `json:"status" form:"status" gorm:"column:status;comment:状态;size:50;default:in_progress;"`
|
|
IsPassed bool `json:"isPassed" form:"isPassed" gorm:"column:is_passed;comment:是否通过;default:false;"`
|
|
SubmittedAt time.Time `json:"submittedAt" form:"submittedAt" gorm:"column:submitted_at;comment:提交时间;"`
|
|
|
|
// 关联关系 - 去掉外键约束,只保留逻辑关联
|
|
Exam Exam `json:"exam" gorm:"-"`
|
|
}
|
|
|
|
// TableName 设置表名
|
|
func (UserExam) TableName() string {
|
|
return "learning_user_exams"
|
|
}
|