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 add pv

aichy638aadbded3e
diff --git a/internal/controller/question_controller.go b/internal/controller/question_controller.go
index 748710e0..8b93230e 100644
--- a/internal/controller/question_controller.go
+++ b/internal/controller/question_controller.go
@@ -85,7 +85,7 @@ func (qc *QuestionController) GetQuestion(c *gin.Context) {
id := c.Query("id")
ctx := context.Background()
userID := middleware.GetLoginUserIDFromContext(c)
- info, err := qc.questionService.GetQuestion(ctx, id, userID)
+ info, err := qc.questionService.GetQuestion(ctx, id, userID, true)
if err != nil {
handler.HandleResponse(c, err, nil)
return
diff --git a/internal/service/question_service.go b/internal/service/question_service.go
index f2273a1f..73a53e76 100644
--- a/internal/service/question_service.go
+++ b/internal/service/question_service.go
@@ -149,7 +149,7 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.Question
log.Error("user IncreaseQuestionCount error", err.Error())
}
- questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID)
+ questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID, false)
return
}
@@ -229,20 +229,23 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
return
}
- questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID)
+ questionInfo, err = qs.GetQuestion(ctx, question.ID, question.UserID, false)
return
}
// GetQuestion get question one
-func (qs *QuestionService) GetQuestion(ctx context.Context, id, loginUserID string) (resp *schema.QuestionInfo, err error) {
+func (qs *QuestionService) GetQuestion(ctx context.Context, id, loginUserID string, addpv bool) (resp *schema.QuestionInfo, err error) {
question, err := qs.questioncommon.Info(ctx, id, loginUserID)
if err != nil {
return
}
- err = qs.questioncommon.UpdataPv(ctx, id)
- if err != nil {
- log.Error("UpdataPv", err)
+ if addpv {
+ err = qs.questioncommon.UpdataPv(ctx, id)
+ if err != nil {
+ log.Error("UpdataPv", err)
+ }
}
+
question.MemberActions = permission.GetQuestionPermission(loginUserID, question.UserId)
return question, nil
}
@@ -466,7 +469,7 @@ func (qs *QuestionService) SearchByTitleLike(ctx context.Context, title string,
// SimilarQuestion
func (qs *QuestionService) SimilarQuestion(ctx context.Context, questionID string, loginUserID string) ([]*schema.QuestionInfo, int64, error) {
list := make([]*schema.QuestionInfo, 0)
- questionInfo, err := qs.GetQuestion(ctx, questionID, loginUserID)
+ questionInfo, err := qs.GetQuestion(ctx, questionID, loginUserID, false)
if err != nil {
return list, 0, err
}