diff --git a/api/service/Question.go b/api/service/Question.go index 5478506..6ec4015 100644 --- a/api/service/Question.go +++ b/api/service/Question.go @@ -72,6 +72,23 @@ func (r *QuestionService) AddQuestion(req requests.AddQuestion) (bool, error) { if len(req.QuestionOption) == 0 { return false, errors.New("请填入选项") } + + questionOption := "A.B.C.D.E.F.G.H.I.J.K." + for _, s := range req.QuestionOption { + if s == "" { + return false, errors.New("存在为空的选项") + } + + // 判断是否为正常选项 + if !strings.Contains(questionOption, s) { + return false, errors.New("选项存在错误标识") + } + + // 判断答案是否在选项中 + if !strings.Contains(questionAnswer, s) { + return false, errors.New("答案不在选项中,请重新填写") + } + } } // 验证重复