处理分享2
This commit is contained in:
+19
-7
@@ -89,7 +89,7 @@ func GetQuestionListDto(m []*model.Question) []*QuestionDto {
|
||||
|
||||
// 加载答案
|
||||
if v.QuestionAnswer != "" {
|
||||
response = response.LoadQuestionAnswer(v.QuestionAnswer)
|
||||
response = response.LoadQuestionAnswer(v)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
@@ -140,6 +140,14 @@ func (r *QuestionDto) LoadQuestionOption(m []*model.QuestionOption) *QuestionDto
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadQuestionOptionSimplify 加载选项-简化
|
||||
func (r *QuestionDto) LoadQuestionOptionSimplify(m []*model.QuestionOption) *QuestionDto {
|
||||
if len(m) > 0 {
|
||||
r.QuestionOption = GetQuestionOptionSimplifyListDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadQuestionImage 加载图片
|
||||
func (r *QuestionDto) LoadQuestionImage(s string) *QuestionDto {
|
||||
if s != "" {
|
||||
@@ -155,13 +163,17 @@ func (r *QuestionDto) LoadQuestionImage(s string) *QuestionDto {
|
||||
}
|
||||
|
||||
// LoadQuestionAnswer 加载答案
|
||||
func (r *QuestionDto) LoadQuestionAnswer(s string) *QuestionDto {
|
||||
if s != "" {
|
||||
result := strings.Split(s, ",")
|
||||
if len(result) > 0 {
|
||||
for _, v := range result {
|
||||
r.QuestionAnswer = append(r.QuestionAnswer, v)
|
||||
func (r *QuestionDto) LoadQuestionAnswer(m *model.Question) *QuestionDto {
|
||||
if m.QuestionAnswer != "" {
|
||||
if m.QuestionType == 1 || m.QuestionType == 2 {
|
||||
result := strings.Split(m.QuestionAnswer, ",")
|
||||
if len(result) > 0 {
|
||||
for _, v := range result {
|
||||
r.QuestionAnswer = append(r.QuestionAnswer, v)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
r.QuestionAnswer[0] = m.QuestionAnswer
|
||||
}
|
||||
}
|
||||
return r
|
||||
|
||||
@@ -49,3 +49,22 @@ func GetQuestionOptionListDto(m []*model.QuestionOption) []*QuestionOptionDto {
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetQuestionOptionSimplifyListDto 题目选项列表-简化
|
||||
func GetQuestionOptionSimplifyListDto(m []*model.QuestionOption) []*QuestionOptionDto {
|
||||
// 处理返回值
|
||||
responses := make([]*QuestionOptionDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &QuestionOptionDto{
|
||||
OptionValue: v.OptionValue,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (r *QuestionQaItemDto) LoadQuestion(m *model.Question) *QuestionQaItemDto {
|
||||
r.Question = r.Question.LoadQuestionImage(m.QuestionImage)
|
||||
|
||||
// 加载答案
|
||||
r.Question = r.Question.LoadQuestionAnswer(m.QuestionAnswer)
|
||||
r.Question = r.Question.LoadQuestionAnswer(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,7 +1,18 @@
|
||||
package dto
|
||||
|
||||
// GetBackgroundImageDto 获取背景图
|
||||
type GetBackgroundImageDto struct {
|
||||
Status int `json:"status"` // 状态
|
||||
Message string `json:"message"` // 提示信息
|
||||
Data interface{} `json:"data"` // 数据值
|
||||
}
|
||||
|
||||
// ShareAuthDto 授权
|
||||
type ShareAuthDto struct {
|
||||
Token string `json:"token"` // token
|
||||
}
|
||||
|
||||
type ShareDto struct {
|
||||
QuestionQa *QuestionQaDto `json:"question_qa"` // 题库数据
|
||||
Question []*QuestionDto `json:"question"` // 题库关联题目列表
|
||||
BaseTokenItem []*BaseTokenItemDto `json:"base_token_item"` // 题库关联飞花令-列表
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user