33 lines
1.8 KiB
Go
33 lines
1.8 KiB
Go
package learning
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
|
)
|
|
|
|
// UserLearning 用户学习记录模型
|
|
type UserLearning struct {
|
|
global.GVA_MODEL
|
|
UserId uint `json:"userId" form:"userId" gorm:"column:user_id;comment:关联用户ID;not null;" binding:"required"`
|
|
CourseId uint `json:"courseId" form:"courseId" gorm:"column:course_id;comment:关联课程ID;not null;" binding:"required"`
|
|
ChapterId uint `json:"chapterId" form:"chapterId" gorm:"column:chapter_id;comment:当前学习章节ID;"`
|
|
KnowledgePointId uint `json:"knowledgePointId" form:"knowledgePointId" gorm:"column:knowledge_point_id;comment:当前学习知识点ID;"`
|
|
Progress int `json:"progress" form:"progress" gorm:"column:progress;comment:学习进度百分比;default:0;"`
|
|
StudyTime int `json:"studyTime" form:"studyTime" gorm:"column:study_time;comment:累计学习时长(分钟);default:0;"`
|
|
LastStudyAt time.Time `json:"lastStudyAt" form:"lastStudyAt" gorm:"column:last_study_at;comment:最后学习时间;"`
|
|
Status string `json:"status" form:"status" gorm:"column:status;comment:学习状态;size:50;default:not_started;"`
|
|
Score int `json:"score" form:"score" gorm:"column:score;comment:总分数;default:0;"`
|
|
CompletedAt time.Time `json:"completedAt" form:"completedAt" gorm:"column:completed_at;comment:完成时间;"`
|
|
|
|
// 关联关系 - 去掉外键约束,只保留逻辑关联
|
|
Course Course `json:"course" gorm:"-"`
|
|
Chapter Chapter `json:"chapter" gorm:"-"`
|
|
KnowledgePoint KnowledgePoint `json:"knowledgePoint" gorm:"-"`
|
|
}
|
|
|
|
// TableName 设置表名
|
|
func (UserLearning) TableName() string {
|
|
return "learning_user_learning"
|
|
}
|