(ctx context.Context, req *schema.AnswerListReq)
| 665 | } |
| 666 | |
| 667 | func (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 | |
| 700 | func (as *AnswerService) SearchFormatInfo(ctx context.Context, answers []*entity.Answer, req *schema.AnswerListReq) ( |
| 701 | []*schema.AnswerInfo, error) { |
nothing calls this directly
no test coverage detected