1
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package learning
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
)
|
||||
|
||||
// Chapter 章节模型
|
||||
type Chapter struct {
|
||||
global.GVA_MODEL
|
||||
CourseId uint `json:"courseId" form:"courseId" gorm:"column:course_id;comment:关联课程ID;not null;" binding:"required"`
|
||||
Title string `json:"title" form:"title" gorm:"column:title;comment:章节标题;size:255;not null;" binding:"required"`
|
||||
Description string `json:"description" form:"description" gorm:"column:description;comment:章节描述;type:text;"`
|
||||
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序号;default:0;"`
|
||||
Status string `json:"status" form:"status" gorm:"column:status;comment:章节状态;size:50;default:draft;"`
|
||||
Duration int `json:"duration" form:"duration" gorm:"column:duration;comment:预计学习时长(分钟);default:0;"`
|
||||
|
||||
// 关联关系 - 去掉外键约束,只保留逻辑关联
|
||||
Course Course `json:"course" gorm:"-"`
|
||||
}
|
||||
|
||||
// TableName 设置表名
|
||||
func (Chapter) TableName() string {
|
||||
return "learning_chapters"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package learning
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
)
|
||||
|
||||
// Course 课程模型
|
||||
type Course struct {
|
||||
global.GVA_MODEL
|
||||
Title string `json:"title" form:"title" gorm:"column:title;comment:课程标题;size:255;not null;" binding:"required"`
|
||||
Description string `json:"description" form:"description" gorm:"column:description;comment:课程描述;type:longtext;"`
|
||||
Cover string `json:"cover" form:"cover" gorm:"column:cover;comment:课程封面图片URL;size:500;"`
|
||||
Difficulty string `json:"difficulty" form:"difficulty" gorm:"column:difficulty;comment:难度等级;size:50;default:beginner;"`
|
||||
Duration int `json:"duration" form:"duration" gorm:"column:duration;comment:预计学时(分钟);default:0;"`
|
||||
Status string `json:"status" form:"status" gorm:"column:status;comment:课程状态;size:50;default:draft;"`
|
||||
Price float64 `json:"price" form:"price" gorm:"column:price;comment:课程价格;type:decimal(10,2);default:0.00;"`
|
||||
Tags string `json:"tags" form:"tags" gorm:"column:tags;comment:课程标签,逗号分隔;size:500;"`
|
||||
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序权重;default:0;"`
|
||||
}
|
||||
|
||||
// TableName 设置表名
|
||||
func (Course) TableName() string {
|
||||
return "learning_courses"
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package learning
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
)
|
||||
|
||||
// Exam 考试模型
|
||||
type Exam struct {
|
||||
global.GVA_MODEL
|
||||
Title string `json:"title" form:"title" gorm:"column:title;comment:考试标题;size:255;not null;" binding:"required"`
|
||||
Description string `json:"description" form:"description" gorm:"column:description;comment:考试描述;type:longtext;"`
|
||||
CourseId uint `json:"courseId" form:"courseId" gorm:"column:course_id;comment:关联课程ID;"`
|
||||
Duration int `json:"duration" form:"duration" gorm:"column:duration;comment:考试时长(分钟);not null;" binding:"required"`
|
||||
TotalScore int `json:"totalScore" form:"totalScore" gorm:"column:total_score;comment:总分;not null;" binding:"required"`
|
||||
PassScore int `json:"passScore" form:"passScore" gorm:"column:pass_score;comment:及格分数;not null;" binding:"required"`
|
||||
QuestionCount int `json:"questionCount" form:"questionCount" gorm:"column:question_count;comment:题目数量;not null;" binding:"required"`
|
||||
StartTime time.Time `json:"startTime" form:"startTime" gorm:"column:start_time;comment:开始时间;"`
|
||||
EndTime time.Time `json:"endTime" form:"endTime" gorm:"column:end_time;comment:结束时间;"`
|
||||
Status string `json:"status" form:"status" gorm:"column:status;comment:考试状态;size:50;default:draft;"`
|
||||
AllowRetake bool `json:"allowRetake" form:"allowRetake" gorm:"column:allow_retake;comment:是否允许重考;default:false;"`
|
||||
MaxAttempts int `json:"maxAttempts" form:"maxAttempts" gorm:"column:max_attempts;comment:最大尝试次数;default:1;"`
|
||||
|
||||
// 关联关系 - 去掉外键约束,只保留逻辑关联
|
||||
Course Course `json:"course" gorm:"-"`
|
||||
}
|
||||
|
||||
// TableName 设置表名
|
||||
func (Exam) TableName() string {
|
||||
return "learning_exams"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package learning
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
)
|
||||
|
||||
// KnowledgePoint 知识点模型
|
||||
type KnowledgePoint struct {
|
||||
global.GVA_MODEL
|
||||
ChapterId uint `json:"chapterId" form:"chapterId" gorm:"column:chapter_id;comment:关联章节ID;not null;" binding:"required"`
|
||||
Title string `json:"title" form:"title" gorm:"column:title;comment:知识点标题;size:255;not null;" binding:"required"`
|
||||
Content string `json:"content" form:"content" gorm:"column:content;comment:知识点内容;type:longtext;"`
|
||||
VideoUrl string `json:"videoUrl" form:"videoUrl" gorm:"column:video_url;comment:视频链接;size:500;"`
|
||||
Attachments string `json:"attachments" form:"attachments" gorm:"column:attachments;comment:附件信息JSON;type:text;"`
|
||||
Sort int `json:"sort" form:"sort" gorm:"column:sort;comment:排序号;default:0;"`
|
||||
Duration int `json:"duration" form:"duration" gorm:"column:duration;comment:预计学习时长(分钟);default:0;"`
|
||||
Status string `json:"status" form:"status" gorm:"column:status;comment:知识点状态;size:50;default:draft;"`
|
||||
|
||||
// 关联关系 - 去掉外键约束,只保留逻辑关联
|
||||
Chapter Chapter `json:"chapter" gorm:"-"`
|
||||
}
|
||||
|
||||
// TableName 设置表名
|
||||
func (KnowledgePoint) TableName() string {
|
||||
return "learning_knowledge_points"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package learning
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
)
|
||||
|
||||
// Question 题目模型
|
||||
type Question struct {
|
||||
global.GVA_MODEL
|
||||
KnowledgePointId uint `json:"knowledgePointId" form:"knowledgePointId" gorm:"column:knowledge_point_id;comment:关联知识点ID;not null;" binding:"required"`
|
||||
Title string `json:"title" form:"title" gorm:"column:title;comment:题目标题;size:255;not null;" binding:"required"`
|
||||
Content string `json:"content" form:"content" gorm:"column:content;comment:题目内容;type:longtext;"`
|
||||
Type string `json:"type" form:"type" gorm:"column:type;comment:题目类型;size:50;not null;" binding:"required"`
|
||||
Options string `json:"options" form:"options" gorm:"column:options;comment:选项内容JSON;type:text;"`
|
||||
Answer string `json:"answer" form:"answer" gorm:"column:answer;comment:正确答案;type:text;not null;" binding:"required"`
|
||||
Explanation string `json:"explanation" form:"explanation" gorm:"column:explanation;comment:答案解析;type:longtext;"`
|
||||
Difficulty string `json:"difficulty" form:"difficulty" gorm:"column:difficulty;comment:难度等级;size:50;default:medium;"`
|
||||
Score int `json:"score" form:"score" gorm:"column:score;comment:题目分值;default:5;"`
|
||||
|
||||
// 关联关系 - 去掉外键约束,只保留逻辑关联
|
||||
KnowledgePoint KnowledgePoint `json:"knowledgePoint" gorm:"-"`
|
||||
}
|
||||
|
||||
// TableName 设置表名
|
||||
func (Question) TableName() string {
|
||||
return "learning_questions"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/learning"
|
||||
)
|
||||
|
||||
type ChapterSearch struct {
|
||||
learning.Chapter
|
||||
request.PageInfo
|
||||
StartCreatedAt *string `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *string `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
}
|
||||
|
||||
type ChapterCreate struct {
|
||||
CourseId uint `json:"courseId" binding:"required"`
|
||||
Title string `json:"title" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
Sort int `json:"sort"`
|
||||
Status string `json:"status"`
|
||||
Duration int `json:"duration"`
|
||||
}
|
||||
|
||||
type ChapterUpdate struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
CourseId uint `json:"courseId" binding:"required"`
|
||||
Title string `json:"title" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
Sort int `json:"sort"`
|
||||
Status string `json:"status"`
|
||||
Duration int `json:"duration"`
|
||||
}
|
||||
|
||||
type ChaptersByCourseRequest struct {
|
||||
CourseId uint `json:"courseId" form:"courseId" binding:"required"`
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/learning"
|
||||
)
|
||||
|
||||
type CourseSearch struct {
|
||||
learning.Course
|
||||
request.PageInfo
|
||||
StartCreatedAt *string `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *string `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
}
|
||||
|
||||
type CourseCreate struct {
|
||||
Title string `json:"title" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
Cover string `json:"cover"`
|
||||
Difficulty string `json:"difficulty"`
|
||||
Duration int `json:"duration"`
|
||||
Status string `json:"status"`
|
||||
Price float64 `json:"price"`
|
||||
Tags string `json:"tags"`
|
||||
Sort int `json:"sort"`
|
||||
}
|
||||
|
||||
type CourseUpdate struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
Title string `json:"title" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
Cover string `json:"cover"`
|
||||
Difficulty string `json:"difficulty"`
|
||||
Duration int `json:"duration"`
|
||||
Status string `json:"status"`
|
||||
Price float64 `json:"price"`
|
||||
Tags string `json:"tags"`
|
||||
Sort int `json:"sort"`
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/learning"
|
||||
)
|
||||
|
||||
type ExamSearch struct {
|
||||
learning.Exam
|
||||
request.PageInfo
|
||||
StartCreatedAt *string `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *string `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
}
|
||||
|
||||
type ExamCreate struct {
|
||||
Title string `json:"title" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
CourseId uint `json:"courseId"`
|
||||
Duration int `json:"duration" binding:"required"`
|
||||
TotalScore int `json:"totalScore" binding:"required"`
|
||||
PassScore int `json:"passScore" binding:"required"`
|
||||
QuestionCount int `json:"questionCount" binding:"required"`
|
||||
StartTime time.Time `json:"startTime"`
|
||||
EndTime time.Time `json:"endTime"`
|
||||
Status string `json:"status"`
|
||||
AllowRetake bool `json:"allowRetake"`
|
||||
MaxAttempts int `json:"maxAttempts"`
|
||||
}
|
||||
|
||||
type ExamUpdate struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
Title string `json:"title" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
CourseId uint `json:"courseId"`
|
||||
Duration int `json:"duration" binding:"required"`
|
||||
TotalScore int `json:"totalScore" binding:"required"`
|
||||
PassScore int `json:"passScore" binding:"required"`
|
||||
QuestionCount int `json:"questionCount" binding:"required"`
|
||||
StartTime time.Time `json:"startTime"`
|
||||
EndTime time.Time `json:"endTime"`
|
||||
Status string `json:"status"`
|
||||
AllowRetake bool `json:"allowRetake"`
|
||||
MaxAttempts int `json:"maxAttempts"`
|
||||
}
|
||||
|
||||
type ExamStatistics struct {
|
||||
TotalExams int `json:"totalExams"` // 总考试数
|
||||
ActiveExams int `json:"activeExams"` // 进行中的考试数
|
||||
CompletedExams int `json:"completedExams"` // 已结束的考试数
|
||||
DraftExams int `json:"draftExams"` // 草稿考试数
|
||||
}
|
||||
|
||||
type PublishExamRequest struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
}
|
||||
|
||||
type ExamQuestionConfig struct {
|
||||
ExamId uint `json:"examId" binding:"required"`
|
||||
QuestionId uint `json:"questionId" binding:"required"`
|
||||
Score int `json:"score" binding:"required"`
|
||||
QuestionOrder int `json:"questionOrder"`
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/learning"
|
||||
)
|
||||
|
||||
type KnowledgePointSearch struct {
|
||||
learning.KnowledgePoint
|
||||
request.PageInfo
|
||||
StartCreatedAt *string `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *string `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
}
|
||||
|
||||
type KnowledgePointCreate struct {
|
||||
ChapterId uint `json:"chapterId" binding:"required"`
|
||||
Title string `json:"title" binding:"required"`
|
||||
Content string `json:"content"`
|
||||
VideoUrl string `json:"videoUrl"`
|
||||
Attachments string `json:"attachments"`
|
||||
Sort int `json:"sort"`
|
||||
Duration int `json:"duration"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type KnowledgePointUpdate struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
ChapterId uint `json:"chapterId" binding:"required"`
|
||||
Title string `json:"title" binding:"required"`
|
||||
Content string `json:"content"`
|
||||
VideoUrl string `json:"videoUrl"`
|
||||
Attachments string `json:"attachments"`
|
||||
Sort int `json:"sort"`
|
||||
Duration int `json:"duration"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type KnowledgePointsByChapterRequest struct {
|
||||
ChapterId uint `json:"chapterId" form:"chapterId" binding:"required"`
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/learning"
|
||||
)
|
||||
|
||||
type QuestionSearch struct {
|
||||
learning.Question
|
||||
request.PageInfo
|
||||
StartCreatedAt *string `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *string `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
}
|
||||
|
||||
type QuestionCreate struct {
|
||||
KnowledgePointId uint `json:"knowledgePointId" binding:"required"`
|
||||
Title string `json:"title" binding:"required"`
|
||||
Content string `json:"content"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
Options string `json:"options"`
|
||||
Answer string `json:"answer" binding:"required"`
|
||||
Explanation string `json:"explanation"`
|
||||
Difficulty string `json:"difficulty"`
|
||||
Score int `json:"score"`
|
||||
}
|
||||
|
||||
type QuestionUpdate struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
KnowledgePointId uint `json:"knowledgePointId" binding:"required"`
|
||||
Title string `json:"title" binding:"required"`
|
||||
Content string `json:"content"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
Options string `json:"options"`
|
||||
Answer string `json:"answer" binding:"required"`
|
||||
Explanation string `json:"explanation"`
|
||||
Difficulty string `json:"difficulty"`
|
||||
Score int `json:"score"`
|
||||
}
|
||||
|
||||
type QuestionsByKnowledgePointRequest struct {
|
||||
KnowledgePointId uint `json:"knowledgePointId" form:"knowledgePointId" binding:"required"`
|
||||
}
|
||||
|
||||
// QuestionOption 题目选项结构
|
||||
type QuestionOption struct {
|
||||
Key string `json:"key"` // 选项标识 A、B、C、D
|
||||
Value string `json:"value"` // 选项内容
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/learning"
|
||||
)
|
||||
|
||||
type UserExamSearch struct {
|
||||
learning.UserExam
|
||||
request.PageInfo
|
||||
StartCreatedAt *string `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *string `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
}
|
||||
|
||||
type UserExamCreate struct {
|
||||
UserId uint `json:"userId" binding:"required"`
|
||||
ExamId uint `json:"examId" binding:"required"`
|
||||
AttemptNumber int `json:"attemptNumber"`
|
||||
StartTime time.Time `json:"startTime"`
|
||||
EndTime time.Time `json:"endTime"`
|
||||
Duration int `json:"duration"`
|
||||
TotalScore int `json:"totalScore"`
|
||||
CorrectCount int `json:"correctCount"`
|
||||
WrongCount int `json:"wrongCount"`
|
||||
Status string `json:"status"`
|
||||
IsPassed bool `json:"isPassed"`
|
||||
SubmittedAt time.Time `json:"submittedAt"`
|
||||
}
|
||||
|
||||
type UserExamUpdate struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
UserId uint `json:"userId" binding:"required"`
|
||||
ExamId uint `json:"examId" binding:"required"`
|
||||
AttemptNumber int `json:"attemptNumber"`
|
||||
StartTime time.Time `json:"startTime"`
|
||||
EndTime time.Time `json:"endTime"`
|
||||
Duration int `json:"duration"`
|
||||
TotalScore int `json:"totalScore"`
|
||||
CorrectCount int `json:"correctCount"`
|
||||
WrongCount int `json:"wrongCount"`
|
||||
Status string `json:"status"`
|
||||
IsPassed bool `json:"isPassed"`
|
||||
SubmittedAt time.Time `json:"submittedAt"`
|
||||
}
|
||||
|
||||
type StartExamRequest struct {
|
||||
ExamId uint `json:"examId" binding:"required"`
|
||||
UserId uint `json:"userId" binding:"required"`
|
||||
}
|
||||
|
||||
type SubmitExamRequest struct {
|
||||
UserExamId uint `json:"userExamId" binding:"required"`
|
||||
TotalScore int `json:"totalScore"`
|
||||
CorrectCount int `json:"correctCount"`
|
||||
WrongCount int `json:"wrongCount"`
|
||||
}
|
||||
|
||||
type UserExamStatistics struct {
|
||||
TotalExams int `json:"totalExams"` // 总考试次数
|
||||
PassedExams int `json:"passedExams"` // 通过考试次数
|
||||
FailedExams int `json:"failedExams"` // 未通过考试次数
|
||||
AverageScore float64 `json:"averageScore"` // 平均分数
|
||||
HighestScore int `json:"highestScore"` // 最高分数
|
||||
TotalStudyTime int `json:"totalStudyTime"` // 总学习时间(分钟)
|
||||
PassRate float64 `json:"passRate"` // 通过率
|
||||
}
|
||||
|
||||
type ExamRankingItem struct {
|
||||
UserId uint `json:"userId"`
|
||||
UserName string `json:"userName"`
|
||||
Score int `json:"score"`
|
||||
Duration int `json:"duration"`
|
||||
Rank int `json:"rank"`
|
||||
IsPassed bool `json:"isPassed"`
|
||||
SubmittedAt time.Time `json:"submittedAt"`
|
||||
}
|
||||
|
||||
type ExamRankingResponse struct {
|
||||
ExamId uint `json:"examId"`
|
||||
ExamTitle string `json:"examTitle"`
|
||||
Rankings []ExamRankingItem `json:"rankings"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/learning"
|
||||
)
|
||||
|
||||
type UserLearningSearch struct {
|
||||
learning.UserLearning
|
||||
request.PageInfo
|
||||
StartCreatedAt *string `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *string `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
}
|
||||
|
||||
type UserLearningCreate struct {
|
||||
UserId uint `json:"userId" binding:"required"`
|
||||
CourseId uint `json:"courseId" binding:"required"`
|
||||
ChapterId uint `json:"chapterId"`
|
||||
KnowledgePointId uint `json:"knowledgePointId"`
|
||||
Progress int `json:"progress"`
|
||||
StudyTime int `json:"studyTime"`
|
||||
LastStudyAt time.Time `json:"lastStudyAt"`
|
||||
Status string `json:"status"`
|
||||
Score int `json:"score"`
|
||||
CompletedAt time.Time `json:"completedAt"`
|
||||
}
|
||||
|
||||
type UserLearningUpdate struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
UserId uint `json:"userId" binding:"required"`
|
||||
CourseId uint `json:"courseId" binding:"required"`
|
||||
ChapterId uint `json:"chapterId"`
|
||||
KnowledgePointId uint `json:"knowledgePointId"`
|
||||
Progress int `json:"progress"`
|
||||
StudyTime int `json:"studyTime"`
|
||||
LastStudyAt time.Time `json:"lastStudyAt"`
|
||||
Status string `json:"status"`
|
||||
Score int `json:"score"`
|
||||
CompletedAt time.Time `json:"completedAt"`
|
||||
}
|
||||
|
||||
type UserProgressRequest struct {
|
||||
UserId uint `json:"userId" form:"userId" binding:"required"`
|
||||
CourseId uint `json:"courseId" form:"courseId"`
|
||||
}
|
||||
|
||||
type LearningStatistics struct {
|
||||
TotalCourses int `json:"totalCourses"` // 总课程数
|
||||
CompletedCourses int `json:"completedCourses"` // 已完成课程数
|
||||
InProgressCourses int `json:"inProgressCourses"` // 学习中课程数
|
||||
TotalStudyTime int `json:"totalStudyTime"` // 总学习时长
|
||||
AverageScore int `json:"averageScore"` // 平均分数
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/learning"
|
||||
)
|
||||
|
||||
type WrongQuestionSearch struct {
|
||||
learning.WrongQuestion
|
||||
request.PageInfo
|
||||
StartCreatedAt *string `json:"startCreatedAt" form:"startCreatedAt"`
|
||||
EndCreatedAt *string `json:"endCreatedAt" form:"endCreatedAt"`
|
||||
}
|
||||
|
||||
type WrongQuestionCreate struct {
|
||||
UserId uint `json:"userId" binding:"required"`
|
||||
QuestionId uint `json:"questionId" binding:"required"`
|
||||
WrongAnswer string `json:"wrongAnswer"`
|
||||
WrongCount int `json:"wrongCount"`
|
||||
LastWrongAt time.Time `json:"lastWrongAt"`
|
||||
IsMastered bool `json:"isMastered"`
|
||||
MasteredAt time.Time `json:"masteredAt"`
|
||||
Notes string `json:"notes"`
|
||||
}
|
||||
|
||||
type WrongQuestionUpdate struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
UserId uint `json:"userId" binding:"required"`
|
||||
QuestionId uint `json:"questionId" binding:"required"`
|
||||
WrongAnswer string `json:"wrongAnswer"`
|
||||
WrongCount int `json:"wrongCount"`
|
||||
LastWrongAt time.Time `json:"lastWrongAt"`
|
||||
IsMastered bool `json:"isMastered"`
|
||||
MasteredAt time.Time `json:"masteredAt"`
|
||||
Notes string `json:"notes"`
|
||||
}
|
||||
|
||||
type WrongQuestionStatistics struct {
|
||||
TotalWrongQuestions int `json:"totalWrongQuestions"` // 总错题数
|
||||
MasteredQuestions int `json:"masteredQuestions"` // 已掌握题目数
|
||||
UnmasteredQuestions int `json:"unmasteredQuestions"` // 未掌握题目数
|
||||
AverageWrongCount int `json:"averageWrongCount"` // 平均错误次数
|
||||
}
|
||||
|
||||
type MarkMasteredRequest struct {
|
||||
ID uint `json:"id" binding:"required"`
|
||||
UserId uint `json:"userId" binding:"required"`
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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"
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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"
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package learning
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
)
|
||||
|
||||
// WrongQuestion 错题本模型
|
||||
type WrongQuestion struct {
|
||||
global.GVA_MODEL
|
||||
UserId uint `json:"userId" form:"userId" gorm:"column:user_id;comment:关联用户ID;not null;" binding:"required"`
|
||||
QuestionId uint `json:"questionId" form:"questionId" gorm:"column:question_id;comment:关联题目ID;not null;" binding:"required"`
|
||||
WrongAnswer string `json:"wrongAnswer" form:"wrongAnswer" gorm:"column:wrong_answer;comment:错误答案;type:text;"`
|
||||
WrongCount int `json:"wrongCount" form:"wrongCount" gorm:"column:wrong_count;comment:错误次数;default:1;"`
|
||||
LastWrongAt time.Time `json:"lastWrongAt" form:"lastWrongAt" gorm:"column:last_wrong_at;comment:最后错误时间;"`
|
||||
IsMastered bool `json:"isMastered" form:"isMastered" gorm:"column:is_mastered;comment:是否已掌握;default:false;"`
|
||||
MasteredAt time.Time `json:"masteredAt" form:"masteredAt" gorm:"column:mastered_at;comment:掌握时间;"`
|
||||
Notes string `json:"notes" form:"notes" gorm:"column:notes;comment:用户笔记;type:longtext;"`
|
||||
|
||||
// 关联关系 - 去掉外键约束,只保留逻辑关联
|
||||
Question Question `json:"question" gorm:"-"`
|
||||
}
|
||||
|
||||
// TableName 设置表名
|
||||
func (WrongQuestion) TableName() string {
|
||||
return "learning_wrong_questions"
|
||||
}
|
||||
Reference in New Issue
Block a user