RemoveAnswer delete answer
(ctx context.Context, id string)
| 572 | |
| 573 | // RemoveAnswer delete answer |
| 574 | func (qs *QuestionCommon) RemoveAnswer(ctx context.Context, id string) (err error) { |
| 575 | answerinfo, has, err := qs.answerRepo.GetByID(ctx, id) |
| 576 | if err != nil { |
| 577 | return err |
| 578 | } |
| 579 | if !has { |
| 580 | return nil |
| 581 | } |
| 582 | |
| 583 | // user add question count |
| 584 | |
| 585 | err = qs.UpdateAnswerCount(ctx, answerinfo.QuestionID) |
| 586 | if err != nil { |
| 587 | log.Error("UpdateAnswerCount error", err.Error()) |
| 588 | } |
| 589 | userAnswerCount, err := qs.answerRepo.GetCountByUserID(ctx, answerinfo.UserID) |
| 590 | if err != nil { |
| 591 | log.Error("GetCountByUserID error", err.Error()) |
| 592 | } |
| 593 | err = qs.userCommon.UpdateAnswerCount(ctx, answerinfo.UserID, int(userAnswerCount)) |
| 594 | if err != nil { |
| 595 | log.Error("user UpdateAnswerCount error", err.Error()) |
| 596 | } |
| 597 | |
| 598 | return qs.answerRepo.RemoveAnswer(ctx, id) |
| 599 | } |
| 600 | |
| 601 | func (qs *QuestionCommon) SitemapCron(ctx context.Context) { |
| 602 | questionNum, err := qs.questionRepo.GetQuestionCount(ctx) |
nothing calls this directly
no test coverage detected