You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

52 lines
2.0 KiB

package cmd
import (
"Knowledge_Test_Go/internal/controller"
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd"
)
var (
Main = gcmd.Command{
Name: "main",
Usage: "main",
Brief: "start http server",
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
s := g.Server()
// 前台路由组 - 知识测评
s.Group("/api", func(group *ghttp.RouterGroup) {
group.Middleware(
ghttp.MiddlewareHandlerResponse,
ghttp.MiddlewareCORS,
)
group.POST("/knowledge/questions", controller.NewKnowledgeTest().GetQuestions) // 获取题目列表
group.POST("/knowledge/submit", controller.NewKnowledgeTest().SubmitAnswers) // 提交答案
group.POST("/knowledge/scores", controller.NewKnowledgeTest().GetUserScores) // 获取用户成绩
group.POST("/knowledge/wrongQuestions", controller.NewKnowledgeTest().GetWrongQuestions) // 获取错题列表
group.POST("/knowledge/course", controller.NewKnowledgeTest().GetCourse) // 获取课程
})
// 后台路由组
s.Group("/admin", func(group *ghttp.RouterGroup) {
group.Middleware(
ghttp.MiddlewareHandlerResponse,
ghttp.MiddlewareCORS,
)
group.POST("/questions/get", controller.NewQuestionBank().GetQuestions) // 获取题目列表
group.POST("/questions/update", controller.NewQuestionBank().QuestionUpdate) // 新增修改题目
group.POST("/questions/del", controller.NewQuestionBank().QuestionDel) // 删除题目
group.POST("/user/score", controller.NewQuestionBank().UserScoreOutput) // 获取用户成绩
group.POST("/questions/user", controller.NewQuestionBank().ErrorOutPutUser) // 获取错题用户列表
group.POST("/questions/export", controller.NewQuestionBank().ExportQuestion) // 导出题目数据到 Excel
group.POST("/user/export", controller.NewQuestionBank().ExportUserScore) //导出用户成绩到 Excel
})
s.Run()
return nil
},
}
)