Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: set last answer ID to zero if no answers

Sonui4a07fdb4a8b1
diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.go
index fce3761e..b9f2fd53 100644
--- a/internal/service/question_common/question.go
+++ b/internal/service/question_common/question.go
@@ -145,6 +145,15 @@ func (qs *QuestionCommon) UpdateAnswerCount(ctx context.Context, questionID stri
if err != nil {
return err
}
+ if count == 0 {
+ err = qs.questionRepo.UpdateLastAnswer(ctx, &entity.Question{
+ ID: questionID,
+ LastAnswerID: "0",
+ })
+ if err != nil {
+ return err
+ }
+ }
return qs.questionRepo.UpdateAnswerCount(ctx, questionID, int(count))
}