MCPcopy Index your code
hub / github.com/apache/answer / SearchList

Method SearchList

internal/service/content/answer_service.go:667–698  ·  view source on GitHub ↗
(ctx context.Context, req *schema.AnswerListReq)

Source from the content-addressed store, hash-verified

665}
666
667func (as *AnswerService) SearchList(ctx context.Context, req *schema.AnswerListReq) ([]*schema.AnswerInfo, int64, error) {
668 list := make([]*schema.AnswerInfo, 0)
669 questionInfo, exist, err := as.questionRepo.GetQuestion(ctx, req.QuestionID)
670 if err != nil {
671 return list, 0, err
672 }
673 if !exist {
674 return list, 0, errors.NotFound(reason.QuestionNotFound)
675 }
676 if (questionInfo.Status == entity.QuestionStatusDeleted ||
677 questionInfo.Status == entity.QuestionStatusPending ||
678 questionInfo.Show == entity.QuestionHide) &&
679 !req.IsAdminModerator && questionInfo.UserID != req.UserID {
680 return list, 0, errors.NotFound(reason.QuestionNotFound)
681 }
682 dbSearch := entity.AnswerSearch{}
683 dbSearch.QuestionID = req.QuestionID
684 dbSearch.Page = req.Page
685 dbSearch.PageSize = req.PageSize
686 dbSearch.Order = req.Order
687 dbSearch.IncludeDeleted = req.CanDelete
688 dbSearch.LoginUserID = req.UserID
689 answerOriginalList, count, err := as.answerRepo.SearchList(ctx, &dbSearch)
690 if err != nil {
691 return list, count, err
692 }
693 answerList, err := as.SearchFormatInfo(ctx, answerOriginalList, req)
694 if err != nil {
695 return answerList, count, err
696 }
697 return answerList, count, nil
698}
699
700func (as *AnswerService) SearchFormatInfo(ctx context.Context, answers []*entity.Answer, req *schema.AnswerListReq) (
701 []*schema.AnswerInfo, error) {

Callers

nothing calls this directly

Calls 3

SearchFormatInfoMethod · 0.95
GetQuestionMethod · 0.65
SearchListMethod · 0.65

Tested by

no test coverage detected