AdminAnswerPage search answer list
(ctx context.Context, req *schema.AdminAnswerPageReq)
| 1684 | |
| 1685 | // AdminAnswerPage search answer list |
| 1686 | func (qs *QuestionService) AdminAnswerPage(ctx context.Context, req *schema.AdminAnswerPageReq) ( |
| 1687 | resp *pager.PageModel, err error) { |
| 1688 | answerList, count, err := qs.questioncommon.AnswerCommon.AdminSearchList(ctx, req) |
| 1689 | if err != nil { |
| 1690 | return nil, err |
| 1691 | } |
| 1692 | |
| 1693 | questionIDs := make([]string, 0) |
| 1694 | userIds := make([]string, 0) |
| 1695 | answerResp := make([]*schema.AdminAnswerInfo, 0) |
| 1696 | for _, item := range answerList { |
| 1697 | answerInfo := qs.questioncommon.AnswerCommon.AdminShowFormat(ctx, item) |
| 1698 | answerResp = append(answerResp, answerInfo) |
| 1699 | questionIDs = append(questionIDs, item.QuestionID) |
| 1700 | userIds = append(userIds, item.UserID) |
| 1701 | } |
| 1702 | userInfoMap, err := qs.userCommon.BatchUserBasicInfoByID(ctx, userIds) |
| 1703 | if err != nil { |
| 1704 | return nil, err |
| 1705 | } |
| 1706 | questionMaps, err := qs.questioncommon.FindInfoByID(ctx, questionIDs, req.LoginUserID) |
| 1707 | if err != nil { |
| 1708 | return nil, err |
| 1709 | } |
| 1710 | |
| 1711 | for _, item := range answerResp { |
| 1712 | if q, ok := questionMaps[item.QuestionID]; ok { |
| 1713 | item.QuestionInfo.Title = q.Title |
| 1714 | } |
| 1715 | if u, ok := userInfoMap[item.UserID]; ok { |
| 1716 | item.UserInfo = u |
| 1717 | } |
| 1718 | } |
| 1719 | return pager.NewPageModel(count, answerResp), nil |
| 1720 | } |
| 1721 | |
| 1722 | func (qs *QuestionService) changeQuestionToRevision(_ context.Context, questionInfo *entity.Question, tags []*entity.Tag) ( |
| 1723 | questionRevision *entity.QuestionWithTagsRevision) { |
nothing calls this directly
no test coverage detected