修改标签
This commit is contained in:
@@ -45,13 +45,39 @@ func (r *Question) GetQuestionPage(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
GetQuestionPageResponses := dto.GetQuestionListDto(question)
|
||||
g := dto.GetQuestionListDto(question)
|
||||
|
||||
for _, v := range g {
|
||||
// 加载一级标签
|
||||
if v.FirstLabelId != nil {
|
||||
labelDao := dao.LabelDao{}
|
||||
firstLabel, err := labelDao.GetLabelFirstById(*v.FirstLabelId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
v.LoadFirstLabel(firstLabel)
|
||||
}
|
||||
|
||||
// 加载二级标签
|
||||
if v.SecondLabelId != nil {
|
||||
labelDao := dao.LabelDao{}
|
||||
secondLabel, err := labelDao.GetLabelFirstById(*v.SecondLabelId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
v.LoadSecondLabel(secondLabel)
|
||||
}
|
||||
}
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.Page
|
||||
result["page_size"] = req.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = GetQuestionPageResponses
|
||||
result["data"] = g
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
@@ -72,13 +98,13 @@ func (r *Question) GetQuestion(c *gin.Context) {
|
||||
|
||||
// 业务处理
|
||||
questionService := service.QuestionService{}
|
||||
getQuestionResponses, err := questionService.GetQuestion(questionId)
|
||||
g, err := questionService.GetQuestion(questionId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(getQuestionResponses, c)
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
// AddQuestion 新增题目
|
||||
|
||||
@@ -45,17 +45,39 @@ func (r *QuestionQaItem) GetQuestionQaItemPage(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
questionQaItemPageResponses := dto.GetQuestionQaItemListDto(questionQaItem)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
g := dto.GetQuestionQaItemListDto(questionQaItem)
|
||||
|
||||
for _, v := range g {
|
||||
// 加载一级标签
|
||||
if v.Question.FirstLabelId != nil {
|
||||
labelDao := dao.LabelDao{}
|
||||
firstLabel, err := labelDao.GetLabelFirstById(*v.Question.FirstLabelId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
v.LoadFirstLabel(firstLabel)
|
||||
}
|
||||
|
||||
// 加载二级标签
|
||||
if v.Question.SecondLabelId != nil {
|
||||
labelDao := dao.LabelDao{}
|
||||
secondLabel, err := labelDao.GetLabelFirstById(*v.Question.SecondLabelId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
v.LoadSecondLabel(secondLabel)
|
||||
}
|
||||
}
|
||||
|
||||
result := make(map[string]interface{})
|
||||
result["page"] = req.Page
|
||||
result["page_size"] = req.PageSize
|
||||
result["total"] = total
|
||||
result["data"] = questionQaItemPageResponses
|
||||
result["data"] = g
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user