处理分享2
This commit is contained in:
+28
-6
@@ -56,6 +56,17 @@ func (r *QuestionService) AddQuestion(req requests.AddQuestion) (bool, error) {
|
||||
questionImage = strings.Join(result, ",")
|
||||
}
|
||||
|
||||
// 处理答案
|
||||
var questionAnswer string
|
||||
if len(req.QuestionAnswer) > 0 {
|
||||
result := make([]string, len(req.QuestionAnswer))
|
||||
for i, url := range req.QuestionAnswer {
|
||||
result[i] = url
|
||||
}
|
||||
|
||||
questionAnswer = strings.Join(result, ",")
|
||||
}
|
||||
|
||||
// 判断选项
|
||||
if req.QuestionType == 1 || req.QuestionType == 2 {
|
||||
if len(req.QuestionOption) == 0 {
|
||||
@@ -88,7 +99,7 @@ func (r *QuestionService) AddQuestion(req requests.AddQuestion) (bool, error) {
|
||||
QuestionStatus: req.QuestionStatus,
|
||||
QuestionSource: req.QuestionSource,
|
||||
QuestionImage: questionImage,
|
||||
QuestionAnswer: req.QuestionAnswer,
|
||||
QuestionAnswer: questionAnswer,
|
||||
QuestionAnalysis: req.QuestionAnalysis,
|
||||
Difficulty: req.Difficulty,
|
||||
FirstLabelId: &firstLabelId,
|
||||
@@ -365,11 +376,6 @@ func (r *QuestionService) PutQuestion(questionId int64, req requests.PutQuestion
|
||||
questionData["question_status"] = req.QuestionStatus
|
||||
}
|
||||
|
||||
// 答案
|
||||
if req.QuestionAnswer != question.QuestionAnswer {
|
||||
questionData["question_answer"] = req.QuestionAnswer
|
||||
}
|
||||
|
||||
// 解析
|
||||
if req.QuestionAnalysis != question.QuestionAnalysis {
|
||||
questionData["question_analysis"] = req.QuestionAnalysis
|
||||
@@ -432,6 +438,16 @@ func (r *QuestionService) PutQuestion(questionId int64, req requests.PutQuestion
|
||||
questionData["question_image"] = strings.Join(result, ",")
|
||||
}
|
||||
|
||||
// 答案
|
||||
if len(req.QuestionAnswer) > 0 {
|
||||
result := make([]string, len(req.QuestionAnswer))
|
||||
for i, v := range req.QuestionAnswer {
|
||||
result[i] = v
|
||||
}
|
||||
|
||||
questionData["question_answer"] = strings.Join(result, ",")
|
||||
}
|
||||
|
||||
// 验证重复
|
||||
if req.QuestionName != question.QuestionName {
|
||||
maps := make(map[string]interface{})
|
||||
@@ -799,5 +815,11 @@ func (r *QuestionService) GetQuestion(questionId int64) (g *dto.QuestionDto, err
|
||||
// 加载选项
|
||||
g.LoadQuestionOption(question.QuestionOption)
|
||||
|
||||
// 加载图片
|
||||
g.LoadQuestionImage(question.QuestionImage)
|
||||
|
||||
// 加载答案
|
||||
g.LoadQuestionAnswer(question.QuestionAnswer)
|
||||
|
||||
return g, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user