This commit is contained in:
wucongxing8150 2024-06-25 14:17:05 +08:00
parent 8405cdb5d7
commit c4278c9f19

View File

@ -176,7 +176,7 @@ func (r *QuestionService) AddQuestionTest(req requests.AddQuestionTest) (bool, e
}
// 判断选项
if req.QuestionType == "1" || req.QuestionType == "2" {
if req.QuestionType == 1 || req.QuestionType == 2 {
if req.Input1 == nil {
return false, errors.New("请填入选项")
}
@ -192,11 +192,6 @@ func (r *QuestionService) AddQuestionTest(req requests.AddQuestionTest) (bool, e
return false, errors.New("题目名称重复")
}
questionType, err := strconv.Atoi(req.QuestionType)
if err != nil {
return false, errors.New("题目类型错误")
}
questionStatus, err := strconv.Atoi(req.QuestionStatus)
if err != nil {
return false, errors.New("题目状态错误")
@ -218,7 +213,7 @@ func (r *QuestionService) AddQuestionTest(req requests.AddQuestionTest) (bool, e
// 新增题目
question = &model.Question{
QuestionName: req.QuestionName,
QuestionType: questionType,
QuestionType: req.QuestionType,
QuestionStatus: questionStatus,
QuestionSource: 1,
QuestionImage: questionImage,
@ -241,7 +236,7 @@ func (r *QuestionService) AddQuestionTest(req requests.AddQuestionTest) (bool, e
// 新增选项
questionOptionDao := dao.QuestionOptionDao{}
if req.QuestionType == "1" || req.QuestionType == "2" {
if req.QuestionType == 1 || req.QuestionType == 2 {
if req.Input1 != nil {
questionOption := &model.QuestionOption{
QuestionId: question.QuestionId,
@ -487,16 +482,8 @@ func (r *QuestionService) PutQuestionTest(questionId int64, req requests.PutQues
}
// 题目类型
if req.QuestionType != "" {
questionType, err := strconv.Atoi(req.QuestionType)
if err != nil {
tx.Rollback()
return false, errors.New("题目类型错误")
}
if questionType != question.QuestionType {
questionData["question_type"] = req.QuestionType
}
if req.QuestionType != question.QuestionType {
questionData["question_type"] = req.QuestionType
}
// 状态
@ -627,7 +614,7 @@ func (r *QuestionService) PutQuestionTest(questionId int64, req requests.PutQues
}
}
if req.QuestionType == "1" || req.QuestionType == "2" {
if req.QuestionType == 1 || req.QuestionType == 2 {
// 新增选项
questionOptionDao := dao.QuestionOptionDao{}
if req.Input1 != nil {