mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-10 12:05:58 +08:00
cache
This commit is contained in:
@@ -96,5 +96,6 @@ func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLogi
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
||||
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
Vendored
+10
-11
@@ -90,6 +90,7 @@ func SyncDB2Cache() error {
|
||||
var err error
|
||||
log.NewInfo("0", utils.GetSelfFuncName())
|
||||
userList, err := imdb.GetAllUser()
|
||||
log.NewDebug("", utils.GetSelfFuncName(), "userList", userList)
|
||||
if err != nil {
|
||||
return utils.Wrap(err, "")
|
||||
}
|
||||
@@ -118,10 +119,10 @@ func updateAllUserToCache(userList []db.User) error {
|
||||
}
|
||||
m, err := utils.Pb2Map(userInfoPb)
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), err.Error())
|
||||
log.NewWarn("", utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
if err := db.DB.SetUserInfoToCache(userInfo.UserID, m); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error())
|
||||
log.NewWarn("0", utils.GetSelfFuncName(), "set userInfo to cache failed", err.Error())
|
||||
}
|
||||
}
|
||||
log.NewInfo("0", utils.GetSelfFuncName(), "ok")
|
||||
@@ -132,19 +133,19 @@ func updateAllGroupMemberListToCache() error {
|
||||
log.NewInfo("0", utils.GetSelfFuncName())
|
||||
groupIDList, err := imdb.GetAllGroupIDList()
|
||||
if err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), "getAllGroupIDList failed", err.Error())
|
||||
log.NewWarn("0", utils.GetSelfFuncName(), "getAllGroupIDList failed", err.Error())
|
||||
panic(err.Error())
|
||||
}
|
||||
for _, groupID := range groupIDList {
|
||||
groupMemberIDList, err := imdb.GetGroupMemberIDListByGroupID(groupID)
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error())
|
||||
log.NewWarn("", utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID", err.Error())
|
||||
continue
|
||||
}
|
||||
//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())
|
||||
log.NewWarn("", utils.GetSelfFuncName(), "AddGroupMemberToCache", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,13 +158,12 @@ func updateAllFriendToCache(userList []db.User) error {
|
||||
for _, user := range userList {
|
||||
friendIDList, err := imdb.GetFriendIDListByUserID(user.UserID)
|
||||
if err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
log.NewWarn("0", utils.GetSelfFuncName(), err.Error())
|
||||
continue
|
||||
}
|
||||
//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)
|
||||
log.NewWarn("0", utils.GetSelfFuncName(), err.Error(), friendIDList, user.UserID)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,13 +176,12 @@ func updateAllBlackListToCache(userList []db.User) error {
|
||||
for _, user := range userList {
|
||||
blackIDList, err := imdb.GetBlackIDListByUserID(user.UserID)
|
||||
if err != nil {
|
||||
log.NewError("", utils.GetSelfFuncName(), err.Error())
|
||||
log.NewWarn("", utils.GetSelfFuncName(), err.Error())
|
||||
continue
|
||||
}
|
||||
//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())
|
||||
log.NewWarn("0", utils.GetSelfFuncName(), err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,7 +593,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
||||
}
|
||||
|
||||
resp := pbGroup.GetGroupsInfoResp{GroupInfoList: groupsInfoList}
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo rpc return ", resp)
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo rpc return ", resp.String())
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
@@ -991,7 +991,8 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
|
||||
for _, v := range groups {
|
||||
groupMember, err := imdb.GetGroupMaster(v.GroupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
|
||||
continue
|
||||
}
|
||||
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
|
||||
GroupInfo: &open_im_sdk.GroupInfo{
|
||||
@@ -1007,7 +1008,7 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
|
||||
GroupMasterName: groupMember.Nickname,
|
||||
})
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -1087,6 +1088,7 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
|
||||
CurrentPage: req.Pagination.PageNumber,
|
||||
ShowNumber: req.Pagination.ShowNumber,
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetC
|
||||
chatLog.RecvID = req.GroupId
|
||||
chatLog.SendID = req.UserId
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
|
||||
nums, err := imdb.GetChatLogCount(chatLog)
|
||||
resp.ChatLogsNum = int32(nums)
|
||||
if err != nil {
|
||||
|
||||
@@ -12,13 +12,6 @@ import (
|
||||
func (rpc *rpcChat) DelMsgList(_ context.Context, req *commonPb.DelMsgListReq) (*commonPb.DelMsgListResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &commonPb.DelMsgListResp{}
|
||||
//if err := db.DB.DelMsgLogic(req.UserID, req.SeqList, req.OperationID); err != nil {
|
||||
// log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
|
||||
// resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
// resp.ErrCode = constant.ErrDB.ErrCode
|
||||
// return resp, nil
|
||||
//}
|
||||
|
||||
if err := db.DB.DelMsgBySeqList(req.UserID, req.SeqList, req.OperationID); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsg failed", err.Error())
|
||||
resp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
|
||||
@@ -147,10 +147,10 @@ func (s *officeServer) DeleteTag(_ context.Context, req *pbOffice.DeleteTagReq)
|
||||
func (s *officeServer) SetTag(_ context.Context, req *pbOffice.SetTagReq) (resp *pbOffice.SetTagResp, err error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp = &pbOffice.SetTagResp{CommonResp: &pbOffice.CommonResp{}}
|
||||
IncreaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
|
||||
increaseUserIDList := utils.RemoveRepeatedStringInList(req.IncreaseUserIDList)
|
||||
reduceUserIDList := utils.RemoveRepeatedStringInList(req.ReduceUserIDList)
|
||||
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, IncreaseUserIDList, reduceUserIDList); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", err.Error())
|
||||
if err := db.DB.SetTag(req.UserID, req.TagID, req.NewName, increaseUserIDList, reduceUserIDList); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetTag failed", increaseUserIDList, reduceUserIDList, err.Error())
|
||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
return resp, nil
|
||||
@@ -175,13 +175,13 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
|
||||
for _, groupID := range req.GroupList {
|
||||
userIDList, err := im_mysql_model.GetGroupMemberIDListByGroupID(groupID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID failed", err.Error())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberIDListByGroupID failed", err.Error(), groupID)
|
||||
continue
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userIDList)
|
||||
groupUserIDList = append(groupUserIDList, userIDList...)
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), groupUserIDList, req.GroupList)
|
||||
var userIDList []string
|
||||
userIDList = append(userIDList, tagUserIDList...)
|
||||
userIDList = append(userIDList, groupUserIDList...)
|
||||
@@ -192,13 +192,13 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
|
||||
userIDList = append(userIDList[:i], userIDList[i+1:]...)
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
|
||||
us, err := imdb.GetUserByUserID(req.SendID)
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "total userIDList result: ", userIDList)
|
||||
user, err := imdb.GetUserByUserID(req.SendID)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.SendID)
|
||||
}
|
||||
for _, userID := range userIDList {
|
||||
msg.TagSendMessage(req.OperationID, us, userID, req.Content, req.SenderPlatformID)
|
||||
msg.TagSendMessage(req.OperationID, user, userID, req.Content, req.SenderPlatformID)
|
||||
}
|
||||
var tagSendLogs db.TagSendLog
|
||||
for _, userID := range userIDList {
|
||||
@@ -217,7 +217,7 @@ func (s *officeServer) SendMsg2Tag(_ context.Context, req *pbOffice.SendMsg2TagR
|
||||
tagSendLogs.SenderPlatformID = req.SenderPlatformID
|
||||
tagSendLogs.SendTime = time.Now().Unix()
|
||||
if err := db.DB.SaveTagSendLog(&tagSendLogs); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", err.Error())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SaveTagSendLog failed", tagSendLogs, err.Error())
|
||||
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||
return resp, nil
|
||||
|
||||
@@ -89,13 +89,14 @@ func (s *statisticsServer) Run() {
|
||||
}
|
||||
|
||||
func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.GetActiveGroupReq) (*pbStatistics.GetActiveGroupResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
|
||||
resp := &pbStatistics.GetActiveGroupResp{}
|
||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrArgs)
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
||||
@@ -109,6 +110,7 @@ func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.G
|
||||
MessageNum: int32(activeGroup.MessageNum),
|
||||
})
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -120,6 +122,7 @@ func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.Ge
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
|
||||
@@ -134,6 +137,7 @@ func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.Ge
|
||||
},
|
||||
)
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -233,7 +237,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
|
||||
}
|
||||
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
totalGroupNum, err := imdb.GetTotalGroupNum()
|
||||
@@ -244,7 +248,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
|
||||
resp.IncreaseGroupNum = increaseGroupNum
|
||||
resp.TotalGroupNum = totalGroupNum
|
||||
times := GetRangeDate(fromTime, toTime)
|
||||
log.NewInfo(req.OperationID, "times:", times)
|
||||
log.NewDebug(req.OperationID, "times:", times)
|
||||
wg := &sync.WaitGroup{}
|
||||
resp.IncreaseGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
||||
resp.TotalGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
||||
@@ -271,6 +275,7 @@ func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatisti
|
||||
}(wg, i, v)
|
||||
}
|
||||
wg.Wait()
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -278,6 +283,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
resp := &pbStatistics.GetMessageStatisticsResp{}
|
||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrArgs)
|
||||
@@ -292,6 +298,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
|
||||
resp.PrivateMessageNum = privateMessageNum
|
||||
resp.GroupMessageNum = groupMessageNum
|
||||
times := GetRangeDate(fromTime, toTime)
|
||||
@@ -326,7 +333,7 @@ func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatis
|
||||
}
|
||||
|
||||
func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistics.GetUserStatisticsReq) (*pbStatistics.GetUserStatisticsResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbStatistics.GetUserStatisticsResp{}
|
||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||
if err != nil {
|
||||
@@ -388,5 +395,6 @@ func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistic
|
||||
}(wg, i, v)
|
||||
}
|
||||
wg.Wait()
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -171,6 +170,7 @@ func (s *userServer) GetAllConversations(ctx context.Context, req *pbUser.GetAll
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetAllConversationsResp{Conversations: []*pbUser.Conversation{}}
|
||||
conversations, err := imdb.GetUserAllConversations(req.OwnerUserID)
|
||||
log.NewDebug(req.OperationID, "conversations: ", conversations)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
@@ -188,6 +188,7 @@ func (s *userServer) GetConversation(ctx context.Context, req *pbUser.GetConvers
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetConversationResp{Conversation: &pbUser.Conversation{}}
|
||||
conversation, err := imdb.GetConversation(req.OwnerUserID, req.ConversationID)
|
||||
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
@@ -205,6 +206,7 @@ func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConver
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetConversationsResp{Conversations: []*pbUser.Conversation{}}
|
||||
conversations, err := imdb.GetConversations(req.OwnerUserID, req.ConversationIDs)
|
||||
log.NewDebug("", utils.GetSelfFuncName(), "conversations", conversations)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||
@@ -232,6 +234,7 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
|
||||
return resp, nil
|
||||
}
|
||||
if groupInfo.Status == constant.GroupStatusDismissed && !req.Conversation.IsNotInGroup {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "group status is dismissed", groupInfo)
|
||||
errMsg := "group status is dismissed"
|
||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
|
||||
return resp, nil
|
||||
@@ -444,6 +447,7 @@ func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByN
|
||||
CurrentPage: req.Pagination.PageNumber,
|
||||
ShowNumber: req.Pagination.ShowNumber,
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -467,6 +471,7 @@ func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq
|
||||
CreateTime: user.CreateTime.String(),
|
||||
IsBlock: isBlock,
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -475,6 +480,7 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
||||
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
|
||||
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
for _, v := range users {
|
||||
@@ -488,16 +494,19 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
||||
IsBlock: isBlock,
|
||||
}
|
||||
resp.User = append(resp.User, user)
|
||||
} else {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UserIsBlock failed", err.Error())
|
||||
}
|
||||
}
|
||||
user := db.User{}
|
||||
nums, err := imdb.GetUsersCount(user)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error())
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error(), user)
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.UserNums = nums
|
||||
resp.Pagination = &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -507,7 +516,7 @@ func (s *userServer) ResignUser(ctx context.Context, req *pbUser.ResignUserReq)
|
||||
}
|
||||
|
||||
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
|
||||
log.NewInfo(req.OperationID, "AlterUser args ", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.AlterUserResp{}
|
||||
user := db.User{
|
||||
PhoneNumber: strconv.FormatInt(req.PhoneNumber, 10),
|
||||
@@ -520,11 +529,12 @@ func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
chat.UserInfoUpdatedNotification(req.OperationID, req.UserId, req.OpUserId)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
|
||||
log.NewInfo(req.OperationID, "AddUser args ", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.AddUserResp{}
|
||||
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name)
|
||||
if err != nil {
|
||||
@@ -535,8 +545,7 @@ func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUs
|
||||
}
|
||||
|
||||
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
|
||||
log.NewInfo(req.OperationID, "BlockUser args ", req.String())
|
||||
fmt.Println("BlockUser args ", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.BlockUserResp{}
|
||||
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
|
||||
if err != nil {
|
||||
@@ -547,7 +556,7 @@ func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*
|
||||
}
|
||||
|
||||
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
|
||||
log.NewInfo(req.OperationID, "UnBlockUser args ", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.UnBlockUserResp{}
|
||||
err := imdb.UnBlockUser(req.UserId)
|
||||
if err != nil {
|
||||
@@ -558,7 +567,7 @@ func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq
|
||||
}
|
||||
|
||||
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
|
||||
log.NewInfo(req.OperationID, "GetBlockUsers args ", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetBlockUsersResp{}
|
||||
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
if err != nil {
|
||||
@@ -586,11 +595,12 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.UserNums = nums
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUserByIdReq) (*pbUser.GetBlockUserByIdResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById args ", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetBlockUserByIdResp{}
|
||||
user, err := imdb.GetBlockUserById(req.UserId)
|
||||
if err != nil {
|
||||
@@ -607,6 +617,7 @@ func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUse
|
||||
BeginDisableTime: (user.BeginDisableTime).String(),
|
||||
EndDisableTime: (user.EndDisableTime).String(),
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user