Merge branch 'feat/1.2.0/user' into test

This commit is contained in:
LinkinStars 2023-09-19 15:56:35 +08:00
commit b0747d2616
1 changed files with 5 additions and 2 deletions

View File

@ -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 ""