From bef9ce9ebcf53ec3ece4f2dda184c5b94d69dcfd Mon Sep 17 00:00:00 2001 From: LinkinStars Date: Tue, 19 Sep 2023 15:53:06 +0800 Subject: [PATCH] fix(vote): wrong vote status of answer --- internal/repo/activity_common/vote.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/repo/activity_common/vote.go b/internal/repo/activity_common/vote.go index 56c33798..f425f615 100644 --- a/internal/repo/activity_common/vote.go +++ b/internal/repo/activity_common/vote.go @@ -2,6 +2,7 @@ package activity_common import ( "context" + "github.com/answerdev/answer/pkg/uid" "github.com/answerdev/answer/internal/base/data" "github.com/answerdev/answer/internal/base/reason" @@ -26,13 +27,15 @@ func NewVoteRepo(data *data.Data, activityRepo activity_common.ActivityRepo) act } func (vr *VoteRepo) GetVoteStatus(ctx context.Context, objectID, userID string) (status string) { + objectID = uid.DeShortID(objectID) for _, action := range []string{"vote_up", "vote_down"} { - at := &entity.Activity{} activityType, _, _, err := vr.activityRepo.GetActivityTypeByObjID(ctx, objectID, action) if err != nil { return "" } - has, err := vr.data.DB.Context(ctx).Where("object_id =? AND cancelled=0 AND activity_type=? AND user_id=?", objectID, activityType, userID).Get(at) + at := &entity.Activity{} + has, err := vr.data.DB.Context(ctx).Where("object_id = ? AND cancelled = 0 AND activity_type = ? AND user_id = ?", + objectID, activityType, userID).Get(at) if err != nil { log.Error(err) return ""