From 305ee394b17556ba2845baa90850df2afb28159b Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Mon, 9 May 2022 10:00:03 +0800 Subject: [PATCH] cache --- internal/rpc/cache/cache.go | 8 ++++---- internal/rpc/office/office.go | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/rpc/cache/cache.go b/internal/rpc/cache/cache.go index b787459eb..a343c57e7 100644 --- a/internal/rpc/cache/cache.go +++ b/internal/rpc/cache/cache.go @@ -83,7 +83,7 @@ func SyncDB2Cache() error { err = updateAllFriendToCache(userList) err = updateAllBlackListToCache(userList) err = updateAllGroupMemberListToCache() - return err + return utils.Wrap(err, "") } func DelRelationCache() {} @@ -127,7 +127,7 @@ func updateAllGroupMemberListToCache() error { log.NewError("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error()) continue } - log.NewDebug("", utils.GetSelfFuncName(), "groupMemberIDList", groupMemberIDList) + //log.NewDebug("", utils.GetSelfFuncName(), "groupMemberIDList", groupMemberIDList) if len(groupMemberIDList) > 0 { if err := db.DB.AddGroupMemberToCache(groupID, groupMemberIDList...); err != nil { log.NewError("", utils.GetSelfFuncName(), "AddGroupMemberToCache", err.Error()) @@ -146,7 +146,7 @@ func updateAllFriendToCache(userList []db.User) error { log.NewError("0", utils.GetSelfFuncName(), err.Error()) continue } - log.NewDebug("", utils.GetSelfFuncName(), "friendIDList", user.UserID, friendIDList) + //log.NewDebug("", utils.GetSelfFuncName(), "friendIDList", user.UserID, friendIDList) if len(friendIDList) > 0 { if err := db.DB.AddFriendToCache(user.UserID, friendIDList...); err != nil { log.NewError("0", utils.GetSelfFuncName(), err.Error(), friendIDList, user.UserID) @@ -165,7 +165,7 @@ func updateAllBlackListToCache(userList []db.User) error { log.NewError("", utils.GetSelfFuncName(), err.Error()) continue } - log.NewDebug("", utils.GetSelfFuncName(), "updateAllBlackListToCache", user.UserID, blackIDList) + //log.NewDebug("", utils.GetSelfFuncName(), "updateAllBlackListToCache", user.UserID, blackIDList) if len(blackIDList) > 0 { if err := db.DB.AddBlackUserToCache(user.UserID, blackIDList...); err != nil { log.NewError("0", utils.GetSelfFuncName(), err.Error()) diff --git a/internal/rpc/office/office.go b/internal/rpc/office/office.go index c51c5d37b..1d8ab522e 100644 --- a/internal/rpc/office/office.go +++ b/internal/rpc/office/office.go @@ -287,6 +287,18 @@ func (s *officeServer) CreateOneWorkMoment(_ context.Context, req *pbOffice.Crea workMoment.UserName = createUser.Nickname workMoment.FaceURL = createUser.FaceURL workMoment.PermissionUserIDList = s.getPermissionUserIDList(req.OperationID, req.WorkMoment.PermissionGroupList, req.WorkMoment.PermissionUserList) + workMoment.PermissionUserList = []*db.WorkMomentUser{} + for _, userID := range workMoment.PermissionUserIDList { + userName, err := imdb.GetUserNameByUserID(userID) + if err != nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", err.Error()) + continue + } + workMoment.PermissionUserList = append(workMoment.PermissionUserList, &db.WorkMomentUser{ + UserID: userID, + UserName: userName, + }) + } log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "workMoment to create", workMoment) err = db.DB.CreateOneWorkMoment(&workMoment) if err != nil {