修改了新增了题库类型2、3
This commit is contained in:
@@ -91,6 +91,39 @@ func (r *QuestionQa) AddQuestionQa(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// 判断题库类型
|
||||
if req.QaType == 2 || req.QaType == 3 {
|
||||
if req.QaDisplayType == 1 {
|
||||
responses.FailWithMessage("展示类型错误,该题库下只允许选择飞花令类型", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 判断飞花令题目数量规则
|
||||
if req.TokenQuestionContent == nil {
|
||||
responses.FailWithMessage("请填入飞花令题目数量规则", c)
|
||||
return
|
||||
}
|
||||
|
||||
for _, item := range req.TokenQuestionContent {
|
||||
if err := global.Validate.Struct(item); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if req.TokenNum == nil {
|
||||
responses.FailWithMessage("请填入飞花令数量", c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.QaType == 3 {
|
||||
if req.RoundNum == nil {
|
||||
responses.FailWithMessage("请填入轮次数量", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 业务处理
|
||||
questionQaService := service.QuestionQaService{}
|
||||
_, err := questionQaService.AddQuestionQa(req)
|
||||
|
||||
Reference in New Issue
Block a user