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(question): update answer count after reviewing

LinkinStars8f30a1530cd2
diff --git a/cmd/wire_gen.go b/cmd/wire_gen.go
index e7ff464c..1e69c751 100644
--- a/cmd/wire_gen.go
+++ b/cmd/wire_gen.go
@@ -193,7 +193,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,
answerActivityService := activity2.NewAnswerActivityService(answerActivityRepo, configService)
externalNotificationService := notification.NewExternalNotificationService(dataData, userNotificationConfigRepo, followRepo, emailService, userRepo, externalNotificationQueueService, userExternalLoginRepo, siteInfoCommonService)
reviewRepo := review.NewReviewRepo(dataData)
- reviewService := review2.NewReviewService(reviewRepo, objService, userCommon, userRepo, questionRepo, answerRepo, userRoleRelService, externalNotificationQueueService, tagCommonService, notificationQueueService, siteInfoCommonService)
+ reviewService := review2.NewReviewService(reviewRepo, objService, userCommon, userRepo, questionRepo, answerRepo, userRoleRelService, externalNotificationQueueService, tagCommonService, questionCommon, notificationQueueService, siteInfoCommonService)
questionService := content.NewQuestionService(questionRepo, tagCommonService, questionCommon, userCommon, userRepo, userRoleRelService, revisionService, metaCommonService, collectionCommon, answerActivityService, emailService, notificationQueueService, externalNotificationQueueService, activityQueueService, siteInfoCommonService, externalNotificationService, reviewService, configService)
answerService := content.NewAnswerService(answerRepo, questionRepo, questionCommon, userCommon, collectionCommon, userRepo, revisionService, answerActivityService, answerCommon, voteRepo, emailService, userRoleRelService, notificationQueueService, externalNotificationQueueService, activityQueueService, reviewService)
reportHandle := report_handle.NewReportHandle(questionService, answerService, commentService)
diff --git a/internal/service/review/review_service.go b/internal/service/review/review_service.go
index ab4079ee..fb323178 100644
--- a/internal/service/review/review_service.go
+++ b/internal/service/review/review_service.go
@@ -63,6 +63,7 @@ type ReviewService struct {
answerRepo answercommon.AnswerRepo
userRoleService *role.UserRoleRelService
tagCommon *tagcommon.TagCommonService
+ questionCommon *questioncommon.QuestionCommon
externalNotificationQueueService notice_queue.ExternalNotificationQueueService
notificationQueueService notice_queue.NotificationQueueService
siteInfoService siteinfo_common.SiteInfoCommonService
@@ -79,6 +80,7 @@ func NewReviewService(
userRoleService *role.UserRoleRelService,
externalNotificationQueueService notice_queue.ExternalNotificationQueueService,
tagCommon *tagcommon.TagCommonService,
+ questionCommon *questioncommon.QuestionCommon,
notificationQueueService notice_queue.NotificationQueueService,
siteInfoService siteinfo_common.SiteInfoCommonService,
) *ReviewService {
@@ -92,6 +94,7 @@ func NewReviewService(
userRoleService: userRoleService,
externalNotificationQueueService: externalNotificationQueueService,
tagCommon: tagCommon,
+ questionCommon: questionCommon,
notificationQueueService: notificationQueueService,
siteInfoService: siteInfoService,
}
@@ -295,6 +298,12 @@ func (cs *ReviewService) updateObjectStatus(ctx context.Context, review *entity.
cs.notificationAnswerTheQuestion(ctx, questionInfo.UserID, questionInfo.ID, answerInfo.ID,
answerInfo.UserID, questionInfo.Title, answerInfo.OriginalText)
}
+ if err := cs.questionCommon.UpdateAnswerCount(ctx, answerInfo.QuestionID); err != nil {
+ log.Errorf("update question answer count failed, err: %v", err)
+ }
+ if err := cs.questionCommon.UpdateLastAnswer(ctx, answerInfo.QuestionID, uid.DeShortID(answerInfo.ID)); err != nil {
+ log.Errorf("update question last answer failed, err: %v", err)
+ }
userAnswerCount, err := cs.answerRepo.GetCountByUserID(ctx, answerInfo.UserID)
if err != nil {
log.Errorf("get user answer count failed, err: %v", err)