(ctx context.Context, req *schema.CloseQuestionReq)
| 539 | } |
| 540 | |
| 541 | func (qs *QuestionCommon) CloseQuestion(ctx context.Context, req *schema.CloseQuestionReq) error { |
| 542 | questionInfo, has, err := qs.questionRepo.GetQuestion(ctx, req.ID) |
| 543 | if err != nil { |
| 544 | return err |
| 545 | } |
| 546 | if !has { |
| 547 | return nil |
| 548 | } |
| 549 | questionInfo.Status = entity.QuestionStatusClosed |
| 550 | err = qs.questionRepo.UpdateQuestionStatus(ctx, questionInfo.ID, questionInfo.Status) |
| 551 | if err != nil { |
| 552 | return err |
| 553 | } |
| 554 | |
| 555 | closeMeta, _ := json.Marshal(schema.CloseQuestionMeta{ |
| 556 | CloseType: req.CloseType, |
| 557 | CloseMsg: req.CloseMsg, |
| 558 | }) |
| 559 | err = qs.metaCommonService.AddMeta(ctx, req.ID, entity.QuestionCloseReasonKey, string(closeMeta)) |
| 560 | if err != nil { |
| 561 | return err |
| 562 | } |
| 563 | |
| 564 | qs.activityQueueService.Send(ctx, &schema.ActivityMsg{ |
| 565 | UserID: questionInfo.UserID, |
| 566 | ObjectID: questionInfo.ID, |
| 567 | OriginalObjectID: questionInfo.ID, |
| 568 | ActivityTypeKey: constant.ActQuestionClosed, |
| 569 | }) |
| 570 | return nil |
| 571 | } |
| 572 | |
| 573 | // RemoveAnswer delete answer |
| 574 | func (qs *QuestionCommon) RemoveAnswer(ctx context.Context, id string) (err error) { |
no test coverage detected