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.
refactor: repo code should procees error
edocevolc8175744aa0f
diff --git a/go.mod b/go.modindex 7fe0bfd9..b6fa86d5 100644--- a/go.mod+++ b/go.mod@@ -17,7 +17,6 @@ require (github.com/jinzhu/copier v0.3.5github.com/jinzhu/now v1.1.5github.com/lib/pq v1.10.2- github.com/mattn/go-sqlite3 v2.0.3+incompatiblegithub.com/mojocn/base64Captcha v1.3.5github.com/segmentfault/pacman v1.0.1github.com/segmentfault/pacman/contrib/cache/memory v0.0.0-20220929065758-260b3093a347@@ -60,6 +59,7 @@ require (github.com/magiconair/properties v1.8.6 // indirectgithub.com/mailru/easyjson v0.7.7 // indirectgithub.com/mattn/go-isatty v0.0.16 // indirect+ github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirectgithub.com/mitchellh/mapstructure v1.5.0 // indirectgithub.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirectgithub.com/modern-go/reflect2 v1.0.2 // indirectdiff --git a/internal/repo/activity_common/follow.go b/internal/repo/activity_common/follow.goindex a793fdec..a61ddcdb 100644--- a/internal/repo/activity_common/follow.go+++ b/internal/repo/activity_common/follow.go@@ -95,6 +95,9 @@ func (ar *FollowRepo) GetFollowUserIDs(ctx context.Context, objectID string) (usfunc (ar *FollowRepo) GetFollowIDs(ctx context.Context, userID, objectKey string) (followIDs []string, err error) {followIDs = make([]string, 0)activityType, err := ar.activityRepo.GetActivityTypeByObjKey(ctx, objectKey, "follow")+ if err != nil {+ return nil, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()+ }session := ar.data.DB.Select("object_id")session.Table(entity.Activity{}.TableName())session.Where("user_id = ? AND activity_type = ?", userID, activityType)@@ -108,7 +111,7 @@ func (ar *FollowRepo) GetFollowIDs(ctx context.Context, userID, objectKey string// IsFollowed check user if follow object or notfunc (ar *FollowRepo) IsFollowed(userId, objectId string) (bool, error) {- activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(nil, objectId, "follow")+ activityType, _, _, err := ar.activityRepo.GetActivityTypeByObjID(context.TODO(), objectId, "follow")if err != nil {return false, err}diff --git a/internal/repo/activity_common/vote.go b/internal/repo/activity_common/vote.goindex c2525145..86db8f39 100644--- a/internal/repo/activity_common/vote.go+++ b/internal/repo/activity_common/vote.go@@ -6,13 +6,11 @@ import ("github.com/answerdev/answer/internal/base/data""github.com/answerdev/answer/internal/entity""github.com/answerdev/answer/internal/service/activity_common"- "github.com/answerdev/answer/internal/service/unique")// VoteRepo activity repositorytype VoteRepo struct {data *data.Data- uniqueIDRepo unique.UniqueIDRepoactivityRepo activity_common.ActivityRepo}@@ -28,6 +26,9 @@ func (vr *VoteRepo) GetVoteStatus(ctx context.Context, objectId, userId string)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.Where("object_id =? AND cancelled=0 AND activity_type=? AND user_id=?", objectId, activityType, userId).Get(at)if err != nil {return ""