RemoveQuestion delete question
(ctx context.Context, req *schema.RemoveQuestionReq)
| 507 | |
| 508 | // RemoveQuestion delete question |
| 509 | func (qs *QuestionCommon) RemoveQuestion(ctx context.Context, req *schema.RemoveQuestionReq) (err error) { |
| 510 | questionInfo, has, err := qs.questionRepo.GetQuestion(ctx, req.ID) |
| 511 | if err != nil { |
| 512 | return err |
| 513 | } |
| 514 | if !has { |
| 515 | return nil |
| 516 | } |
| 517 | |
| 518 | if questionInfo.Status == entity.QuestionStatusDeleted { |
| 519 | return nil |
| 520 | } |
| 521 | |
| 522 | questionInfo.Status = entity.QuestionStatusDeleted |
| 523 | err = qs.questionRepo.UpdateQuestionStatus(ctx, questionInfo.ID, questionInfo.Status) |
| 524 | if err != nil { |
| 525 | return err |
| 526 | } |
| 527 | |
| 528 | userQuestionCount, err := qs.GetUserQuestionCount(ctx, questionInfo.UserID) |
| 529 | if err != nil { |
| 530 | log.Error("user GetUserQuestionCount error", err.Error()) |
| 531 | } else { |
| 532 | err = qs.userCommon.UpdateQuestionCount(ctx, questionInfo.UserID, userQuestionCount) |
| 533 | if err != nil { |
| 534 | log.Error("user IncreaseQuestionCount error", err.Error()) |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | return nil |
| 539 | } |
| 540 | |
| 541 | func (qs *QuestionCommon) CloseQuestion(ctx context.Context, req *schema.CloseQuestionReq) error { |
| 542 | questionInfo, has, err := qs.questionRepo.GetQuestion(ctx, req.ID) |
nothing calls this directly
no test coverage detected