MCPcopy
hub / github.com/apache/answer / RemoveQuestion

Method RemoveQuestion

internal/service/question_common/question.go:509–539  ·  view source on GitHub ↗

RemoveQuestion delete question

(ctx context.Context, req *schema.RemoveQuestionReq)

Source from the content-addressed store, hash-verified

507
508// RemoveQuestion delete question
509func (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
541func (qs *QuestionCommon) CloseQuestion(ctx context.Context, req *schema.CloseQuestionReq) error {
542 questionInfo, has, err := qs.questionRepo.GetQuestion(ctx, req.ID)

Callers

nothing calls this directly

Calls 4

GetUserQuestionCountMethod · 0.95
GetQuestionMethod · 0.65
UpdateQuestionStatusMethod · 0.65
UpdateQuestionCountMethod · 0.65

Tested by

no test coverage detected