Browse Source

11.14

补充后台的跨域
wangguixi/feature-20251107144650-股票知识测评
wangguixi 2 months ago
parent
commit
f88b3e27e6
  1. 1
      Knowledge_Test_Go/internal/cmd/cmd.go
  2. 18
      Knowledge_Test_Go/internal/controller/knowledge.go
  3. 20
      Knowledge_Test_Go/internal/controller/questionBank.go

1
Knowledge_Test_Go/internal/cmd/cmd.go

@ -34,6 +34,7 @@ var (
s.Group("/admin", func(group *ghttp.RouterGroup) { s.Group("/admin", func(group *ghttp.RouterGroup) {
group.Middleware( group.Middleware(
ghttp.MiddlewareHandlerResponse, ghttp.MiddlewareHandlerResponse,
ghttp.MiddlewareCORS,
) )
group.POST("/questions/get", controller.NewQuestionBank().GetQuestions) // 获取题目列表 group.POST("/questions/get", controller.NewQuestionBank().GetQuestions) // 获取题目列表
group.POST("/questions/update", controller.NewQuestionBank().QuestionUpdate) // 新增修改题目 group.POST("/questions/update", controller.NewQuestionBank().QuestionUpdate) // 新增修改题目

18
Knowledge_Test_Go/internal/controller/knowledge.go

@ -9,14 +9,14 @@ import (
"github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/ghttp"
) )
type cKnowledgeTest struct{}
type CKnowledgeTest struct{}
func NewKnowledgeTest() *cKnowledgeTest {
return &cKnowledgeTest{}
func NewKnowledgeTest() *CKnowledgeTest {
return &CKnowledgeTest{}
} }
// GetQuestions 获取题目列表 // GetQuestions 获取题目列表
func (c *cKnowledgeTest) GetQuestions(r *ghttp.Request) {
func (c *CKnowledgeTest) GetQuestions(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.GetQuestionsReq var req *v1.GetQuestionsReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -33,7 +33,7 @@ func (c *cKnowledgeTest) GetQuestions(r *ghttp.Request) {
} }
// GetUserScores 获取用户成绩 // GetUserScores 获取用户成绩
func (c *cKnowledgeTest) GetUserScores(r *ghttp.Request) {
func (c *CKnowledgeTest) GetUserScores(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.GetUserScoresReq var req *v1.GetUserScoresReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -46,8 +46,8 @@ func (c *cKnowledgeTest) GetUserScores(r *ghttp.Request) {
response.JsonExit(r, 200, "success", res) response.JsonExit(r, 200, "success", res)
} }
// GetScores 获取课程推荐
func (c *cKnowledgeTest) GetCourse(r *ghttp.Request) {
// GetCourse 获取用户课程
func (c *CKnowledgeTest) GetCourse(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.GetCourseReq var req *v1.GetCourseReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -61,7 +61,7 @@ func (c *cKnowledgeTest) GetCourse(r *ghttp.Request) {
} }
// SubmitAnswers 提交答案 // SubmitAnswers 提交答案
func (c *cKnowledgeTest) SubmitAnswers(r *ghttp.Request) {
func (c *CKnowledgeTest) SubmitAnswers(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req v1.SubmitAnswersReq var req v1.SubmitAnswersReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -77,7 +77,7 @@ func (c *cKnowledgeTest) SubmitAnswers(r *ghttp.Request) {
} }
// GetWrongQuestions 获取错题列表 // GetWrongQuestions 获取错题列表
func (c *cKnowledgeTest) GetWrongQuestions(r *ghttp.Request) {
func (c *CKnowledgeTest) GetWrongQuestions(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.GetWrongQuestionsReq var req *v1.GetWrongQuestionsReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {

20
Knowledge_Test_Go/internal/controller/questionBank.go

@ -9,14 +9,14 @@ import (
"github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/ghttp"
) )
type cQuestionBank struct{}
type CQuestionBank struct{}
func NewQuestionBank() *cQuestionBank {
return &cQuestionBank{}
func NewQuestionBank() *CQuestionBank {
return &CQuestionBank{}
} }
// GetQuestions 获取题目列表 // GetQuestions 获取题目列表
func (c *cQuestionBank) GetQuestions(r *ghttp.Request) {
func (c *CQuestionBank) GetQuestions(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.QuestionOutputReq var req *v1.QuestionOutputReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -33,7 +33,7 @@ func (c *cQuestionBank) GetQuestions(r *ghttp.Request) {
} }
// QuestionUpdate 获取题目列表 // QuestionUpdate 获取题目列表
func (c *cQuestionBank) QuestionUpdate(r *ghttp.Request) {
func (c *CQuestionBank) QuestionUpdate(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.QuestionUpdateReq var req *v1.QuestionUpdateReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -49,7 +49,7 @@ func (c *cQuestionBank) QuestionUpdate(r *ghttp.Request) {
} }
// QuestionDel 删除题目 // QuestionDel 删除题目
func (c *cQuestionBank) QuestionDel(r *ghttp.Request) {
func (c *CQuestionBank) QuestionDel(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.QuestionDelReq var req *v1.QuestionDelReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -65,7 +65,7 @@ func (c *cQuestionBank) QuestionDel(r *ghttp.Request) {
} }
// UserScoreOutput 获取用户成绩列表 // UserScoreOutput 获取用户成绩列表
func (c *cQuestionBank) UserScoreOutput(r *ghttp.Request) {
func (c *CQuestionBank) UserScoreOutput(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.UserScoreOutputReq var req *v1.UserScoreOutputReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -82,7 +82,7 @@ func (c *cQuestionBank) UserScoreOutput(r *ghttp.Request) {
} }
// ErrorOutPutUser 错题统计出错用户 // ErrorOutPutUser 错题统计出错用户
func (c *cQuestionBank) ErrorOutPutUser(r *ghttp.Request) {
func (c *CQuestionBank) ErrorOutPutUser(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.ErrorOutPutUserReq var req *v1.ErrorOutPutUserReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -99,7 +99,7 @@ func (c *cQuestionBank) ErrorOutPutUser(r *ghttp.Request) {
} }
// ExportQuestion 导出题目数据到 Excel // ExportQuestion 导出题目数据到 Excel
func (c *cQuestionBank) ExportQuestion(r *ghttp.Request) {
func (c *CQuestionBank) ExportQuestion(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.QuestionOutputReq var req *v1.QuestionOutputReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {
@ -109,7 +109,7 @@ func (c *cQuestionBank) ExportQuestion(r *ghttp.Request) {
} }
// ExportUserScore 导出用户成绩到 Excel // ExportUserScore 导出用户成绩到 Excel
func (c *cQuestionBank) ExportUserScore(r *ghttp.Request) {
func (c *CQuestionBank) ExportUserScore(r *ghttp.Request) {
ctx := r.GetCtx() ctx := r.GetCtx()
var req *v1.UserScoreOutputReq var req *v1.UserScoreOutputReq
if err := r.Parse(&req); err != nil { if err := r.Parse(&req); err != nil {

Loading…
Cancel
Save