mirror of https://gitee.com/answerdev/answer.git
fix question add pv
This commit is contained in:
parent
45e056d26b
commit
d74e250d26
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue