5 changed files with 222 additions and 29 deletions
-
58Knowledge_Test_Go/api/v1/questionBank.go
-
30Knowledge_Test_Go/internal/cmd/cmd.go
-
63Knowledge_Test_Go/internal/controller/questionBank.go
-
1Knowledge_Test_Go/internal/logic/knowledge/knowledge.go
-
99Knowledge_Test_Go/internal/logic/questionBank/questionBank.go
@ -1 +1,64 @@ |
|||
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, |
|||
}) |
|||
} |
|||
|
|||
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, |
|||
}) |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue