From 4b0cd42c1bc0c01e806b9f53c609a7add05f9e69 Mon Sep 17 00:00:00 2001 From: plutoyty <2631223275@qq.com> Date: Fri, 28 Jul 2023 17:05:16 +0800 Subject: [PATCH] Get user online status --- pkg/common/db/cache/user.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/common/db/cache/user.go b/pkg/common/db/cache/user.go index 6283633fa..5c76af22f 100644 --- a/pkg/common/db/cache/user.go +++ b/pkg/common/db/cache/user.go @@ -174,15 +174,17 @@ func (u *UserCacheRedis) GetUserStatus(ctx context.Context, userIDs []string) ([ key := olineStatusKey + modKey result, err := u.rdb.HGet(ctx, key, userID).Result() if err != nil { - return nil, err - } else if err == redis.Nil { - // key or field does not exist - res = append(res, &user.OnlineStatus{ - UserID: userID, - Status: 0, - PlatformID: -1, - }) - continue + if err == redis.Nil { + // key or field does not exist + res = append(res, &user.OnlineStatus{ + UserID: userID, + Status: 0, + PlatformID: -1, + }) + continue + } else { + return nil, err + } } err = json.Unmarshal([]byte(result), &onlineStatus) if err != nil {