This is an automated email from the ASF dual-hosted git repository. linkinstar pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 4a07fdb4a8b180bd28684e54c66a3a7caf51bfcc Author: Sonui <[email protected]> AuthorDate: Thu Aug 1 23:53:55 2024 +0800 fix: set last answer ID to zero if no answers --- internal/service/question_common/question.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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)) }
