47 lines
2.4 KiB
Go
47 lines
2.4 KiB
Go
package api
|
|
|
|
import (
|
|
"dd_fiber_api/internal/question/handler"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
// SetupQuestionRoutes 设置题目相关路由
|
|
func SetupQuestionRoutes(app *fiber.App, questionHandler *handler.QuestionHandler, paperHandler *handler.PaperHandler, answerRecordHandler *handler.AnswerRecordHandler) {
|
|
// 题目相关路由
|
|
question := app.Group("/api/v1/question")
|
|
{
|
|
question.Post("/create", questionHandler.CreateQuestion) // 创建题目
|
|
question.Get("/detail", questionHandler.GetQuestion) // 获取题目详情
|
|
question.Get("/search", questionHandler.SearchQuestions) // 搜索题目
|
|
question.Post("/update", questionHandler.UpdateQuestion) // 更新题目
|
|
question.Post("/delete", questionHandler.DeleteQuestion) // 删除题目
|
|
question.Post("/batch_delete", questionHandler.BatchDeleteQuestions) // 批量删除题目
|
|
}
|
|
|
|
// 试卷相关路由
|
|
paper := app.Group("/api/v1/paper")
|
|
{
|
|
paper.Post("/create", paperHandler.CreatePaper) // 创建试卷
|
|
paper.Get("/detail", paperHandler.GetPaper) // 获取试卷详情
|
|
paper.Get("/result", paperHandler.GetPaperWithAnswers) // 获取试卷详情(包含答案和解析,用于答题结果页面)
|
|
paper.Get("/search", paperHandler.SearchPapers) // 搜索试卷
|
|
paper.Post("/update", paperHandler.UpdatePaper) // 更新试卷
|
|
paper.Post("/delete", paperHandler.DeletePaper) // 删除试卷
|
|
paper.Post("/batch_delete", paperHandler.BatchDeletePapers) // 批量删除试卷
|
|
paper.Post("/add_question", paperHandler.AddQuestionToPaper) // 添加题目到试卷
|
|
paper.Post("/remove_question", paperHandler.RemoveQuestionFromPaper) // 从试卷移除题目
|
|
}
|
|
|
|
// 答题记录相关路由
|
|
answerRecord := app.Group("/api/v1/answer_record")
|
|
{
|
|
answerRecord.Post("/create", answerRecordHandler.CreateAnswerRecords) // 批量创建答题记录
|
|
answerRecord.Get("/detail", answerRecordHandler.GetAnswerRecord) // 获取答题记录
|
|
answerRecord.Get("/user", answerRecordHandler.GetUserAnswerRecord) // 获取用户答题记录
|
|
answerRecord.Get("/statistics", answerRecordHandler.GetPaperAnswerStatistics) // 获取试卷答题统计
|
|
answerRecord.Post("/delete", answerRecordHandler.DeleteAnswerRecord) // 删除答题记录
|
|
}
|
|
}
|
|
|