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.
 
 
 

109 lines
2.7 KiB

package controller
import (
"Knowledge_Test_Go/api/v1"
"Knowledge_Test_Go/internal/service"
"Knowledge_Test_Go/utility/response"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
type cQuestionBank struct{}
func NewQuestionBank() *cQuestionBank {
return &cQuestionBank{}
}
// GetQuestions 获取题目列表
func (c *cQuestionBank) GetQuestions(r *ghttp.Request) {
ctx := r.GetCtx()
var req *v1.QuestionOutputReq
if err := r.Parse(&req); err != nil {
response.JsonExit(r, 400, err.Error())
}
res, total, err := service.QuestionBank().GetQuestions(ctx, req)
if err != nil {
response.JsonExit(r, 400, err.Error())
}
response.JsonExit(r, 200, "success", g.Map{
"list": res,
"total": total,
})
}
// QuestionUpdate 获取题目列表
func (c *cQuestionBank) QuestionUpdate(r *ghttp.Request) {
ctx := r.GetCtx()
var req *v1.QuestionUpdateReq
if err := r.Parse(&req); err != nil {
response.JsonExit(r, 400, err.Error())
}
res, err := service.QuestionBank().QuestionUpdate(ctx, req)
if err != nil {
response.JsonExit(r, 400, err.Error())
}
response.JsonExit(r, 200, "success", g.Map{
"list": res,
})
}
// QuestionDel 删除题目
func (c *cQuestionBank) QuestionDel(r *ghttp.Request) {
ctx := r.GetCtx()
var req *v1.QuestionDelReq
if err := r.Parse(&req); err != nil {
response.JsonExit(r, 400, err.Error())
}
res, err := service.QuestionBank().QuestionDel(ctx, req)
if err != nil {
response.JsonExit(r, 400, err.Error())
}
response.JsonExit(r, 200, "success", g.Map{
"list": res,
})
}
// UserScoreOutput 获取用户成绩列表
func (c *cQuestionBank) UserScoreOutput(r *ghttp.Request) {
ctx := r.GetCtx()
var req *v1.UserScoreOutputReq
if err := r.Parse(&req); err != nil {
response.JsonExit(r, 400, err.Error())
}
res, total, err := service.QuestionBank().UserScoreOutput(ctx, req)
if err != nil {
response.JsonExit(r, 400, err.Error())
}
response.JsonExit(r, 200, "success", g.Map{
"list": res,
"total": total,
})
}
// ErrorOutPutUser 错题统计出错用户
func (c *cQuestionBank) ErrorOutPutUser(r *ghttp.Request) {
ctx := r.GetCtx()
var req *v1.ErrorOutPutUserReq
if err := r.Parse(&req); err != nil {
response.JsonExit(r, 400, err.Error())
}
res, total, err := service.QuestionBank().ErrorOutPutUser(ctx, req)
if err != nil {
response.JsonExit(r, 400, err.Error())
}
response.JsonExit(r, 200, "success", g.Map{
"list": res,
"total": total,
})
}
// ExportQuestion 导出题目数据到 Excel
func (c *cQuestionBank) ExportQuestion(r *ghttp.Request) {
ctx := r.GetCtx()
var req *v1.QuestionOutputReq
if err := r.Parse(&req); err != nil {
response.JsonExit(r, 400, err.Error())
}
service.QuestionBank().ExportQuestion(r, ctx, req)
}