diff --git a/go.mod b/go.mod index cc2da5157..ccb41a574 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module Open_IM -go 1.16 +go 1.18 require ( firebase.google.com/go v3.13.0+incompatible @@ -50,7 +50,6 @@ require ( go.mongodb.org/mongo-driver v1.8.3 golang.org/x/image v0.3.0 golang.org/x/net v0.5.0 - golang.org/x/tools v0.1.12 google.golang.org/api v0.103.0 google.golang.org/grpc v1.52.3 google.golang.org/protobuf v1.28.1 @@ -73,6 +72,14 @@ require ( go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.5.0 // indirect + golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/sys v0.4.0 // indirect + golang.org/x/text v0.6.0 // indirect + golang.org/x/time v0.1.0 // indirect + golang.org/x/tools v0.1.12 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/ini.v1 v1.66.2 // indirect diff --git a/internal/common/convert/convert.go b/internal/common/convert/convert.go index 588b3a731..7a4718a84 100644 --- a/internal/common/convert/convert.go +++ b/internal/common/convert/convert.go @@ -343,7 +343,7 @@ func (pb *PBUser) Convert() (*relation.UserModel, error) { dst := &relation.UserModel{} utils.CopyStructFields(dst, pb) dst.Birth = utils.UnixSecondToTime(pb.Birthday) - dst.CreateTime = utils.UnixSecondToTime(int64(pb.CreateTime)) + dst.CreateTime = utils.UnixSecondToTime(pb.CreateTime) return dst, nil } diff --git a/internal/rpc/friend/black.go b/internal/rpc/friend/black.go index d8626049d..55d4c396f 100644 --- a/internal/rpc/friend/black.go +++ b/internal/rpc/friend/black.go @@ -11,8 +11,8 @@ import ( "context" ) -func (s *friendServer) GetBlacks(ctx context.Context, req *pbFriend.GetBlacksReq) (*pbFriend.GetBlacksResp, error) { - resp := &pbFriend.GetBlacksResp{} +func (s *friendServer) GetPaginationBlacks(ctx context.Context, req *pbFriend.GetPaginationBlacksReq) (resp *pbFriend.GetPaginationBlacksResp, err error) { + resp = &pbFriend.GetPaginationBlacksResp{} if err := check.Access(ctx, req.UserID); err != nil { return nil, err } @@ -24,7 +24,6 @@ func (s *friendServer) GetBlacks(ctx context.Context, req *pbFriend.GetBlacksReq if err != nil { return nil, err } - resp.Total = int32(total) return resp, nil } diff --git a/internal/rpc/friend/friend.go b/internal/rpc/friend/friend.go index ae72cc0aa..11acc55e7 100644 --- a/internal/rpc/friend/friend.go +++ b/internal/rpc/friend/friend.go @@ -14,7 +14,6 @@ import ( "Open_IM/pkg/common/token_verify" "Open_IM/pkg/common/tracelog" pbFriend "Open_IM/pkg/proto/friend" - sdkws "Open_IM/pkg/proto/sdk_ws" pbUser "Open_IM/pkg/proto/user" "Open_IM/pkg/utils" "context" @@ -128,22 +127,22 @@ func (s *friendServer) Run() { } } -func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq) (*pbFriend.AddFriendResp, error) { - resp := &pbFriend.AddFriendResp{} +// ok +func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbFriend.ApplyToAddFriendReq) (resp *pbFriend.ApplyToAddFriendResp, err error) { + resp = &pbFriend.ApplyToAddFriendResp{} if err := token_verify.CheckAccessV3(ctx, req.FromUserID); err != nil { return nil, err } if err := callbackBeforeAddFriendV1(ctx, req); err != nil { return nil, err } - - //检查toUserID fromUserID是否存在 + if req.ToUserID == req.FromUserID { + return nil, constant.ErrCanNotAddYourself.Wrap() + } if _, err := check.GetUsersInfo(ctx, req.ToUserID, req.FromUserID); err != nil { return nil, err } - - //from是否在to的好友列表里面 - err, in1, in2 := s.FriendInterface.CheckIn(ctx, req.FromUserID, req.ToUserID) + in1, in2, err := s.FriendInterface.CheckIn(ctx, req.FromUserID, req.ToUserID) if err != nil { return nil, err } @@ -153,34 +152,36 @@ func (s *friendServer) AddFriend(ctx context.Context, req *pbFriend.AddFriendReq if err = s.FriendInterface.AddFriendRequest(ctx, req.FromUserID, req.ToUserID, req.ReqMsg, req.Ex); err != nil { return nil, err } - chat.FriendApplicationNotification(ctx, req) + chat.FriendApplicationAddNotification(ctx, req) return resp, nil } -func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFriendReq) (*pbFriend.ImportFriendResp, error) { - resp := &pbFriend.ImportFriendResp{} +// ok +func (s *friendServer) ImportFriends(ctx context.Context, req *pbFriend.ImportFriendReq) (resp *pbFriend.ImportFriendResp, err error) { + resp = &pbFriend.ImportFriendResp{} if err := token_verify.CheckAdmin(ctx); err != nil { return nil, err } - if _, err := check.GetUsersInfo(ctx, req.OwnerUserID); err != nil { + if _, err := check.GetUsersInfo(ctx, req.OwnerUserID, req.FriendUserIDs); err != nil { return nil, err } - var friends []*relation2.FriendModel - for _, userID := range utils.RemoveDuplicateElement(req.FriendUserIDs) { - friends = append(friends, &relation2.FriendModel{OwnerUserID: userID, FriendUserID: req.OwnerUserID, AddSource: constant.BecomeFriendByImport, OperatorUserID: tracelog.GetOpUserID(ctx)}) + if utils.Contain(req.FriendUserIDs, req.OwnerUserID) { + return nil, constant.ErrCanNotAddYourself.Wrap() } - if len(friends) > 0 { - if err := s.FriendInterface.BecomeFriend(ctx, friends); err != nil { - return nil, err - } + if utils.Duplicate(req.FriendUserIDs) { + return nil, constant.ErrArgs.Wrap("friend userID repeated") + } + + if err := s.FriendInterface.BecomeFriends(ctx, req.OwnerUserID, req.FriendUserIDs, constant.BecomeFriendByImport, tracelog.GetOpUserID(ctx)); err != nil { + return nil, err } return resp, nil } -// process Friend application -func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.RespondFriendApplyReq) (*pbFriend.RespondFriendApplyResp, error) { - resp := &pbFriend.RespondFriendApplyResp{} +// ok +func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.RespondFriendApplyReq) (resp *pbFriend.RespondFriendApplyResp, err error) { + resp = &pbFriend.RespondFriendApplyResp{} if err := check.Access(ctx, req.ToUserID); err != nil { return nil, err } @@ -190,7 +191,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res if err != nil { return nil, err } - chat.FriendApplicationApprovedNotification(ctx, req) + chat.FriendApplicationAgreedNotification(ctx, req) return resp, nil } if req.HandleResult == constant.FriendResponseRefuse { @@ -198,29 +199,39 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbFriend.Res if err != nil { return nil, err } - chat.FriendApplicationRejectedNotification(ctx, req) + chat.FriendApplicationRefusedNotification(ctx, req) return resp, nil } return nil, constant.ErrArgs.Wrap("req.HandleResult != -1/1") } -func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFriendReq) (*pbFriend.DeleteFriendResp, error) { - resp := &pbFriend.DeleteFriendResp{} +// ok +func (s *friendServer) DeleteFriend(ctx context.Context, req *pbFriend.DeleteFriendReq) (resp *pbFriend.DeleteFriendResp, err error) { + resp = &pbFriend.DeleteFriendResp{} if err := check.Access(ctx, req.OwnerUserID); err != nil { return nil, err } - if err := s.FriendInterface.Delete(ctx, req.OwnerUserID, req.FriendUserID); err != nil { + _, err = s.FindFriends(ctx, req.OwnerUserID, []string{req.FriendUserID}) + if err != nil { + return nil, err + } + if err := s.FriendInterface.Delete(ctx, req.OwnerUserID, []string{req.FriendUserID}); err != nil { return nil, err } chat.FriendDeletedNotification(ctx, req) return resp, nil } -func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFriendRemarkReq) (*pbFriend.SetFriendRemarkResp, error) { - resp := &pbFriend.SetFriendRemarkResp{} +// ok +func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFriendRemarkReq) (resp *pbFriend.SetFriendRemarkResp, err error) { + resp = &pbFriend.SetFriendRemarkResp{} if err := check.Access(ctx, req.OwnerUserID); err != nil { return nil, err } + _, err = s.FindFriends(ctx, req.OwnerUserID, []string{req.FriendUserID}) + if err != nil { + return nil, err + } if err := s.FriendInterface.UpdateRemark(ctx, req.OwnerUserID, req.FriendUserID, req.Remark); err != nil { return nil, err } @@ -228,8 +239,9 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbFriend.SetFri return resp, nil } -func (s *friendServer) GetFriends(ctx context.Context, req *pbFriend.GetFriendsReq) (*pbFriend.GetFriendsResp, error) { - resp := &pbFriend.GetFriendsResp{} +// ok +func (s *friendServer) GetDesignatedFriendsReq(ctx context.Context, req *pbFriend.GetDesignatedFriendsReq) (resp *pbFriend.GetDesignatedFriendsResp, err error) { + resp = &pbFriend.GetDesignatedFriendsResp{} if err := check.Access(ctx, req.UserID); err != nil { return nil, err } @@ -237,18 +249,6 @@ func (s *friendServer) GetFriends(ctx context.Context, req *pbFriend.GetFriendsR if err != nil { return nil, err } - userIDList := make([]string, 0, len(friends)) - for _, f := range friends { - userIDList = append(userIDList, f.FriendUserID) - } - users, err := check.GetUsersInfo(ctx, userIDList) - if err != nil { - return nil, err - } - userMap := make(map[string]*sdkws.UserInfo) - for i, user := range users { - userMap[user.UserID] = users[i] - } resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(friends) if err != nil { return nil, err @@ -257,9 +257,9 @@ func (s *friendServer) GetFriends(ctx context.Context, req *pbFriend.GetFriendsR return resp, nil } -// 获取接收到的好友申请(即别人主动申请的) -func (s *friendServer) GetToFriendsApply(ctx context.Context, req *pbFriend.GetToFriendsApplyReq) (*pbFriend.GetToFriendsApplyResp, error) { - resp := &pbFriend.GetToFriendsApplyResp{} +// ok 获取接收到的好友申请(即别人主动申请的) +func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbFriend.GetPaginationFriendsApplyToReq) (resp *pbFriend.GetPaginationFriendsApplyToResp, err error) { + resp = &pbFriend.GetPaginationFriendsApplyToResp{} if err := check.Access(ctx, req.UserID); err != nil { return nil, err } @@ -275,9 +275,9 @@ func (s *friendServer) GetToFriendsApply(ctx context.Context, req *pbFriend.GetT return resp, nil } -// 获取主动发出去的好友申请列表 -func (s *friendServer) GetFromFriendsApply(ctx context.Context, req *pbFriend.GetFromFriendsApplyReq) (*pbFriend.GetFromFriendsApplyResp, error) { - resp := &pbFriend.GetFromFriendsApplyResp{} +// ok 获取主动发出去的好友申请列表 +func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbFriend.GetPaginationFriendsApplyFromReq) (resp *pbFriend.GetPaginationFriendsApplyFromResp, err error) { + resp = &pbFriend.GetPaginationFriendsApplyFromResp{} if err := check.Access(ctx, req.UserID); err != nil { return nil, err } @@ -293,26 +293,28 @@ func (s *friendServer) GetFromFriendsApply(ctx context.Context, req *pbFriend.Ge return resp, nil } -func (s *friendServer) IsFriend(ctx context.Context, req *pbFriend.IsFriendReq) (*pbFriend.IsFriendResp, error) { - resp := &pbFriend.IsFriendResp{} - err, in1, in2 := s.FriendInterface.CheckIn(ctx, req.UserID1, req.UserID2) +// ok +func (s *friendServer) IsFriend(ctx context.Context, req *pbFriend.IsFriendReq) (resp *pbFriend.IsFriendResp, err error) { + resp = &pbFriend.IsFriendResp{} + resp.InUser1Friends, resp.InUser2Friends, err = s.FriendInterface.CheckIn(ctx, req.UserID1, req.UserID2) if err != nil { return nil, err } - resp.InUser1Friends = in1 - resp.InUser2Friends = in2 return resp, nil } -func (s *friendServer) GetFriendsInfo(ctx context.Context, req *pbFriend.GetFriendsInfoReq) (*pbFriend.GetFriendsInfoResp, error) { - resp := pbFriend.GetFriendsInfoResp{} +// ok +func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbFriend.GetPaginationFriendsReq) (resp *pbFriend.GetPaginationFriendsResp, err error) { + resp = &pbFriend.GetPaginationFriendsResp{} + if utils.Duplicate(req.FriendUserIDs) { + return nil, constant.ErrArgs.Wrap("friend userID repeated") + } friends, err := s.FriendInterface.FindFriends(ctx, req.OwnerUserID, req.FriendUserIDs) if err != nil { return nil, err } - resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(friends) - if err != nil { + if resp.FriendsInfo, err = (*convert.DBFriend)(nil).DB2PB(friends); err != nil { return nil, err } - return &resp, nil + return resp, nil } diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 683881ea3..a355271bc 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -22,6 +22,7 @@ import ( "fmt" "github.com/OpenIMSDK/getcdv3" grpcPrometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "math/big" "net" "strconv" "strings" @@ -256,32 +257,37 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo if err := token_verify.CheckAccessV3(ctx, req.FromUserID); err != nil { return nil, err } - total, groups, err := s.GroupInterface.FindJoinedGroup(ctx, req.FromUserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) + total, members, err := s.GroupInterface.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber) if err != nil { return nil, err } resp.Total = total - if len(groups) == 0 { + if len(members) == 0 { return resp, nil } - groupIDs := utils.Slice(groups, func(e *relation2.GroupModel) string { + groupIDs := utils.Slice(members, func(e *relation2.GroupMemberModel) string { return e.GroupID }) - groupMemberNum, err := s.GroupInterface.MapGroupMemberNum(ctx, groupIDs) + groups, err := s.GroupInterface.FindGroup(ctx, groupIDs) if err != nil { return nil, err } - groupOwnerUserID, err := s.GroupInterface.MapGroupOwnerUserID(ctx, groupIDs) + groupMemberNum, err := s.GroupInterface.MapGroupMemberNum(ctx, groupIDs) if err != nil { return nil, err } - for _, group := range groups { - if group.Status == constant.GroupStatusDismissed || group.GroupType == constant.SuperGroup { - continue - } - resp.Groups = append(resp.Groups, DbToPbGroupInfo(group, groupOwnerUserID[group.GroupID], uint32(groupMemberNum[group.GroupID]))) + owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner}) + if err != nil { + return nil, err } - resp.Total = int32(len(resp.Groups)) + ownerMap := utils.SliceToMap(owners, func(e *relation2.GroupMemberModel) string { + return e.GroupID + }) + resp.Groups = utils.Slice(utils.Order(groupIDs, groups, func(group *relation2.GroupModel) string { + return group.GroupID + }), func(group *relation2.GroupModel) *open_im_sdk.GroupInfo { + return DbToPbGroupInfo(group, ownerMap[group.GroupID].UserID, uint32(groupMemberNum[group.GroupID])) + }) return resp, nil } @@ -300,7 +306,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if group.Status == constant.GroupStatusDismissed { return nil, constant.ErrDismissedAlready.Wrap() } - members, err := s.GroupInterface.FindGroupMemberAll(ctx, group.GroupID) + members, err := s.GroupInterface.FindGroupMember(ctx, []string{group.GroupID}, nil, nil) if err != nil { return nil, err } @@ -350,7 +356,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite } } if group.GroupType == constant.SuperGroup { - if err := s.GroupInterface.AddUserToSuperGroup(ctx, req.GroupID, req.InvitedUserIDs); err != nil { + if err := s.GroupInterface.CreateSuperGroupMember(ctx, req.GroupID, req.InvitedUserIDs); err != nil { return nil, err } for _, userID := range req.InvitedUserIDs { @@ -371,7 +377,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite } groupMembers = append(groupMembers, member) } - if err := s.GroupInterface.CreateGroupMember(ctx, groupMembers); err != nil { + if err := s.GroupInterface.CreateGroup(ctx, nil, groupMembers); err != nil { return nil, err } chat.MemberInvitedNotification(tracelog.GetOperationID(ctx), req.GroupID, tracelog.GetOpUserID(ctx), req.Reason, req.InvitedUserIDs) @@ -388,7 +394,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro if group.GroupType == constant.SuperGroup { return nil, constant.ErrArgs.Wrap("unsupported super group") } - members, err := s.GroupInterface.FindGroupMemberAll(ctx, req.GroupID) + members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, nil, nil) if err != nil { return nil, err } @@ -400,10 +406,11 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGroupMemberListReq) (*pbGroup.GetGroupMemberListResp, error) { resp := &pbGroup.GetGroupMemberListResp{} - members, err := s.GroupInterface.FindGroupMemberFilterList(ctx, req.GroupID, req.Filter, req.Pagination.PageNumber, req.Pagination.ShowNumber) + total, members, err := s.GroupInterface.PageGroupMember(ctx, []string{req.GroupID}, nil, utils.If(req.Filter >= 0, []int32{req.Filter}, nil), req.Pagination.PageNumber, req.Pagination.ShowNumber) if err != nil { return nil, err } + resp.Total = total resp.Members = utils.Slice(members, func(e *relation2.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { return DbToPbGroupMembersCMSResp(e) }) @@ -436,7 +443,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou } }() } else { - members, err := s.GroupInterface.FindGroupMember(ctx, req.GroupID, append(req.KickedUserIDs, opUserID)) + members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, append(req.KickedUserIDs, opUserID), nil) if err != nil { return nil, err } @@ -479,7 +486,13 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetGroupMembersInfoReq) (*pbGroup.GetGroupMembersInfoResp, error) { resp := &pbGroup.GetGroupMembersInfoResp{} - members, err := s.GroupInterface.FindGroupMember(ctx, req.GroupID, req.Members) + if len(req.Members) == 0 { + return nil, constant.ErrArgs.Wrap("members empty") + } + if req.GroupID == "" { + return nil, constant.ErrArgs.Wrap("groupID empty") + } + members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, req.Members, nil) if err != nil { return nil, err } @@ -491,10 +504,11 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) { resp := &pbGroup.GetGroupApplicationListResp{} - groupRequests, err := s.GroupInterface.GetGroupRecvApplicationList(ctx, req.FromUserID) + total, groupRequests, err := s.GroupInterface.PageGroupRequestUser(ctx, req.FromUserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) if err != nil { return nil, err } + resp.Total = total if len(groupRequests) == 0 { return resp, nil } @@ -529,12 +543,15 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup. if err != nil { return nil, err } - groupOwnerUserIDMap, err := s.GroupInterface.MapGroupOwnerUserID(ctx, groupIDs) + owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner}) if err != nil { return nil, err } + ownerMap := utils.SliceToMap(owners, func(e *relation2.GroupMemberModel) string { + return e.GroupID + }) resp.GroupRequests = utils.Slice(groupRequests, func(e *relation2.GroupRequestModel) *open_im_sdk.GroupRequest { - return DbToPbGroupRequest(e, userMap[e.UserID], DbToPbGroupInfo(groupMap[e.GroupID], groupOwnerUserIDMap[e.GroupID], uint32(groupMemberNumMap[e.GroupID]))) + return DbToPbGroupRequest(e, userMap[e.UserID], DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID]))) }) return resp, nil } @@ -552,12 +569,15 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI if err != nil { return nil, err } - groupOwnerUserIDMap, err := s.GroupInterface.MapGroupOwnerUserID(ctx, req.GroupIDs) + owners, err := s.GroupInterface.FindGroupMember(ctx, req.GroupIDs, nil, []int32{constant.GroupOwner}) if err != nil { return nil, err } + ownerMap := utils.SliceToMap(owners, func(e *relation2.GroupMemberModel) string { + return e.GroupID + }) resp.GroupInfos = utils.Slice(groups, func(e *relation2.GroupModel) *open_im_sdk.GroupInfo { - return DbToPbGroupInfo(e, groupOwnerUserIDMap[e.GroupID], uint32(groupMemberNumMap[e.GroupID])) + return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID])) }) return resp, nil } @@ -657,7 +677,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if err := CallbackBeforeMemberJoinGroup(ctx, tracelog.GetOperationID(ctx), groupMember, group.Ex); err != nil { return nil, err } - if err := s.GroupInterface.CreateGroupMember(ctx, []*relation2.GroupMemberModel{groupMember}); err != nil { + if err := s.GroupInterface.CreateGroup(ctx, nil, []*relation2.GroupMemberModel{groupMember}); err != nil { return nil, err } chat.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) @@ -746,7 +766,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans if req.OldOwnerUserID == req.NewOwnerUserID { return nil, constant.ErrArgs.Wrap("OldOwnerUserID == NewOwnerUserID") } - members, err := s.GroupInterface.FindGroupMember(ctx, req.GroupID, []string{req.OldOwnerUserID, req.NewOwnerUserID}) + members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.GroupID}, []string{req.OldOwnerUserID, req.NewOwnerUserID}, nil) if err != nil { return nil, err } @@ -774,7 +794,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans return nil, constant.ErrNoPermission.Wrap(fmt.Sprintf("user %s no permission transfer group owner", tracelog.GetOpUserID(ctx))) } } - if err := s.GroupInterface.TransferGroupOwner(ctx, req.GroupID, req.OldOwnerUserID, req.NewOwnerUserID); err != nil { + if err := s.GroupInterface.TransferGroupOwner(ctx, req.GroupID, req.OldOwnerUserID, req.NewOwnerUserID, newOwner.RoleLevel); err != nil { return nil, err } chat.GroupOwnerTransferredNotification(req) @@ -799,7 +819,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq) groupIDs := utils.Slice(groups, func(e *relation2.GroupModel) string { return e.GroupID }) - ownerMembers, err := s.GroupInterface.FindGroupOwnerUser(ctx, groupIDs) + ownerMembers, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner}) if err != nil { return nil, err } @@ -822,7 +842,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq) func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) { resp := &pbGroup.GetGroupMembersCMSResp{} - total, members, err := s.GroupInterface.SearchGroupMember(ctx, req.GroupID, req.UserName, req.Pagination.PageNumber, req.Pagination.ShowNumber) + total, members, err := s.GroupInterface.SearchGroupMember(ctx, req.UserName, []string{req.GroupID}, nil, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber) if err != nil { return nil, err } @@ -839,7 +859,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou if err != nil { return nil, err } - total, requests, err := s.GroupInterface.FindUserGroupRequest(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) + total, requests, err := s.GroupInterface.PageGroupRequestUser(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) if err != nil { return nil, err } @@ -860,7 +880,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 { return nil, constant.ErrGroupIDNotFound.Wrap(strings.Join(ids, ",")) } - owners, err := s.GroupInterface.FindGroupOwnerUser(ctx, groupIDs) + owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner}) if err != nil { return nil, err } @@ -1034,16 +1054,16 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get if err != nil { return nil, err } - numMap, err := s.GroupInterface.MapGroupMemberNum(ctx, req.GroupIDs) - if err != nil { - return nil, err - } - hashMap, err := s.GroupInterface.MapGroupHash(ctx, req.GroupIDs) + groupUserMap, err := s.GroupInterface.MapGroupMemberUserID(ctx, req.GroupIDs) if err != nil { return nil, err } resp.GroupAbstractInfos = utils.Slice(groups, func(e *relation2.GroupModel) *pbGroup.GroupAbstractInfo { - return DbToPbGroupAbstractInfo(e.GroupID, int32(numMap[e.GroupID]), hashMap[e.GroupID]) + userIDs := groupUserMap[e.GroupID] + utils.Sort(userIDs, true) + bi := big.NewInt(0) + bi.SetString(utils.Md5(strings.Join(userIDs, ";;"))[0:8], 16) + return DbToPbGroupAbstractInfo(e.GroupID, int32(len(userIDs)), bi.Uint64()) }) return resp, nil } @@ -1053,7 +1073,7 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge if len(req.GroupIDs) == 0 { return nil, constant.ErrArgs.Wrap("groupIDs empty") } - members, err := s.GroupInterface.FindGroupMember(ctx, req.UserID, req.GroupIDs) + members, err := s.GroupInterface.FindGroupMember(ctx, []string{req.UserID}, req.GroupIDs, nil) if err != nil { return nil, err } diff --git a/internal/rpc/group/super_group.go b/internal/rpc/group/super_group.go index f462b3f50..5e0fc1892 100644 --- a/internal/rpc/group/super_group.go +++ b/internal/rpc/group/super_group.go @@ -23,10 +23,13 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup. if err != nil { return nil, err } - ownerIdMap, err := s.GroupInterface.MapGroupOwnerUserID(ctx, groupIDs) + owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner}) if err != nil { return nil, err } + ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string { + return e.GroupID + }) groups, err := s.GroupInterface.FindGroup(ctx, groupIDs) if err != nil { return nil, err @@ -35,7 +38,7 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup. return e.GroupID }) resp.Groups = utils.Slice(groupIDs, func(groupID string) *sdk_ws.GroupInfo { - return DbToPbGroupInfo(groupMap[groupID], ownerIdMap[groupID], numMap[groupID]) + return DbToPbGroupInfo(groupMap[groupID], ownerMap[groupID].UserID, numMap[groupID]) }) return resp, nil } @@ -53,12 +56,15 @@ func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSu if err != nil { return nil, err } - ownerIdMap, err := s.GroupInterface.MapGroupOwnerUserID(ctx, req.GroupIDs) + owners, err := s.GroupInterface.FindGroupMember(ctx, req.GroupIDs, nil, []int32{constant.GroupOwner}) if err != nil { return nil, err } + ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string { + return e.GroupID + }) resp.GroupInfos = utils.Slice(groups, func(e *relation.GroupModel) *sdk_ws.GroupInfo { - return DbToPbGroupInfo(e, ownerIdMap[e.GroupID], numMap[e.GroupID]) + return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, numMap[e.GroupID]) }) return resp, nil } diff --git a/internal/rpc/msg/friend_notification.go b/internal/rpc/msg/friend_notification.go index fe3979d5e..a61cd6b57 100644 --- a/internal/rpc/msg/friend_notification.go +++ b/internal/rpc/msg/friend_notification.go @@ -91,14 +91,14 @@ func friendNotification(operationID, fromUserID, toUserID string, contentType in Notification(&n) } -func FriendApplicationNotification(ctx context.Context, req *pbFriend.AddFriendReq) { +func FriendApplicationAddNotification(ctx context.Context, req *pbFriend.AddFriendReq) { FriendApplicationTips := open_im_sdk.FriendApplicationTips{FromToUserID: &open_im_sdk.FromToUserID{}} FriendApplicationTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationTips.FromToUserID.ToUserID = req.ToUserID friendNotification(tracelog.GetOperationID(ctx), req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &FriendApplicationTips) } -func FriendApplicationApprovedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { +func FriendApplicationAgreedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { FriendApplicationApprovedTips := open_im_sdk.FriendApplicationApprovedTips{FromToUserID: &open_im_sdk.FromToUserID{}} FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID @@ -106,7 +106,7 @@ func FriendApplicationApprovedNotification(ctx context.Context, req *pbFriend.Re friendNotification(tracelog.GetOperationID(ctx), req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &FriendApplicationApprovedTips) } -func FriendApplicationRejectedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { +func FriendApplicationRefusedNotification(ctx context.Context, req *pbFriend.RespondFriendApplyReq) { FriendApplicationApprovedTips := open_im_sdk.FriendApplicationApprovedTips{FromToUserID: &open_im_sdk.FromToUserID{}} FriendApplicationApprovedTips.FromToUserID.FromUserID = req.FromUserID FriendApplicationApprovedTips.FromToUserID.ToUserID = req.ToUserID diff --git a/internal/rpc/user/user.go b/internal/rpc/user/user.go index be40bc213..bec86a761 100644 --- a/internal/rpc/user/user.go +++ b/internal/rpc/user/user.go @@ -12,9 +12,9 @@ import ( promePkg "Open_IM/pkg/common/prometheus" "Open_IM/pkg/common/token_verify" "Open_IM/pkg/common/tracelog" - "Open_IM/pkg/getcdv3" pbFriend "Open_IM/pkg/proto/friend" pbGroup "Open_IM/pkg/proto/group" + server_api_params "Open_IM/pkg/proto/sdk_ws" pbUser "Open_IM/pkg/proto/user" "Open_IM/pkg/utils" "context" @@ -167,8 +167,9 @@ func (s *userServer) SyncJoinedGroupMemberNickname(ctx context.Context, userID s } } -func (s *userServer) GetUsersInfo(ctx context.Context, req *pbUser.GetUsersInfoReq) (*pbUser.GetUsersInfoResp, error) { - resp := &pbUser.GetUsersInfoResp{} +// ok +func (s *userServer) GetDesignateUsers(ctx context.Context, req *pbUser.GetDesignateUsersReq) (resp *pbUser.GetDesignateUsersResp, err error) { + resp = &pbUser.GetDesignateUsersResp{} users, err := s.Find(ctx, req.UserIDs) if err != nil { return nil, err @@ -228,21 +229,24 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI return &resp, nil } -func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbUser.SetGlobalRecvMessageOptReq) (*pbUser.SetGlobalRecvMessageOptResp, error) { - resp := pbUser.SetGlobalRecvMessageOptResp{} +func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbUser.SetGlobalRecvMessageOptReq) (resp *pbUser.SetGlobalRecvMessageOptResp, err error) { + resp = &pbUser.SetGlobalRecvMessageOptResp{} + + if _, err := s.Find(ctx, []string{req.UserID}); err != nil { + return nil, err + } m := make(map[string]interface{}, 1) m["global_recv_msg_opt"] = req.GlobalRecvMsgOpt - err := s.UpdateByMap(ctx, req.UserID, m) - if err != nil { + if err := s.UpdateByMap(ctx, req.UserID, m); err != nil { return nil, err } chat.UserInfoUpdatedNotification(ctx, req.UserID, req.UserID) - return &resp, nil + return resp, nil } -func (s *userServer) AccountCheck(ctx context.Context, req *pbUser.AccountCheckReq) (*pbUser.AccountCheckResp, error) { - resp := pbUser.AccountCheckResp{} - err := token_verify.CheckAdmin(ctx) +func (s *userServer) AccountCheck(ctx context.Context, req *pbUser.AccountCheckReq) (resp *pbUser.AccountCheckResp, err error) { + resp = &pbUser.AccountCheckResp{} + err = token_verify.CheckAdmin(ctx) if err != nil { return nil, err } @@ -250,72 +254,25 @@ func (s *userServer) AccountCheck(ctx context.Context, req *pbUser.AccountCheckR if err != nil { return nil, err } - uidList := make([]string, 0) + userIDs := make(map[string]interface{}, 0) for _, v := range user { - uidList = append(uidList, v.UserID) + userIDs[v.UserID] = nil } - var r []*pbUser.AccountCheckRespSingleUserStatus for _, v := range req.CheckUserIDs { - temp := new(pbUser.AccountCheckRespSingleUserStatus) - temp.UserID = v - if utils.IsContain(v, uidList) { + temp := &pbUser.AccountCheckRespSingleUserStatus{UserID: v} + if _, ok := userIDs[v]; ok { temp.AccountStatus = constant.Registered } else { temp.AccountStatus = constant.UnRegistered } - r = append(r, temp) + resp.Results = append(resp.Results, temp) } - return &resp, nil + return resp, nil } -func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pbUser.GetUsersResp, error) { - resp := pbUser.GetUsersResp{} - var err error - if req.UserID != "" { - u, err := s.Find(ctx, []string{req.UserID}) - if err != nil { - return nil, err - } - resp.Total = 1 - u1, err := convert.NewDBUser(u[0]).Convert() - if err != nil { - return nil, err - } - resp.Users = append(resp.Users, u1) - return &resp, nil - } - - if req.UserName != "" { - usersDB, total, err := s.GetByName(ctx, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber) - if err != nil { - return nil, err - } - resp.Total = int32(total) - for _, v := range usersDB { - u1, err := convert.NewDBUser(v).Convert() - if err != nil { - return nil, err - } - resp.Users = append(resp.Users, u1) - } - return &resp, nil - } else if req.Content != "" { - usersDB, total, err := s.GetByNameAndID(ctx, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber) - if err != nil { - return nil, err - } - resp.Total = int32(total) - for _, v := range usersDB { - u1, err := convert.NewDBUser(v).Convert() - if err != nil { - return nil, err - } - resp.Users = append(resp.Users, u1) - } - return &resp, nil - } - - usersDB, total, err := s.Get(ctx, req.Pagination.ShowNumber, req.Pagination.PageNumber) +func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbUser.GetPaginationUsersReq) (resp *pbUser.GetPaginationUsersResp, err error) { + resp = &pbUser.GetPaginationUsersResp{} + usersDB, total, err := s.Get(ctx, req.Pagination.PageNumber, req.Pagination.ShowNumber) if err != nil { return nil, err } @@ -329,21 +286,25 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb } resp.Users = append(resp.Users, u) } - return &resp, nil + return resp, nil } -func (s *userServer) UserRegister(ctx context.Context, req *pbUser.UserRegisterReq) (*pbUser.UserRegisterResp, error) { - resp := pbUser.UserRegisterResp{} +func (s *userServer) UserRegister(ctx context.Context, req *pbUser.UserRegisterReq) (resp *pbUser.UserRegisterResp, err error) { + resp = &pbUser.UserRegisterResp{} + if utils.DuplicateAny(req.Users, func(e *server_api_params.UserInfo) string { return e.UserID }) { + return nil, constant.ErrArgs.Wrap("userID repeated") + } userIDs := make([]string, 0) for _, v := range req.Users { userIDs = append(userIDs, v.UserID) } + exist, err := s.IsExist(ctx, userIDs) if err != nil { return nil, err } if exist { - return nil, constant.ErrRegisteredAlready.Wrap("exist") + return nil, constant.ErrRegisteredAlready.Wrap("userID exist in db") } users, err := (*convert.PBUser)(nil).PB2DB(req.Users) if err != nil { @@ -353,5 +314,5 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbUser.UserRegisterR if err != nil { return nil, err } - return &resp, nil + return resp, nil } diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 7bff14efa..e282a6c75 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -300,10 +300,8 @@ const ( ReliableNotificationMsg = 3 ) const ( - BecomeFriendByImport = 1 //管理员导入 - BecomeFriendByMyApply = 2 //自己主动申请添加 - BecomeFriendByPeerApply = 3 //对方主动申请添加 - BecomeFriendByApply = 4 //申请添加 + BecomeFriendByImport = 1 //管理员导入 + BecomeFriendByApply = 2 //申请添加 ) const ( diff --git a/pkg/common/constant/errors.go b/pkg/common/constant/errors.go index c34fe521b..8dc933b22 100644 --- a/pkg/common/constant/errors.go +++ b/pkg/common/constant/errors.go @@ -18,6 +18,7 @@ var ( ErrRelationshipAlready = &ErrInfo{RelationshipAlreadyError, "RelationshipAlreadyError", ""} ErrNotRelationshipYet = &ErrInfo{NotRelationshipYetError, "NotRelationshipYetError", ""} + ErrCanNotAddYourself = &ErrInfo{CanNotAddYourselfError, "CanNotAddYourselfError", ""} ErrOnlyOneOwner = &ErrInfo{OnlyOneOwnerError, "OnlyOneOwnerError", ""} ErrInGroupAlready = &ErrInfo{InGroupAlreadyError, "InGroupAlreadyError", ""} @@ -90,6 +91,7 @@ const ( const ( RelationshipAlreadyError = 92001 //已经是好友关系(或者黑名单) NotRelationshipYetError = 92002 //不是好友关系(或者黑名单) + CanNotAddYourselfError = 92003 //不能添加自己为好友 ) // 群组错误码 diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go index 04bc180dd..f236f31d3 100644 --- a/pkg/common/db/controller/friend.go +++ b/pkg/common/db/controller/friend.go @@ -6,33 +6,34 @@ import ( "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/utils" "context" + "errors" "gorm.io/gorm" ) type FriendInterface interface { - // CheckIn 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) + // 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) CheckIn(ctx context.Context, user1, user2 string) (inUser1Friends bool, inUser2Friends bool, err error) - // AddFriendRequest 增加或者更新好友申请 + // 增加或者更新好友申请 如果之前有记录则更新,没有记录则新增 AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) - // BecomeFriend 先判断是否在好友表,如果在则不插入 - BecomeFriend(ctx context.Context, friends []*relation.FriendModel, revFriends []*relation.FriendModel) (err error) - // RefuseFriendRequest 拒绝好友申请 + // (1)先判断是否在好友表 (在不在都不返回错误) (2)对于不在好友列表的 插入即可 + BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32, OperatorUserID string) (err error) + // 拒绝好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)修改申请记录 已拒绝 RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) - // AgreeFriendRequest 同意好友申请 + // 同意好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)检查是否好友(不返回错误) (3) 不是好友则建立双向好友关系 (4)修改申请记录 已同意 AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) - // Delete 删除好友 - Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error) - // UpdateRemark 更新好友备注 + // 删除好友 外部判断是否好友关系 + Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) + // 更新好友备注 零值也支持 UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) - // FindOwnerFriends 获取ownerUserID的好友列表 + // 获取ownerUserID的好友列表 无结果不返回错误 FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) - // FindInWhoseFriends friendUserID在哪些人的好友列表中 + // friendUserID在哪些人的好友列表中 FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) - // FindFriendRequestFromMe 获取我发出去的好友申请 + // 获取我发出去的好友申请 无结果不返回错误 FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) - // FindFriendRequestToMe 获取我收到的的好友申请 + // 获取我收到的的好友申请 无结果不返回错误 FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) - // FindFriends 获取某人指定好友的信息 如果有一个不存在也返回错误 + // 获取某人指定好友的信息 如果有一个不存在也返回错误 FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) } @@ -44,7 +45,7 @@ func NewFriendController(db *gorm.DB) *FriendController { return &FriendController{database: NewFriendDatabase(db)} } -// CheckIn 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) +// 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) func (f *FriendController) CheckIn(ctx context.Context, user1, user2 string) (inUser1Friends bool, inUser2Friends bool, err error) { return f.database.CheckIn(ctx, user1, user2) } @@ -55,8 +56,8 @@ func (f *FriendController) AddFriendRequest(ctx context.Context, fromUserID, toU } // BecomeFriend 先判断是否在好友表,如果在则不插入 -func (f *FriendController) BecomeFriend(ctx context.Context, ownerUserID string, friends []*relation.FriendModel) (err error) { - return f.database.BecomeFriend(ctx, ownerUserID, friends) +func (f *FriendController) BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32, OperatorUserID string) (err error) { + return f.database.BecomeFriends(ctx, ownerUserID, friendUserIDs, addSource, OperatorUserID) } // RefuseFriendRequest 拒绝好友申请 @@ -70,7 +71,7 @@ func (f *FriendController) AgreeFriendRequest(ctx context.Context, friendRequest } // Delete 删除好友 -func (f *FriendController) Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error) { +func (f *FriendController) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) { return f.database.Delete(ctx, ownerUserID, friendUserIDs) } @@ -102,33 +103,32 @@ func (f *FriendController) FindFriendRequestToMe(ctx context.Context, userID str // FindFriends 获取某人指定好友的信息 func (f *FriendController) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) { return f.database.FindFriends(ctx, ownerUserID, friendUserIDs) - } type FriendDatabaseInterface interface { - // CheckIn 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) + // 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) CheckIn(ctx context.Context, user1, user2 string) (inUser1Friends bool, inUser2Friends bool, err error) - // AddFriendRequest 增加或者更新好友申请 + // 增加或者更新好友申请 AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) - // BecomeFriend 先判断是否在好友表,如果在则不插入 - BecomeFriend(ctx context.Context, ownerUserID string, friends []*relation.FriendModel) (err error) - // RefuseFriendRequest 拒绝好友申请 + // 先判断是否在好友表,如果在则不插入 + BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32, OperatorUserID string) (err error) + // 拒绝好友申请 RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) - // AgreeFriendRequest 同意好友申请 + // 同意好友申请 AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) - // Delete 删除好友 - Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error) - // UpdateRemark 更新好友备注 + // 删除好友 + Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) + // 更新好友备注 UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) - // FindOwnerFriends 获取ownerUserID的好友列表 + // 获取ownerUserID的好友列表 FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) - // FindInWhoseFriends friendUserID在哪些人的好友列表中 + // friendUserID在哪些人的好友列表中 FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) - // FindFriendRequestFromMe 获取我发出去的好友申请 + // 获取我发出去的好友申请 FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) - // FindFriendRequestToMe 获取我收到的的好友申请 + // 获取我收到的的好友申请 FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) - // FindFriends 获取某人指定好友的信息 + // 获取某人指定好友的信息 FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) } @@ -141,9 +141,12 @@ func NewFriendDatabase(db *gorm.DB) *FriendDatabase { return &FriendDatabase{friend: relation1.NewFriendGorm(db), friendRequest: relation1.NewFriendRequestGorm(db)} } -// CheckIn 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) +// ok 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) func (f *FriendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Friends bool, inUser2Friends bool, err error) { friends, err := f.friend.FindUserState(ctx, userID1, userID2) + if err != nil { + return false, false, err + } for _, v := range friends { if v.OwnerUserID == userID1 && v.FriendUserID == userID2 { inUser1Friends = true @@ -155,14 +158,16 @@ func (f *FriendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) ( return } -// AddFriendRequest 增加或者更新好友申请 +// 增加或者更新好友申请 如果之前有记录则更新,没有记录则新增 func (f *FriendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) { return f.friendRequest.DB.Transaction(func(tx *gorm.DB) error { - fq, err := f.friendRequest.Find(ctx, fromUserID, toUserID, tx) - if err != nil { + _, err := f.friendRequest.Take(ctx, fromUserID, toUserID, tx) + //有db错误 + if err != nil && errors.Unwrap(err) != gorm.ErrRecordNotFound { return err } - if fq != nil { // + //无错误 则更新 + if err == nil { m := make(map[string]interface{}, 1) m["handle_result"] = 0 m["handle_msg"] = "" @@ -171,44 +176,45 @@ func (f *FriendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUse if err := f.friendRequest.UpdateByMap(ctx, fromUserID, toUserID, m, tx); err != nil { return err } - } else { - if err := f.friendRequest.Create(ctx, []*relation.FriendRequestModel{&relation.FriendRequestModel{FromUserID: fromUserID, ToUserID: toUserID, ReqMsg: reqMsg, Ex: ex}}, tx); err != nil { - return err - } + return nil + } + //gorm.ErrRecordNotFound 错误,则新增 + if err := f.friendRequest.Create(ctx, []*relation.FriendRequestModel{&relation.FriendRequestModel{FromUserID: fromUserID, ToUserID: toUserID, ReqMsg: reqMsg, Ex: ex}}, tx); err != nil { + return err } return nil }) } -// BecomeFriend 先判断是否在好友表,如果在则不插入 -func (f *FriendDatabase) BecomeFriend(ctx context.Context, ownerUserID string, friends []*relation.FriendModel) (err error) { +// (1)先判断是否在好友表 (在不在都不返回错误) (2)对于不在好友列表的 插入即可 +func (f *FriendDatabase) BecomeFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, addSource int32, OperatorUserID string) (err error) { return f.friend.DB.Transaction(func(tx *gorm.DB) error { //先find 找出重复的 去掉重复的 - friendUserIDs := make([]string, 0, len(friends)) - for _, v := range friends { - friendUserIDs = append(friendUserIDs, v.FriendUserID) - } fs1, err := f.friend.FindFriends(ctx, ownerUserID, friendUserIDs, tx) if err != nil { return err } - fs1 = append(fs1, friends...) + for _, v := range friendUserIDs { + fs1 = append(fs1, &relation.FriendModel{OwnerUserID: ownerUserID, FriendUserID: v, AddSource: addSource, OperatorUserID: OperatorUserID}) + } fs11 := utils.DistinctAny(fs1, func(e *relation.FriendModel) string { - return utils.UniqueJoin(e.OwnerUserID, e.FriendUserID) + return e.FriendUserID }) + err = f.friend.Create(ctx, fs11, tx) if err != nil { return err } + fs2, err := f.friend.FindReversalFriends(ctx, ownerUserID, friendUserIDs, tx) if err != nil { return err } - for _, v := range friends { - fs2 = append(fs2, &relation.FriendModel{OwnerUserID: v.FriendUserID, FriendUserID: ownerUserID}) + for _, v := range friendUserIDs { + fs2 = append(fs2, &relation.FriendModel{OwnerUserID: v, FriendUserID: ownerUserID, AddSource: addSource, OperatorUserID: OperatorUserID}) } fs22 := utils.DistinctAny(fs2, func(e *relation.FriendModel) string { - return utils.UniqueJoin(e.OwnerUserID, e.FriendUserID) + return e.OwnerUserID }) err = f.friend.Create(ctx, fs22, tx) if err != nil { @@ -218,8 +224,12 @@ func (f *FriendDatabase) BecomeFriend(ctx context.Context, ownerUserID string, f }) } -// RefuseFriendRequest 拒绝好友申请 +// 拒绝好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)修改申请记录 已拒绝 func (f *FriendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) { + _, err = f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID) + if err != nil { + return err + } friendRequest.HandleResult = constant.FriendResponseRefuse err = f.friendRequest.Update(ctx, []*relation.FriendRequestModel{friendRequest}) if err != nil { @@ -228,41 +238,52 @@ func (f *FriendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest return nil } -// AgreeFriendRequest 同意好友申请 +// 同意好友申请 (1)检查是否有申请记录且为未处理状态 (没有记录返回错误) (2)检查是否好友(不返回错误) (3) 不是好友则建立双向好友关系 (4)修改申请记录 已同意 func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) { return f.friend.DB.Transaction(func(tx *gorm.DB) error { + _, err = f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID) + if err != nil { + return err + } + friendRequest.HandlerUserID = friendRequest.FromUserID + friendRequest.HandleResult = constant.FriendResponseAgree + err = f.friendRequest.Update(ctx, []*relation.FriendRequestModel{friendRequest}, tx) + if err != nil { + return err + } + + ownerUserID := friendRequest.FromUserID + friendUserIDs := []string{friendRequest.ToUserID} + addSource := int32(constant.BecomeFriendByApply) + OperatorUserID := friendRequest.FromUserID //先find 找出重复的 去掉重复的 - fs1, err := f.friend.FindFriends(ctx, friendRequest.FromUserID, []string{friendRequest.ToUserID}, tx) + fs1, err := f.friend.FindFriends(ctx, ownerUserID, friendUserIDs, tx) if err != nil { return err } - if len(fs1) == 0 { - err = f.friend.Create(ctx, []*relation.FriendModel{ - &relation.FriendModel{ - OwnerUserID: friendRequest.FromUserID, - FriendUserID: friendRequest.ToUserID, - OperatorUserID: friendRequest.ToUserID, - AddSource: constant.BecomeFriendByApply, - }}, tx) - if err != nil { - return err - } + for _, v := range friendUserIDs { + fs1 = append(fs1, &relation.FriendModel{OwnerUserID: ownerUserID, FriendUserID: v, AddSource: addSource, OperatorUserID: OperatorUserID}) } - fs2, err := f.friend.FindReversalFriends(ctx, friendRequest.ToUserID, []string{friendRequest.FromUserID}, tx) - if len(fs2) == 0 { - err = f.friend.Create(ctx, []*relation.FriendModel{ - &relation.FriendModel{ - OwnerUserID: friendRequest.ToUserID, - FriendUserID: friendRequest.FromUserID, - OperatorUserID: friendRequest.ToUserID, - AddSource: constant.BecomeFriendByApply, - }}, tx) - if err != nil { - return err - } + fs11 := utils.DistinctAny(fs1, func(e *relation.FriendModel) string { + return e.FriendUserID + }) + + err = f.friend.Create(ctx, fs11, tx) + if err != nil { + return err } - friendRequest.HandleResult = constant.FriendResponseAgree - err = f.friendRequest.Update(ctx, []*relation.FriendRequestModel{friendRequest}, tx) + + fs2, err := f.friend.FindReversalFriends(ctx, ownerUserID, friendUserIDs, tx) + if err != nil { + return err + } + for _, v := range friendUserIDs { + fs2 = append(fs2, &relation.FriendModel{OwnerUserID: v, FriendUserID: ownerUserID, AddSource: addSource, OperatorUserID: OperatorUserID}) + } + fs22 := utils.DistinctAny(fs2, func(e *relation.FriendModel) string { + return e.OwnerUserID + }) + err = f.friend.Create(ctx, fs22, tx) if err != nil { return err } @@ -270,37 +291,37 @@ func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest * }) } -// Delete 删除好友 -func (f *FriendDatabase) Delete(ctx context.Context, ownerUserID string, friendUserID string) (err error) { - return f.friend.Delete(ctx, ownerUserID, friendUserID) +// 删除好友 外部判断是否好友关系 +func (f *FriendDatabase) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string) (err error) { + return f.friend.Delete(ctx, ownerUserID, friendUserIDs) } -// UpdateRemark 更新好友备注 +// 更新好友备注 零值也支持 func (f *FriendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) { return f.friend.UpdateRemark(ctx, ownerUserID, friendUserID, remark) } -// FindOwnerFriends 获取ownerUserID的好友列表 +// 获取ownerUserID的好友列表 无结果不返回错误 func (f *FriendDatabase) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) { return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber) } -// FindInWhoseFriends friendUserID在哪些人的好友列表中 +// friendUserID在哪些人的好友列表中 func (f *FriendDatabase) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) { return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber) } -// FindFriendRequestFromMe 获取我发出去的好友申请 +// 获取我发出去的好友申请 无结果不返回错误 func (f *FriendDatabase) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) { return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber) } -// FindFriendRequestToMe 获取我收到的的好友申请 +// 获取我收到的的好友申请 无结果不返回错误 func (f *FriendDatabase) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) { return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber) } -// FindFriends 获取某人指定好友的信息 如果有一个不存在,也返回错误 +// 获取某人指定好友的信息 如果有好友不存在,也返回错误 func (f *FriendDatabase) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) { friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs) if err != nil { diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go index f5931e0aa..d715e400b 100644 --- a/pkg/common/db/controller/group.go +++ b/pkg/common/db/controller/group.go @@ -9,6 +9,7 @@ import ( "Open_IM/pkg/common/db/unrelation" "Open_IM/pkg/utils" "context" + "fmt" "github.com/dtm-labs/rockscache" _ "github.com/dtm-labs/rockscache" "github.com/go-redis/redis/v8" @@ -16,43 +17,38 @@ import ( "gorm.io/gorm" ) +//type GroupInterface GroupDataBaseInterface + type GroupInterface interface { - // group - FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) - SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) + CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) - FindJoinedGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) + FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) + SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员 - // groupMember - CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupMemberModel) error + // GroupMember TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) - FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error) - FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error) - FindGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupMemberModel, error) // relation.GetGroupMemberByGroupID(req.GroupID, req.Filter, req.NextSeq, 30) - SearchGroupMember(ctx context.Context, groupID, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) - FindGroupOwnerUser(ctx context.Context, groupID []string) ([]*relation2.GroupMemberModel, error) - CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error + FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relation2.GroupMemberModel, error) + PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) + SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error - MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, error) - MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error) - MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) - TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string) error // 转让群 + MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error) + MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) + TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群 UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error - + // GroupRequest CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error - GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) // ? TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) - FindUserGroupRequest(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) - // superGroup + PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) + // SuperGroup TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error) + FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error DeleteSuperGroup(ctx context.Context, groupID string) error DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error - AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error - FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) + CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) } @@ -62,223 +58,147 @@ type GroupController struct { database GroupDataBaseInterface } -func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) { - //TODO implement me - panic("implement me") +func (g *GroupController) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error { + return g.database.CreateGroup(ctx, groups, groupMembers) } -func (g *GroupController) SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) { - //TODO implement me - panic("implement me") +func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) { + return g.TakeGroup(ctx, groupID) } -func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) { - //TODO implement me - panic("implement me") +func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) { + return g.database.FindGroup(ctx, groupIDs) } -func (g *GroupController) FindJoinedGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) { - //TODO implement me - panic("implement me") +func (g *GroupController) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) { + return g.database.SearchGroup(ctx, keyword, pageNumber, showNumber) } func (g *GroupController) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error { - //TODO implement me - panic("implement me") + return g.database.UpdateGroup(ctx, groupID, data) } func (g *GroupController) DismissGroup(ctx context.Context, groupID string) error { - //TODO implement me - panic("implement me") -} - -func (g *GroupController) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupMemberModel) error { - //TODO implement me - panic("implement me") + return g.database.DismissGroup(ctx, groupID) } func (g *GroupController) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) { - //TODO implement me - panic("implement me") -} - -func (g *GroupController) FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error) { - //TODO implement me - panic("implement me") -} - -func (g *GroupController) FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error) { - //TODO implement me - panic("implement me") + return g.database.TakeGroupMember(ctx, groupID, userID) } -func (g *GroupController) FindGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupMemberModel, error) { - //TODO implement me - panic("implement me") -} - -func (g *GroupController) SearchGroupMember(ctx context.Context, groupID, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) { - //TODO implement me - panic("implement me") +func (g *GroupController) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) { + return g.database.TakeGroupOwner(ctx, groupID) } -func (g *GroupController) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) { - //TODO implement me - panic("implement me") +func (g *GroupController) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relation2.GroupMemberModel, error) { + return g.database.FindGroupMember(ctx, groupIDs, userIDs, roleLevels) } -func (g *GroupController) FindGroupOwnerUser(ctx context.Context, groupID []string) ([]*relation2.GroupMemberModel, error) { - //TODO implement me - panic("implement me") +func (g *GroupController) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) { + return g.database.PageGroupMember(ctx, groupIDs, userIDs, roleLevels, pageNumber, showNumber) } -func (g *GroupController) CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error { - //TODO implement me - panic("implement me") +func (g *GroupController) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) { + return g.database.SearchGroupMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber) } func (g *GroupController) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error { - //TODO implement me - panic("implement me") + return g.database.HandlerGroupRequest(ctx, groupID, userID, handledMsg, handleResult, member) } func (g *GroupController) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error { - //TODO implement me - panic("implement me") + return g.database.DeleteGroupMember(ctx, groupID, userIDs) } -func (g *GroupController) MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, error) { - //TODO implement me - panic("implement me") +func (g *GroupController) MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error) { + return g.database.MapGroupMemberUserID(ctx, groupIDs) } -func (g *GroupController) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error) { - //TODO implement me - panic("implement me") +func (g *GroupController) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) { + return g.database.MapGroupMemberNum(ctx, groupIDs) } -func (g *GroupController) MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) { - //TODO implement me - panic("implement me") -} - -func (g *GroupController) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string) error { - //TODO implement me - panic("implement me") +func (g *GroupController) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error { + return g.database.TransferGroupOwner(ctx, groupID, oldOwnerUserID, newOwnerUserID, roleLevel) } func (g *GroupController) UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error { - //TODO implement me - panic("implement me") + return g.database.UpdateGroupMember(ctx, groupID, userID, data) } func (g *GroupController) CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error { - //TODO implement me - panic("implement me") -} - -func (g *GroupController) GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) { - //TODO implement me - panic("implement me") + return g.database.CreateGroupRequest(ctx, requests) } func (g *GroupController) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) { - //TODO implement me - panic("implement me") + return g.database.TakeGroupRequest(ctx, groupID, userID) } -func (g *GroupController) FindUserGroupRequest(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) { - //TODO implement me - panic("implement me") +func (g *GroupController) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) { + return g.database.PageGroupRequestUser(ctx, userID, pageNumber, showNumber) } func (g *GroupController) TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error) { - //TODO implement me - panic("implement me") + return g.database.TakeSuperGroup(ctx, groupID) +} + +func (g *GroupController) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) { + return g.database.FindJoinSuperGroup(ctx, userID, pageNumber, showNumber) } func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error { - //TODO implement me - panic("implement me") + return g.database.CreateSuperGroup(ctx, groupID, initMemberIDList) } func (g *GroupController) DeleteSuperGroup(ctx context.Context, groupID string) error { - //TODO implement me - panic("implement me") + return g.database.DeleteSuperGroup(ctx, groupID) } func (g *GroupController) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error { - //TODO implement me - panic("implement me") -} - -func (g *GroupController) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error { - //TODO implement me - panic("implement me") + return g.database.DeleteSuperGroupMember(ctx, groupID, userIDs) } -func (g *GroupController) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) { - //TODO implement me - panic("implement me") +func (g *GroupController) CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error { + return g.database.CreateSuperGroupMember(ctx, groupID, userIDs) } func (g *GroupController) MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) { - //TODO implement me - panic("implement me") + return g.database.MapSuperGroupMemberNum(ctx, groupIDs) } type GroupDataBaseInterface interface { - // group - FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) - SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) + CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) - FindJoinedGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) + FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) + SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员 - // groupMember - CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupMemberModel) error + // GroupMember TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) - FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error) - FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error) - FindGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupMemberModel, error) // relation.GetGroupMemberByGroupID(req.GroupID, req.Filter, req.NextSeq, 30) - SearchGroupMember(ctx context.Context, groupID, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) - FindGroupOwnerUser(ctx context.Context, groupID []string) ([]*relation2.GroupMemberModel, error) - CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error + FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relation2.GroupMemberModel, error) + PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) + SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error - MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, error) - MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error) - MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) - TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string) error // 转让群 + MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error) + MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) + TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群 UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error - + // GroupRequest CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error - GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) // ? TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) - FindUserGroupRequest(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) - // superGroup + PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) + // SuperGroup TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error) + FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error DeleteSuperGroup(ctx context.Context, groupID string) error DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error - AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error - FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) + CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) } -var _ *GroupDataBase = (GroupDataBaseInterface)(nil) - -type GroupDataBase struct { - groupDB *relation.GroupGorm - groupMemberDB *relation.GroupMemberGorm - groupRequestDB *relation.GroupRequestGorm - db *gorm.DB - - cache *cache.GroupCache - mongoDB *unrelation.SuperGroupMongoDriver -} - func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupDataBaseInterface { groupDB := relation.NewGroupDB(db) groupMemberDB := relation.NewGroupMemberDB(db) @@ -301,130 +221,16 @@ func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.C return database } -//func (g *GroupDataBase) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) { -// return g.cache.GetGroupsInfo(ctx, groupIDs) -//} -// -//func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error { -// return g.db.Transaction(func(tx *gorm.DB) error { -// if len(groups) > 0 { -// if err := g.groupDB.Create(ctx, groups, tx); err != nil { -// return err -// } -// } -// if len(groupMembers) > 0 { -// if err := g.groupMemberDB.Create(ctx, groupMembers, tx); err != nil { -// return err -// } -// } -// return nil -// }) -//} -// -//func (g *GroupDataBase) DeleteGroupByIDs(ctx context.Context, groupIDs []string) error { -// return g.groupDB.DB.Transaction(func(tx *gorm.DB) error { -// if err := g.groupDB.Delete(ctx, groupIDs, tx); err != nil { -// return err -// } -// if err := g.cache.DelGroupsInfo(ctx, groupIDs); err != nil { -// return err -// } -// return nil -// }) -//} -// -//func (g *GroupDataBase) TakeGroupByID(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) { -// return g.cache.GetGroupInfo(ctx, groupID) -//} -// -//func (g *GroupDataBase) Update(ctx context.Context, groups []*relation2.GroupModel) error { -// return g.db.Transaction(func(tx *gorm.DB) error { -// if err := g.groupDB.Update(ctx, groups, tx); err != nil { -// return err -// } -// var groupIDs []string -// for _, group := range groups { -// groupIDs = append(groupIDs, group.GroupID) -// } -// if err := g.cache.DelGroupsInfo(ctx, groupIDs); err != nil { -// return err -// } -// return nil -// }) -//} -// -//func (g *GroupDataBase) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation2.GroupModel, error) { -// -// return nil, nil -//} -// -//func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error { -// sess, err := g.mongoDB.MgoClient.StartSession() -// if err != nil { -// return err -// } -// defer sess.EndSession(ctx) -// sCtx := mongo.NewSessionContext(ctx, sess) -// if err = g.mongoDB.CreateSuperGroup(sCtx, groupID, initMemberIDList); err != nil { -// _ = sess.AbortTransaction(ctx) -// return err -// } -// -// if err = g.cache.BatchDelJoinedSuperGroupIDs(ctx, initMemberIDList); err != nil { -// _ = sess.AbortTransaction(ctx) -// return err -// } -// return sess.CommitTransaction(ctx) -//} -// -//func (g *GroupDataBase) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) { -// return g.mongoDB.GetSuperGroup(ctx, groupID) -//} - -func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) { - return g.groupDB.Find(ctx, groupIDs) -} - -func (g *GroupDataBase) SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) { - return g.groupDB.Search(ctx, name, pageNumber, showNumber) -} - -func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) { - return g.groupDB.Take(ctx, groupID) -} +var _ GroupDataBaseInterface = (*GroupDataBase)(nil) -func (g *GroupDataBase) FindJoinedGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) { - total, members, err := g.groupMemberDB.PageByUser(ctx, userID, pageNumber, showNumber) - if err != nil { - return 0, nil, err - } - if len(members) == 0 { - return total, []*relation2.GroupModel{}, nil - } - groupIDs := utils.Slice(members, func(e *relation2.GroupMemberModel) string { - return e.GroupID - }) - groups, err := g.groupDB.Find(ctx, groupIDs) - if err != nil { - return 0, nil, err - } - utils.OrderPtr(groupIDs, &groups, func(e *relation2.GroupModel) string { - return e.GroupID - }) - return total, groups, nil -} - -func (g *GroupDataBase) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error { - return g.groupDB.UpdateMap(ctx, groupID, data) -} +type GroupDataBase struct { + groupDB *relation.GroupGorm + groupMemberDB *relation.GroupMemberGorm + groupRequestDB *relation.GroupRequestGorm + db *gorm.DB -func (g *GroupDataBase) DismissGroup(ctx context.Context, groupID string) error { - return utils.Wrap(g.db.Transaction(func(tx *gorm.DB) error { - if err := g.groupDB.UpdateStatus(ctx, groupID, constant.GroupStatusDismissed, tx); err != nil { - return err - } - return g.groupMemberDB.DeleteGroup(ctx, []string{groupID}, tx) - }), "") + cache *cache.GroupCache + mongoDB *unrelation.SuperGroupMongoDriver } func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error { @@ -445,126 +251,154 @@ func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation2.Gro return nil } -func (g *GroupDataBase) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) { - return g.groupMemberDB.Take(ctx, groupID, userID) +func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) { + return g.groupDB.Take(ctx, groupID) } -func (g *GroupDataBase) FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error) { - return g.groupMemberDB.FindGroupUser(ctx, []string{groupID}, userIDs, nil) +func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) { + return g.groupDB.Find(ctx, groupIDs) } -func (g *GroupDataBase) FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error) { - return g.groupMemberDB.FindGroupUser(ctx, []string{groupID}, nil, nil) +func (g *GroupDataBase) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) { + return g.groupDB.Search(ctx, keyword, pageNumber, showNumber) } -func (g *GroupDataBase) FindGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupMemberModel, error) { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error { + return g.groupDB.UpdateMap(ctx, groupID, data) } -func (g *GroupDataBase) SearchGroupMember(ctx context.Context, groupID string, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) { - return g.groupMemberDB.SearchMember(ctx, groupID, name, pageNumber, showNumber) +func (g *GroupDataBase) DismissGroup(ctx context.Context, groupID string) error { + return g.db.Transaction(func(tx *gorm.DB) error { + if err := g.groupDB.UpdateStatus(ctx, groupID, constant.GroupStatusDismissed, tx); err != nil { + return err + } + return g.groupMemberDB.DeleteGroup(ctx, []string{groupID}, tx) + }) +} + +func (g *GroupDataBase) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) { + return g.groupMemberDB.Take(ctx, groupID, userID) } func (g *GroupDataBase) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) { return g.groupMemberDB.TakeOwner(ctx, groupID) } -func (g *GroupDataBase) FindGroupOwnerUser(ctx context.Context, groupIDs []string) ([]*relation2.GroupMemberModel, error) { - return g.groupMemberDB.FindGroupUser(ctx, groupIDs, nil, []int32{constant.GroupOwner}) +func (g *GroupDataBase) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relation2.GroupMemberModel, error) { + return g.groupMemberDB.Find(ctx, groupIDs, userIDs, roleLevels) } -func (g *GroupDataBase) CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) { + return g.groupMemberDB.SearchMember(ctx, "", groupIDs, userIDs, roleLevels, pageNumber, showNumber) } -func (g *GroupDataBase) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) { + return g.groupMemberDB.SearchMember(ctx, keyword, groupIDs, userIDs, roleLevels, pageNumber, showNumber) } -func (g *GroupDataBase) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error { + if member == nil { + return g.groupRequestDB.UpdateHandler(ctx, groupID, userID, handledMsg, handleResult) + } + return g.db.Transaction(func(tx *gorm.DB) error { + if err := g.groupRequestDB.UpdateHandler(ctx, groupID, userID, handledMsg, handleResult, tx); err != nil { + return err + } + return g.groupMemberDB.Create(ctx, []*relation2.GroupMemberModel{member}, tx) + }) } -func (g *GroupDataBase) MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, error) { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error { + return g.groupMemberDB.Delete(ctx, groupID, userIDs) } -func (g *GroupDataBase) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error) { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string][]string, error) { + return g.groupMemberDB.FindJoinUserID(ctx, groupIDs) } -func (g *GroupDataBase) MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) { + return g.groupMemberDB.MapGroupMemberNum(ctx, groupIDs) } -func (g *GroupDataBase) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string) error { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error { + return g.db.Transaction(func(tx *gorm.DB) error { + rowsAffected, err := g.groupMemberDB.UpdateRoleLevel(ctx, groupID, oldOwnerUserID, roleLevel, tx) + if err != nil { + return err + } + if rowsAffected != 1 { + return utils.Wrap(fmt.Errorf("oldOwnerUserID %s rowsAffected = %d", oldOwnerUserID, rowsAffected), "") + } + rowsAffected, err = g.groupMemberDB.UpdateRoleLevel(ctx, groupID, newOwnerUserID, constant.GroupOwner, tx) + if err != nil { + return err + } + if rowsAffected != 1 { + return utils.Wrap(fmt.Errorf("newOwnerUserID %s rowsAffected = %d", newOwnerUserID, rowsAffected), "") + } + return nil + }) } func (g *GroupDataBase) UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error { - //TODO implement me - panic("implement me") + return g.groupMemberDB.Update(ctx, groupID, userID, data) } func (g *GroupDataBase) CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error { - //TODO implement me - panic("implement me") -} - -func (g *GroupDataBase) GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) { - //TODO implement me - panic("implement me") + return g.groupRequestDB.Create(ctx, requests) } func (g *GroupDataBase) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) { - //TODO implement me - panic("implement me") + return g.groupRequestDB.Take(ctx, groupID, userID) } -func (g *GroupDataBase) FindUserGroupRequest(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) { + return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber) } func (g *GroupDataBase) TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error) { - //TODO implement me - panic("implement me") + return g.mongoDB.GetSuperGroup(ctx, groupID) +} + +func (g *GroupDataBase) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) { + return g.mongoDB.GetJoinGroup(ctx, userID, pageNumber, showNumber) } func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error { - //TODO implement me - panic("implement me") + return MongoTransaction(ctx, g.mongoDB.MgoClient, func(ctx mongo.SessionContext) error { + if err := g.mongoDB.CreateSuperGroup(ctx, groupID, initMemberIDList); err != nil { + return err + } + return g.cache.BatchDelJoinedSuperGroupIDs(ctx, initMemberIDList) + }) } func (g *GroupDataBase) DeleteSuperGroup(ctx context.Context, groupID string) error { - //TODO implement me - panic("implement me") + return g.mongoDB.DeleteSuperGroup(ctx, groupID) } func (g *GroupDataBase) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error { - //TODO implement me - panic("implement me") + return g.mongoDB.RemoverUserFromSuperGroup(ctx, groupID, userIDs) } -func (g *GroupDataBase) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error { + return g.mongoDB.AddUserToSuperGroup(ctx, groupID, userIDs) } -func (g *GroupDataBase) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) { - //TODO implement me - panic("implement me") +func (g *GroupDataBase) MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) { + return g.mongoDB.MapGroupMemberCount(ctx, groupIDs) } -func (g *GroupDataBase) MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) { - //TODO implement me - panic("implement me") +func MongoTransaction(ctx context.Context, mgo *mongo.Client, fn func(ctx mongo.SessionContext) error) error { + sess, err := mgo.StartSession() + if err != nil { + return err + } + sCtx := mongo.NewSessionContext(ctx, sess) + defer sess.EndSession(sCtx) + if err := fn(sCtx); err != nil { + _ = sess.AbortTransaction(sCtx) + return err + } + return utils.Wrap(sess.CommitTransaction(sCtx), "") } diff --git a/pkg/common/db/controller/user.go b/pkg/common/db/controller/user.go index 06a05f7ec..b6bf2dfbd 100644 --- a/pkg/common/db/controller/user.go +++ b/pkg/common/db/controller/user.go @@ -9,20 +9,16 @@ import ( ) type UserInterface interface { - //获取指定用户的信息 如果有记录未找到 也返回错误 + //获取指定用户的信息 如有userID未找到 也返回错误 Find(ctx context.Context, userIDs []string) (users []*relation2.UserModel, err error) - //插入 - Create(ctx context.Context, users []*relation2.UserModel) error - //更新 + //插入多条 外部保证userID 不重复 且在db中不存在 + Create(ctx context.Context, users []*relation2.UserModel) (err error) + //更新(非零值) 外部保证userID存在 Update(ctx context.Context, users []*relation2.UserModel) (err error) - //更新带零值的 + //更新(零值) 外部保证userID存在 UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) - //通过名字搜索 - GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) - //通过名字和id搜索 - GetByNameAndID(ctx context.Context, content string, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) - //获取,如果没找到,不不返回错误 - Get(ctx context.Context, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) + //获取,如果没找到,不返回错误 + Get(ctx context.Context, pageNumber, showNumber int32) (users []*relation2.UserModel, count int64, err error) //userIDs是否存在 只要有一个存在就为true IsExist(ctx context.Context, userIDs []string) (exist bool, err error) } @@ -45,20 +41,12 @@ func (u *UserController) UpdateByMap(ctx context.Context, userID string, args ma return u.database.UpdateByMap(ctx, userID, args) } -func (u *UserController) GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) { - return u.database.GetByName(ctx, userName, showNumber, pageNumber) -} - -func (u *UserController) GetByNameAndID(ctx context.Context, content string, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) { - return u.database.GetByNameAndID(ctx, content, showNumber, pageNumber) -} - -func (u *UserController) Get(ctx context.Context, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) { - return u.database.Get(ctx, showNumber, pageNumber) +func (u *UserController) Get(ctx context.Context, pageNumber, showNumber int32) (users []*relation2.UserModel, count int64, err error) { + return u.database.Get(ctx, pageNumber, showNumber) } func (u *UserController) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) { - return u.IsExist(ctx, userIDs) + return u.database.IsExist(ctx, userIDs) } func NewUserController(db *gorm.DB) *UserController { controller := &UserController{database: newUserDatabase(db)} @@ -70,27 +58,25 @@ type UserDatabaseInterface interface { Create(ctx context.Context, users []*relation2.UserModel) error Update(ctx context.Context, users []*relation2.UserModel) (err error) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) - GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) - GetByNameAndID(ctx context.Context, content string, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) - Get(ctx context.Context, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) + Get(ctx context.Context, pageNumber, showNumber int32) (users []*relation2.UserModel, count int64, err error) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) } type UserDatabase struct { - sqlDB *relation.UserGorm + user *relation.UserGorm } func newUserDatabase(db *gorm.DB) *UserDatabase { sqlDB := relation.NewUserGorm(db) database := &UserDatabase{ - sqlDB: sqlDB, + user: sqlDB, } return database } -// 获取指定用户的信息 如果有记录未找到 也返回错误 +// 获取指定用户的信息 如有userID未找到 也返回错误 func (u *UserDatabase) Find(ctx context.Context, userIDs []string) (users []*relation2.UserModel, err error) { - users, err = u.sqlDB.Find(ctx, userIDs) + users, err = u.user.Find(ctx, userIDs) if err != nil { return } @@ -100,33 +86,31 @@ func (u *UserDatabase) Find(ctx context.Context, userIDs []string) (users []*rel return } +// 插入多条 外部保证userID 不重复 且在db中不存在 func (u *UserDatabase) Create(ctx context.Context, users []*relation2.UserModel) (err error) { - return u.sqlDB.Create(ctx, users) + return u.user.Create(ctx, users) } +// 更新(非零值) 外部保证userID存在 func (u *UserDatabase) Update(ctx context.Context, users []*relation2.UserModel) (err error) { - return u.sqlDB.Update(ctx, users) + return u.user.Update(ctx, users) } + +// 更新(零值) 外部保证userID存在 func (u *UserDatabase) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) { - return u.sqlDB.UpdateByMap(ctx, userID, args) -} -func (u *UserDatabase) GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) { - return u.sqlDB.GetByName(ctx, userName, showNumber, pageNumber) -} -func (u *UserDatabase) GetByNameAndID(ctx context.Context, content string, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) { - return u.sqlDB.GetByNameAndID(ctx, content, showNumber, pageNumber) + return u.user.UpdateByMap(ctx, userID, args) } // 获取,如果没找到,不返回错误 func (u *UserDatabase) Get(ctx context.Context, showNumber, pageNumber int32) (users []*relation2.UserModel, count int64, err error) { - return u.sqlDB.Get(ctx, showNumber, pageNumber) + return u.user.Get(ctx, showNumber, pageNumber) } // userIDs是否存在 只要有一个存在就为true func (u *UserDatabase) IsExist(ctx context.Context, userIDs []string) (exist bool, err error) { - users, err := u.sqlDB.Find(ctx, userIDs) + users, err := u.user.Find(ctx, userIDs) if err != nil { - return + return false, err } if len(users) > 0 { return true, nil diff --git a/pkg/common/db/relation/friend_model_k.go b/pkg/common/db/relation/friend_model_k.go index 03c642cc4..d88d4c6b1 100644 --- a/pkg/common/db/relation/friend_model_k.go +++ b/pkg/common/db/relation/friend_model_k.go @@ -30,105 +30,106 @@ type FriendUser struct { Nickname string `gorm:"column:name;size:255"` } +// 插入多条记录 func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friends", friends) }() - return utils.Wrap(getDBConn(f.DB, tx).Model(&table.FriendModel{}).Create(&friends).Error, "") + return utils.Wrap(getDBConn(f.DB, tx).Create(&friends).Error, "") } -func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error) { +// 删除ownerUserID指定的好友 +func (f *FriendGorm) Delete(ctx context.Context, ownerUserID string, friendUserIDs []string, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserIDs", friendUserIDs) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserIDs", friendUserIDs) }() - err = utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ? and friend_user_id = ?", ownerUserID, friendUserIDs).Delete(&table.FriendModel{}).Error, "") + err = utils.Wrap(getDBConn(f.DB, tx).Where("owner_user_id = ? AND friend_user_id in ( ?)", ownerUserID, friendUserIDs).Delete(&relation.FriendModel{}).Error, "") return err } -func (f *FriendGorm) UpdateByMap(ctx context.Context, ownerUserID string, args map[string]interface{}) (err error) { +// 更新ownerUserID单个好友信息 更新零值 +func (f *FriendGorm) UpdateByMap(ctx context.Context, ownerUserID string, friendUserID string, args map[string]interface{}, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "args", args) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "args", args) }() - return utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ?", ownerUserID).Updates(args).Error, "") + return utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendModel{}).Where("owner_user_id = ? AND friend_user_id = ? ", ownerUserID, friendUserID).Updates(args).Error, "") } +// 更新好友信息的非零值 func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friends", friends) }() - return utils.Wrap(f.DB.Model(&table.FriendModel{}).Updates(&friends).Error, "") + return utils.Wrap(getDBConn(f.DB, tx).Updates(&friends).Error, "") } -func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) { +// 更新好友备注(也支持零值 ) +func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "remark", remark) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "remark", remark) }() - return utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ? and friend_user_id = ?", ownerUserID, friendUserID).Update("remark", remark).Error, "") -} - -func (f *FriendGorm) FindOwnerUserID(ctx context.Context, ownerUserID string) (friends []*relation.FriendModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friends", friends) - }() - return friends, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ?", ownerUserID).Find(&friends).Error, "") -} + if remark != "" { + return utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendModel{}).Where("owner_user_id = ? and friend_user_id = ?", ownerUserID, friendUserID).Update("remark", remark).Error, "") + } + m := make(map[string]interface{}, 1) + m["remark"] = "" + return utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendModel{}).Where("owner_user_id = ?", ownerUserID).Updates(m).Error, "") -func (f *FriendGorm) FindFriendUserID(ctx context.Context, friendUserID string) (friends []*relation.FriendModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "friends", friends) - }() - return friends, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("friend_user_id = ?", friendUserID).Find(&friends).Error, "") } -func (f *FriendGorm) Take(ctx context.Context, ownerUserID, friendUserID string) (friend *relation.FriendModel, err error) { - friend = &table.FriendModel{} - defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "friend", friend) - return friend, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error, "") +// 获取单个好友信息,如没找到 返回错误 +func (f *FriendGorm) Take(ctx context.Context, ownerUserID, friendUserID string, tx ...*gorm.DB) (friend *relation.FriendModel, err error) { + friend = &relation.FriendModel{} + defer tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "friend", *friend) + return friend, utils.Wrap(getDBConn(f.DB, tx).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error, "") } -func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string) (friends []*relation.FriendModel, err error) { +// 查找好友关系,如果是双向关系,则都返回 +func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "userID1", userID1, "userID2", userID2) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID1", userID1, "userID2", userID2, "friends", friends) }() - return friends, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("(owner_user_id = ? and friend_user_id = ?) or (owner_user_id = ? and friend_user_id = ?)", userID1, userID2, userID2, userID1).Find(&friends).Error, "") + return friends, utils.Wrap(getDBConn(f.DB, tx).Where("(owner_user_id = ? and friend_user_id = ?) or (owner_user_id = ? and friend_user_id = ?)", userID1, userID2, userID2, userID1).Find(&friends).Error, "") } -// 获取 owner的好友列表 如果不存在也不返回错误 +// 获取 owner指定的好友列表 如果有friendUserIDs不存在,也不返回错误 func (f *FriendGorm) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserIDs", friendUserIDs, "friends", friends) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "friendUserIDs", friendUserIDs, "friends", friends) }() return friends, utils.Wrap(getDBConn(f.DB, tx).Where("owner_user_id = ? AND friend_user_id in (?)", ownerUserID, friendUserIDs).Find(&friends).Error, "") } -// 获取哪些人添加了friendUserID 如果不存在也不返回错误 +// 获取哪些人添加了friendUserID 如果有ownerUserIDs不存在,也不返回错误 func (f *FriendGorm) FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "friends", friends) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friendUserID", friendUserID, "ownerUserIDs", ownerUserIDs, "friends", friends) }() return friends, utils.Wrap(getDBConn(f.DB, tx).Where("friend_user_id = ? AND owner_user_id in (?)", friendUserID, ownerUserIDs).Find(&friends).Error, "") } +// 获取ownerUserID好友列表 支持翻页 func (f *FriendGorm) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendModel, total int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total) }() - err = getDBConn(f.DB, tx).Model(f).Where("owner_user_id = ? ", ownerUserID).Count(&total).Error + err = getDBConn(f.DB, tx).Model(&relation.FriendModel{}).Where("owner_user_id = ? ", ownerUserID).Count(&total).Error if err != nil { return nil, 0, utils.Wrap(err, "") } - err = utils.Wrap(getDBConn(f.DB, tx).Model(f).Where("owner_user_id = ? ", ownerUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "") + err = utils.Wrap(getDBConn(f.DB, tx).Where("owner_user_id = ? ", ownerUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "") return } +// 获取哪些人添加了friendUserID 支持翻页 func (f *FriendGorm) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendModel, total int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friendUserID", friendUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total) }() - err = getDBConn(f.DB, tx).Model(f).Where("friend_user_id = ? ", friendUserID).Count(&total).Error + err = getDBConn(f.DB, tx).Model(&relation.FriendModel{}).Where("friend_user_id = ? ", friendUserID).Count(&total).Error if err != nil { return nil, 0, utils.Wrap(err, "") } - err = utils.Wrap(getDBConn(f.DB, tx).Model(f).Where("friend_user_id = ? ", friendUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "") + err = utils.Wrap(getDBConn(f.DB, tx).Where("friend_user_id = ? ", friendUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "") return } diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go index 9a2fa3365..b17017cbc 100644 --- a/pkg/common/db/relation/friend_request_model.go +++ b/pkg/common/db/relation/friend_request_model.go @@ -20,68 +20,80 @@ type FriendRequestGorm struct { DB *gorm.DB `gorm:"-"` } -func (f *FriendRequestGorm) Create(ctx context.Context, friends []*relation.FriendRequestModel, tx ...*gorm.DB) (err error) { +// 插入多条记录 +func (f *FriendRequestGorm) Create(ctx context.Context, friendRequests []*relation.FriendRequestModel, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friendRequests", friendRequests) }() - return utils.Wrap(f.DB.Model(&relation.FriendRequestModel{}).Create(&friends).Error, "") + return utils.Wrap(getDBConn(f.DB, tx).Create(&friendRequests).Error, "") } -func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID string) (err error) { +// 删除记录 +func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID string, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "fromUserID", fromUserID, "toUserID", toUserID) }() - return utils.Wrap(f.DB.Model(&relation.FriendRequestModel{}).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Delete(&relation.FriendRequestModel{}).Error, "") + return utils.Wrap(getDBConn(f.DB, tx).Where("from_user_id = ? AND to_user_id = ?", fromUserID, toUserID).Delete(&relation.FriendRequestModel{}).Error, "") } +// 更新零值 func (f *FriendRequestGorm) UpdateByMap(ctx context.Context, formUserID string, toUserID string, args map[string]interface{}, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "formUserID", formUserID, "toUserID", toUserID, "args", args) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "formUserID", formUserID, "toUserID", toUserID, "args", args) }() return utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? AND to_user_id ", formUserID, toUserID).Updates(args).Error, "") } +// 更新多条记录 (非零值) func (f *FriendRequestGorm) Update(ctx context.Context, friendRequests []*relation.FriendRequestModel, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendRequests", friendRequests) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "friendRequests", friendRequests) }() - return utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Updates(&friendRequests).Error, "") + return utils.Wrap(getDBConn(f.DB, tx).Updates(&friendRequests).Error, "") } -func (f *FriendRequestGorm) Take(ctx context.Context, fromUserID, toUserID string) (friend *relation.FriendRequestModel, err error) { - friend = &relation.FriendRequestModel{} - defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID, "friend", friend) - return friend, utils.Wrap(f.DB.Model(&relation.FriendRequestModel{}).Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Take(friend).Error, "") +// 获取来指定用户的好友申请 未找到 不返回错误 +func (f *FriendRequestGorm) Find(ctx context.Context, fromUserID, toUserID string, tx ...*gorm.DB) (friendRequest *relation.FriendRequestModel, err error) { + friendRequest = &relation.FriendRequestModel{} + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "fromUserID", fromUserID, "toUserID", toUserID, "friendRequest", *friendRequest) + }() + utils.Wrap(getDBConn(f.DB, tx).Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Find(friendRequest).Error, "") + return } -func (f *FriendRequestGorm) Find(ctx context.Context, fromUserID, toUserID string, tx ...*gorm.DB) (friend *relation.FriendRequestModel, err error) { - friend = &relation.FriendRequestModel{} - defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID, "friend", friend) - return friend, utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Find(friend).Error, "") +func (f *FriendRequestGorm) Take(ctx context.Context, fromUserID, toUserID string, tx ...*gorm.DB) (friendRequest *relation.FriendRequestModel, err error) { + friendRequest = &relation.FriendRequestModel{} + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "fromUserID", fromUserID, "toUserID", toUserID, "friendRequest", *friendRequest) + }() + utils.Wrap(getDBConn(f.DB, tx).Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Take(friendRequest).Error, "") + return } -func (f *FriendRequestGorm) FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendRequestModel, total int64, err error) { +// 获取toUserID收到的好友申请列表 +func (f *FriendRequestGorm) FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friendRequests []*relation.FriendRequestModel, total int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "toUserID", toUserID, "friends", friends) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "toUserID", toUserID, "friendRequests", friendRequests) }() err = getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("to_user_id = ? ", toUserID).Count(&total).Error if err != nil { return nil, 0, utils.Wrap(err, "") } - err = utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("to_user_id = ? ", toUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "") + err = utils.Wrap(getDBConn(f.DB, tx).Where("to_user_id = ? ", toUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friendRequests).Error, "") return } -func (f *FriendRequestGorm) FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendRequestModel, total int64, err error) { +// 获取fromUserID发出去的好友申请列表 +func (f *FriendRequestGorm) FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friendRequests []*relation.FriendRequestModel, total int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "friends", friends) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "fromUserID", fromUserID, "friendRequests", friendRequests) }() - err = getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? ", fromUserID).Count(&total).Error if err != nil { return nil, 0, utils.Wrap(err, "") } - err = utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? ", fromUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "") + err = utils.Wrap(getDBConn(f.DB, tx).Where("from_user_id = ? ", fromUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friendRequests).Error, "") return } diff --git a/pkg/common/db/relation/group_member_model_k.go b/pkg/common/db/relation/group_member_model_k.go index e137464b7..3f9a6bc62 100644 --- a/pkg/common/db/relation/group_member_model_k.go +++ b/pkg/common/db/relation/group_member_model_k.go @@ -24,13 +24,20 @@ func (g *GroupMemberGorm) Create(ctx context.Context, groupMemberList []*relatio return utils.Wrap(getDBConn(g.DB, tx).Create(&groupMemberList).Error, "") } -func (g *GroupMemberGorm) Delete(ctx context.Context, groupMembers []*relation.GroupMemberModel, tx ...*gorm.DB) (err error) { +func (g *GroupMemberGorm) Delete(ctx context.Context, groupID string, userIDs []string, tx ...*gorm.DB) (err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userIDs", userIDs) }() - return utils.Wrap(getDBConn(g.DB, tx).Delete(groupMembers).Error, "") + return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id in (?)", groupID, userIDs).Delete(&relation.GroupMemberModel{}).Error, "") } +//func (g *GroupMemberGorm) Delete(ctx context.Context, groupMembers []*relation.GroupMemberModel, tx ...*gorm.DB) (err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) +// }() +// return utils.Wrap(getDBConn(g.DB, tx).Delete(groupMembers).Error, "") +//} + func (g *GroupMemberGorm) DeleteGroup(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs) @@ -45,20 +52,38 @@ func (g *GroupMemberGorm) UpdateByMap(ctx context.Context, groupID string, userI return utils.Wrap(getDBConn(g.DB, tx).Model(&relation.GroupMemberModel{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).Error, "") } -func (g *GroupMemberGorm) Update(ctx context.Context, groupMembers []*relation.GroupMemberModel, tx ...*gorm.DB) (err error) { - defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers) }() - return utils.Wrap(getDBConn(g.DB, tx).Updates(&groupMembers).Error, "") +func (g *GroupMemberGorm) Update(ctx context.Context, groupID string, userID string, data map[string]any, tx ...*gorm.DB) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "data", data) + }() + return utils.Wrap(getDBConn(g.DB, tx).Model(&relation.GroupMemberModel{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(data).Error, "") } -func (g *GroupMemberGorm) Find(ctx context.Context, groupMembers []*relation.GroupMemberModel, tx ...*gorm.DB) (groupList []*relation.GroupMemberModel, err error) { +func (g *GroupMemberGorm) UpdateRoleLevel(ctx context.Context, groupID string, userID string, roleLevel int32, tx ...*gorm.DB) (rowsAffected int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMembers", groupMembers, "groupList", groupList) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "roleLevel", roleLevel) }() - var where [][]interface{} - for _, groupMember := range groupMembers { - where = append(where, []interface{}{groupMember.GroupID, groupMember.UserID}) + db := getDBConn(g.DB, tx).Model(&relation.GroupMemberModel{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(map[string]any{ + "role_level": roleLevel, + }) + return db.RowsAffected, utils.Wrap(db.Error, "") +} + +func (g *GroupMemberGorm) Find(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, tx ...*gorm.DB) (groupList []*relation.GroupMemberModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "userIDs", userIDs, "groupList", groupList) + }() + db := getDBConn(g.DB, tx) + if len(groupIDs) > 0 { + db = db.Where("group_id in (?)", groupIDs) + } + if len(userIDs) > 0 { + db = db.Where("user_id in (?)", userIDs) } - return groupList, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "") + if len(roleLevels) > 0 { + db = db.Where("role_level in (?)", roleLevels) + } + return groupList, utils.Wrap(db.Find(&groupList).Error, "") } func (g *GroupMemberGorm) FindGroupUser(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, tx ...*gorm.DB) (groupList []*relation.GroupMemberModel, err error) { @@ -94,16 +119,38 @@ func (g *GroupMemberGorm) TakeOwner(ctx context.Context, groupID string, tx ...* return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "") } -func (g *GroupMemberGorm) PageByUser(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groupList []*relation.GroupMemberModel, err error) { +func (g *GroupMemberGorm) SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groupList []*relation.GroupMemberModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "groupIDs", groupIDs, "userIDs", userIDs, "roleLevels", roleLevels, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList) + }() + db := getDBConn(g.DB, tx) + gormIn(&db, "group_id", groupIDs) + gormIn(&db, "user_id", userIDs) + gormIn(&db, "role_level", roleLevels) + return gormSearch[relation.GroupMemberModel](db, []string{"nickname"}, keyword, pageNumber, showNumber) +} + +func (g *GroupMemberGorm) MapGroupMemberNum(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (count map[string]uint32, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "total", total, "groupList", groupList) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "count", count) }() - return gormPage[relation.GroupMemberModel](getDBConn(g.DB, tx).Where("user_id = ?", userID), pageNumber, showNumber) + return mapCount(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs), "group_id") } -func (g *GroupMemberGorm) SearchMember(ctx context.Context, groupID string, name string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groupList []*relation.GroupMemberModel, err error) { +func (g *GroupMemberGorm) FindJoinUserID(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (groupUsers map[string][]string, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "name", name, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groupUsers", groupUsers) }() - return gormSearch[relation.GroupMemberModel](getDBConn(g.DB, tx).Where("group_id = ?", groupID), "nickname", name, pageNumber, showNumber) + var items []struct { + GroupID string `gorm:"group_id"` + UserID string `gorm:"user_id"` + } + if err := getDBConn(g.DB, tx).Model(&relation.GroupMemberModel{}).Where("group_id in (?)", groupIDs).Find(&items).Error; err != nil { + return nil, utils.Wrap(err, "") + } + groupUsers = make(map[string][]string) + for _, item := range items { + groupUsers[item.GroupID] = append(groupUsers[item.GroupID], item.UserID) + } + return groupUsers, nil } diff --git a/pkg/common/db/relation/group_model_k.go b/pkg/common/db/relation/group_model_k.go index 011632976..731c83fdd 100644 --- a/pkg/common/db/relation/group_model_k.go +++ b/pkg/common/db/relation/group_model_k.go @@ -66,9 +66,9 @@ func (g *GroupGorm) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (g return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "") } -func (g *GroupGorm) Search(ctx context.Context, name string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groups []*relation.GroupModel, err error) { +func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groups []*relation.GroupModel, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "name", name, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups) }() - return gormSearch[relation.GroupModel](getDBConn(g.DB, tx), "name", name, pageNumber, showNumber) + return gormSearch[relation.GroupModel](getDBConn(g.DB, tx), []string{"name"}, keyword, pageNumber, showNumber) } diff --git a/pkg/common/db/relation/group_request_model_k.go b/pkg/common/db/relation/group_request_model_k.go index d40f3ed4a..46c0f335e 100644 --- a/pkg/common/db/relation/group_request_model_k.go +++ b/pkg/common/db/relation/group_request_model_k.go @@ -32,11 +32,21 @@ func (g *GroupRequestGorm) Delete(ctx context.Context, groupRequests []*relation return utils.Wrap(getDBConn(g.DB, tx).Delete(&groupRequests).Error, utils.GetSelfFuncName()) } -func (g *GroupRequestGorm) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) { +func (g *GroupRequestGorm) UpdateMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args) }() - return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ? ", groupID, userID).Updates(args).Error, utils.GetSelfFuncName()) + return utils.Wrap(getDBConn(g.DB, tx).Model(&relation.GroupRequestModel{}).Where("group_id = ? and user_id = ? ", groupID, userID).Updates(args).Error, utils.GetSelfFuncName()) +} + +func (g *GroupRequestGorm) UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, tx ...*gorm.DB) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "handledMsg", handledMsg, "handleResult", handleResult) + }() + return utils.Wrap(getDBConn(g.DB, tx).Model(&relation.GroupRequestModel{}).Where("group_id = ? and user_id = ? ", groupID, userID).Updates(map[string]any{ + "handle_msg": handledMsg, + "handle_result": handleResult, + }).Error, utils.GetSelfFuncName()) } func (g *GroupRequestGorm) Update(ctx context.Context, groupRequests []*relation.GroupRequestModel, tx ...*gorm.DB) (err error) { @@ -64,3 +74,10 @@ func (g *GroupRequestGorm) Take(ctx context.Context, groupID string, userID stri }() return groupRequest, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error, utils.GetSelfFuncName()) } + +func (g *GroupRequestGorm) Page(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groups []*relation.GroupRequestModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups) + }() + return gormSearch[relation.GroupRequestModel](getDBConn(g.DB, tx).Where("user_id = ?", userID), nil, "", pageNumber, showNumber) +} diff --git a/pkg/common/db/relation/user_model_k.go b/pkg/common/db/relation/user_model_k.go index 72a850044..b8ed1a252 100644 --- a/pkg/common/db/relation/user_model_k.go +++ b/pkg/common/db/relation/user_model_k.go @@ -19,75 +19,84 @@ func NewUserGorm(db *gorm.DB) *UserGorm { return &user } +// 插入多条 func (u *UserGorm) Create(ctx context.Context, users []*relation.UserModel, tx ...*gorm.DB) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "users", users) }() - return utils.Wrap(getDBConn(u.DB, tx).Model(&relation.UserModel{}).Create(&users).Error, "") + return utils.Wrap(getDBConn(u.DB, tx).Create(&users).Error, "") } -func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error) { +// 更新用户信息 零值 +func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "args", args) }() - return utils.Wrap(u.DB.Model(&relation.UserModel{}).Where("user_id = ?", userID).Updates(args).Error, "") + return utils.Wrap(getDBConn(u.DB, tx).Model(&relation.UserModel{}).Where("user_id = ?", userID).Updates(args).Error, "") } -func (u *UserGorm) Update(ctx context.Context, users []*relation.UserModel) (err error) { +// 更新多个用户信息 非零值 +func (u *UserGorm) Update(ctx context.Context, users []*relation.UserModel, tx ...*gorm.DB) (err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "users", users) }() - return utils.Wrap(u.DB.Model(&relation.UserModel{}).Updates(&users).Error, "") + return utils.Wrap(getDBConn(u.DB, tx).Updates(&users).Error, "") } -func (u *UserGorm) Find(ctx context.Context, userIDs []string) (users []*relation.UserModel, err error) { +// 获取指定用户信息 不存在,也不返回错误 +func (u *UserGorm) Find(ctx context.Context, userIDs []string, tx ...*gorm.DB) (users []*relation.UserModel, err error) { defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userIDs", userIDs, "users", users) }() - err = utils.Wrap(u.DB.Model(&relation.UserModel{}).Where("user_id in (?)", userIDs).Find(&users).Error, "") + err = utils.Wrap(getDBConn(u.DB, tx).Where("user_id in (?)", userIDs).Find(&users).Error, "") return users, err } -func (u *UserGorm) Take(ctx context.Context, userID string) (user *relation.UserModel, err error) { +// 获取某个用户信息 不存在,则返回错误 +func (u *UserGorm) Take(ctx context.Context, userID string, tx ...*gorm.DB) (user *relation.UserModel, err error) { user = &relation.UserModel{} defer func() { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "user", *user) }() - err = utils.Wrap(u.DB.Model(&relation.UserModel{}).Where("user_id = ?", userID).Take(&user).Error, "") + err = utils.Wrap(getDBConn(u.DB, tx).Where("user_id = ?", userID).Take(&user).Error, "") return user, err } -func (u *UserGorm) GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation.UserModel, count int64, err error) { +// 通过名字查找用户 不存在,不返回错误 +func (u *UserGorm) GetByName(ctx context.Context, userName string, pageNumber, showNumber int32, tx ...*gorm.DB) (users []*relation.UserModel, count int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userName", userName, "showNumber", showNumber, "pageNumber", pageNumber, "users", users, "count", count) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userName", userName, "pageNumber", pageNumber, "showNumber", showNumber, "users", users, "count", count) }() - err = u.DB.Model(&relation.UserModel{}).Where(" name like ?", fmt.Sprintf("%%%s%%", userName)).Limit(int(showNumber)).Offset(int(showNumber * pageNumber)).Find(&users).Error + err = utils.Wrap(getDBConn(u.DB, tx).Model(&relation.UserModel{}).Where(" name like ?", fmt.Sprintf("%%%s%%", userName)).Count(&count).Error, "") if err != nil { - return nil, 0, utils.Wrap(err, "") + return } - return users, count, utils.Wrap(u.DB.Model(&relation.UserModel{}).Where(" name like ? ", fmt.Sprintf("%%%s%%", userName)).Count(&count).Error, "") + err = utils.Wrap(getDBConn(u.DB, tx).Model(&relation.UserModel{}).Where(" name like ?", fmt.Sprintf("%%%s%%", userName)).Limit(int(showNumber)).Offset(int(showNumber*pageNumber)).Find(&users).Error, "") + return } -func (u *UserGorm) GetByNameAndID(ctx context.Context, content string, showNumber, pageNumber int32) (users []*relation.UserModel, count int64, err error) { +// 通过名字或userID查找用户 不存在,不返回错误 +func (u *UserGorm) GetByNameAndID(ctx context.Context, content string, pageNumber, showNumber int32, tx ...*gorm.DB) (users []*relation.UserModel, count int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "content", content, "showNumber", showNumber, "pageNumber", pageNumber, "users", users) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "content", content, "pageNumber", pageNumber, "showNumber", showNumber, "users", users, "count", count) }() - db := u.DB.Model(&relation.UserModel{}).Where(" name like ? or user_id = ? ", fmt.Sprintf("%%%s%%", content), content) - if err := db.Model(&relation.UserModel{}).Count(&count).Error; err != nil { - return nil, 0, utils.Wrap(err, "") + db := getDBConn(u.DB, tx).Model(&relation.UserModel{}).Where(" name like ? or user_id = ? ", fmt.Sprintf("%%%s%%", content), content) + if err = db.Count(&count).Error; err != nil { + return } err = utils.Wrap(db.Limit(int(showNumber)).Offset(int(showNumber*pageNumber)).Find(&users).Error, "") return } -func (u *UserGorm) Get(ctx context.Context, showNumber, pageNumber int32) (users []*relation.UserModel, count int64, err error) { +// 获取用户信息 不存在,不返回错误 +func (u *UserGorm) Get(ctx context.Context, pageNumber, showNumber int32, tx ...*gorm.DB) (users []*relation.UserModel, count int64, err error) { defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "showNumber", showNumber, "pageNumber", pageNumber, "users", users, "count", count) + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "pageNumber", pageNumber, "showNumber", showNumber, "users", users, "count", count) }() - err = u.DB.Model(&relation.UserModel{}).Model(u).Count(&count).Error + err = utils.Wrap(getDBConn(u.DB, tx).Model(&relation.UserModel{}).Count(&count).Error, "") if err != nil { - return nil, 0, utils.Wrap(err, "") + return } - err = utils.Wrap(u.DB.Model(&relation.UserModel{}).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&users).Error, "") + err = utils.Wrap(getDBConn(u.DB, tx).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&users).Error, "") return } diff --git a/pkg/common/db/relation/utils.go b/pkg/common/db/relation/utils.go index 89ccb6552..83e5e7bd2 100644 --- a/pkg/common/db/relation/utils.go +++ b/pkg/common/db/relation/utils.go @@ -17,9 +17,40 @@ func gormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (int32, []*E, er return int32(count), es, nil } -func gormSearch[E any](db *gorm.DB, field string, value string, pageNumber, showNumber int32) (int32, []*E, error) { - if field != "" && value != "" { - db = db.Where(field+" like ?", "%"+value+"%") +func gormSearch[E any](db *gorm.DB, fields []string, value string, pageNumber, showNumber int32) (int32, []*E, error) { + if len(fields) > 0 && value != "" { + value = "%" + value + "%" + if len(fields) == 1 { + db = db.Where(fields[0]+" like ?", value) + } else { + t := db + for _, field := range fields { + t = t.Or(field+" like ?", value) + } + db = db.Where(t) + } } return gormPage[E](db, pageNumber, showNumber) } + +func gormIn[E any](db **gorm.DB, field string, es []E) { + if len(es) == 0 { + return + } + *db = (*db).Where(field+" in (?)", es) +} + +func mapCount(db *gorm.DB, field string) (map[string]uint32, error) { + var items []struct { + ID string `gorm:"column:id"` + Count uint32 `gorm:"column:count"` + } + if err := db.Select(field + " as id, count(1) as count").Group(field).Find(&items).Error; err != nil { + return nil, err + } + m := make(map[string]uint32) + for _, item := range items { + m[item.ID] = item.Count + } + return m, nil +} diff --git a/pkg/common/db/table/relation/friend.go b/pkg/common/db/table/relation/friend.go index 9c487c7ba..de00f7747 100644 --- a/pkg/common/db/table/relation/friend.go +++ b/pkg/common/db/table/relation/friend.go @@ -10,7 +10,7 @@ type FriendModel struct { OwnerUserID string `gorm:"column:owner_user_id;primary_key;size:64"` FriendUserID string `gorm:"column:friend_user_id;primary_key;size:64"` Remark string `gorm:"column:remark;size:255"` - CreateTime time.Time `gorm:"column:create_time"` + CreateTime time.Time `gorm:"column:create_time;autoCreateTime"` AddSource int32 `gorm:"column:add_source"` OperatorUserID string `gorm:"column:operator_user_id;size:64"` Ex string `gorm:"column:ex;size:1024"` diff --git a/pkg/common/db/table/relation/friend_request.go b/pkg/common/db/table/relation/friend_request.go index 715848a56..8a4ea2805 100644 --- a/pkg/common/db/table/relation/friend_request.go +++ b/pkg/common/db/table/relation/friend_request.go @@ -9,7 +9,7 @@ type FriendRequestModel struct { ToUserID string `gorm:"column:to_user_id;primary_key;size:64"` HandleResult int32 `gorm:"column:handle_result"` ReqMsg string `gorm:"column:req_msg;size:255"` - CreateTime time.Time `gorm:"column:create_time"` + CreateTime time.Time `gorm:"column:create_time; autoCreateTime"` HandlerUserID string `gorm:"column:handler_user_id;size:64"` HandleMsg string `gorm:"column:handle_msg;size:255"` HandleTime time.Time `gorm:"column:handle_time"` diff --git a/pkg/common/db/table/relation/user.go b/pkg/common/db/table/relation/user.go index 0009f4b86..2dd119e13 100644 --- a/pkg/common/db/table/relation/user.go +++ b/pkg/common/db/table/relation/user.go @@ -11,11 +11,12 @@ type UserModel struct { Nickname string `gorm:"column:name;size:255"` FaceURL string `gorm:"column:face_url;size:255"` Gender int32 `gorm:"column:gender"` + AreaCode string `gorm:"column:area_code;size:8" json:"areaCode"` PhoneNumber string `gorm:"column:phone_number;size:32"` Birth time.Time `gorm:"column:birth"` Email string `gorm:"column:email;size:64"` Ex string `gorm:"column:ex;size:1024"` - CreateTime time.Time `gorm:"column:create_time;index:create_time"` + CreateTime time.Time `gorm:"column:create_time;index:create_time; autoCreateTime"` AppMangerLevel int32 `gorm:"column:app_manger_level"` GlobalRecvMsgOpt int32 `gorm:"column:global_recv_msg_opt"` } diff --git a/pkg/common/db/unrelation/super_group.go b/pkg/common/db/unrelation/super_group.go index 9227494e2..e3a57d624 100644 --- a/pkg/common/db/unrelation/super_group.go +++ b/pkg/common/db/unrelation/super_group.go @@ -98,6 +98,16 @@ func (db *SuperGroupMongoDriver) GetSuperGroupByUserID(ctx context.Context, user return &user, utils.Wrap(err, "") } +func (db *SuperGroupMongoDriver) GetJoinGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []string, error) { + //TODO implement me + panic("implement me") +} + +func (db *SuperGroupMongoDriver) MapGroupMemberCount(ctx context.Context, groupIDs []string) (map[string]uint32, error) { + //TODO implement me + panic("implement me") +} + func (db *SuperGroupMongoDriver) DeleteSuperGroup(ctx context.Context, groupID string) error { opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) return db.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { diff --git a/pkg/proto/friend/friend.pb.go b/pkg/proto/friend/friend.pb.go index 03289db2b..33999ee33 100644 --- a/pkg/proto/friend/friend.pb.go +++ b/pkg/proto/friend/friend.pb.go @@ -24,7 +24,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package -type GetFriendsInfoReq struct { +type GetPaginationFriendsReq struct { OwnerUserID string `protobuf:"bytes,1,opt,name=ownerUserID" json:"ownerUserID,omitempty"` FriendUserIDs []string `protobuf:"bytes,2,rep,name=friendUserIDs" json:"friendUserIDs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -32,83 +32,83 @@ type GetFriendsInfoReq struct { XXX_sizecache int32 `json:"-"` } -func (m *GetFriendsInfoReq) Reset() { *m = GetFriendsInfoReq{} } -func (m *GetFriendsInfoReq) String() string { return proto.CompactTextString(m) } -func (*GetFriendsInfoReq) ProtoMessage() {} -func (*GetFriendsInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{0} +func (m *GetPaginationFriendsReq) Reset() { *m = GetPaginationFriendsReq{} } +func (m *GetPaginationFriendsReq) String() string { return proto.CompactTextString(m) } +func (*GetPaginationFriendsReq) ProtoMessage() {} +func (*GetPaginationFriendsReq) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{0} } -func (m *GetFriendsInfoReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFriendsInfoReq.Unmarshal(m, b) +func (m *GetPaginationFriendsReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationFriendsReq.Unmarshal(m, b) } -func (m *GetFriendsInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFriendsInfoReq.Marshal(b, m, deterministic) +func (m *GetPaginationFriendsReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationFriendsReq.Marshal(b, m, deterministic) } -func (dst *GetFriendsInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFriendsInfoReq.Merge(dst, src) +func (dst *GetPaginationFriendsReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationFriendsReq.Merge(dst, src) } -func (m *GetFriendsInfoReq) XXX_Size() int { - return xxx_messageInfo_GetFriendsInfoReq.Size(m) +func (m *GetPaginationFriendsReq) XXX_Size() int { + return xxx_messageInfo_GetPaginationFriendsReq.Size(m) } -func (m *GetFriendsInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetFriendsInfoReq.DiscardUnknown(m) +func (m *GetPaginationFriendsReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationFriendsReq.DiscardUnknown(m) } -var xxx_messageInfo_GetFriendsInfoReq proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationFriendsReq proto.InternalMessageInfo -func (m *GetFriendsInfoReq) GetOwnerUserID() string { +func (m *GetPaginationFriendsReq) GetOwnerUserID() string { if m != nil { return m.OwnerUserID } return "" } -func (m *GetFriendsInfoReq) GetFriendUserIDs() []string { +func (m *GetPaginationFriendsReq) GetFriendUserIDs() []string { if m != nil { return m.FriendUserIDs } return nil } -type GetFriendsInfoResp struct { +type GetPaginationFriendsResp struct { FriendsInfo []*sdk_ws.FriendInfo `protobuf:"bytes,1,rep,name=friendsInfo" json:"friendsInfo,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *GetFriendsInfoResp) Reset() { *m = GetFriendsInfoResp{} } -func (m *GetFriendsInfoResp) String() string { return proto.CompactTextString(m) } -func (*GetFriendsInfoResp) ProtoMessage() {} -func (*GetFriendsInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{1} +func (m *GetPaginationFriendsResp) Reset() { *m = GetPaginationFriendsResp{} } +func (m *GetPaginationFriendsResp) String() string { return proto.CompactTextString(m) } +func (*GetPaginationFriendsResp) ProtoMessage() {} +func (*GetPaginationFriendsResp) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{1} } -func (m *GetFriendsInfoResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFriendsInfoResp.Unmarshal(m, b) +func (m *GetPaginationFriendsResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationFriendsResp.Unmarshal(m, b) } -func (m *GetFriendsInfoResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFriendsInfoResp.Marshal(b, m, deterministic) +func (m *GetPaginationFriendsResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationFriendsResp.Marshal(b, m, deterministic) } -func (dst *GetFriendsInfoResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFriendsInfoResp.Merge(dst, src) +func (dst *GetPaginationFriendsResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationFriendsResp.Merge(dst, src) } -func (m *GetFriendsInfoResp) XXX_Size() int { - return xxx_messageInfo_GetFriendsInfoResp.Size(m) +func (m *GetPaginationFriendsResp) XXX_Size() int { + return xxx_messageInfo_GetPaginationFriendsResp.Size(m) } -func (m *GetFriendsInfoResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetFriendsInfoResp.DiscardUnknown(m) +func (m *GetPaginationFriendsResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationFriendsResp.DiscardUnknown(m) } -var xxx_messageInfo_GetFriendsInfoResp proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationFriendsResp proto.InternalMessageInfo -func (m *GetFriendsInfoResp) GetFriendsInfo() []*sdk_ws.FriendInfo { +func (m *GetPaginationFriendsResp) GetFriendsInfo() []*sdk_ws.FriendInfo { if m != nil { return m.FriendsInfo } return nil } -type AddFriendReq struct { +type ApplyToAddFriendReq struct { FromUserID string `protobuf:"bytes,1,opt,name=fromUserID" json:"fromUserID,omitempty"` ToUserID string `protobuf:"bytes,2,opt,name=toUserID" json:"toUserID,omitempty"` ReqMsg string `protobuf:"bytes,3,opt,name=reqMsg" json:"reqMsg,omitempty"` @@ -118,87 +118,87 @@ type AddFriendReq struct { XXX_sizecache int32 `json:"-"` } -func (m *AddFriendReq) Reset() { *m = AddFriendReq{} } -func (m *AddFriendReq) String() string { return proto.CompactTextString(m) } -func (*AddFriendReq) ProtoMessage() {} -func (*AddFriendReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{2} +func (m *ApplyToAddFriendReq) Reset() { *m = ApplyToAddFriendReq{} } +func (m *ApplyToAddFriendReq) String() string { return proto.CompactTextString(m) } +func (*ApplyToAddFriendReq) ProtoMessage() {} +func (*ApplyToAddFriendReq) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{2} } -func (m *AddFriendReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AddFriendReq.Unmarshal(m, b) +func (m *ApplyToAddFriendReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ApplyToAddFriendReq.Unmarshal(m, b) } -func (m *AddFriendReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AddFriendReq.Marshal(b, m, deterministic) +func (m *ApplyToAddFriendReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ApplyToAddFriendReq.Marshal(b, m, deterministic) } -func (dst *AddFriendReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_AddFriendReq.Merge(dst, src) +func (dst *ApplyToAddFriendReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_ApplyToAddFriendReq.Merge(dst, src) } -func (m *AddFriendReq) XXX_Size() int { - return xxx_messageInfo_AddFriendReq.Size(m) +func (m *ApplyToAddFriendReq) XXX_Size() int { + return xxx_messageInfo_ApplyToAddFriendReq.Size(m) } -func (m *AddFriendReq) XXX_DiscardUnknown() { - xxx_messageInfo_AddFriendReq.DiscardUnknown(m) +func (m *ApplyToAddFriendReq) XXX_DiscardUnknown() { + xxx_messageInfo_ApplyToAddFriendReq.DiscardUnknown(m) } -var xxx_messageInfo_AddFriendReq proto.InternalMessageInfo +var xxx_messageInfo_ApplyToAddFriendReq proto.InternalMessageInfo -func (m *AddFriendReq) GetFromUserID() string { +func (m *ApplyToAddFriendReq) GetFromUserID() string { if m != nil { return m.FromUserID } return "" } -func (m *AddFriendReq) GetToUserID() string { +func (m *ApplyToAddFriendReq) GetToUserID() string { if m != nil { return m.ToUserID } return "" } -func (m *AddFriendReq) GetReqMsg() string { +func (m *ApplyToAddFriendReq) GetReqMsg() string { if m != nil { return m.ReqMsg } return "" } -func (m *AddFriendReq) GetEx() string { +func (m *ApplyToAddFriendReq) GetEx() string { if m != nil { return m.Ex } return "" } -type AddFriendResp struct { +type ApplyToAddFriendResp struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *AddFriendResp) Reset() { *m = AddFriendResp{} } -func (m *AddFriendResp) String() string { return proto.CompactTextString(m) } -func (*AddFriendResp) ProtoMessage() {} -func (*AddFriendResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{3} +func (m *ApplyToAddFriendResp) Reset() { *m = ApplyToAddFriendResp{} } +func (m *ApplyToAddFriendResp) String() string { return proto.CompactTextString(m) } +func (*ApplyToAddFriendResp) ProtoMessage() {} +func (*ApplyToAddFriendResp) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{3} } -func (m *AddFriendResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AddFriendResp.Unmarshal(m, b) +func (m *ApplyToAddFriendResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ApplyToAddFriendResp.Unmarshal(m, b) } -func (m *AddFriendResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AddFriendResp.Marshal(b, m, deterministic) +func (m *ApplyToAddFriendResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ApplyToAddFriendResp.Marshal(b, m, deterministic) } -func (dst *AddFriendResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_AddFriendResp.Merge(dst, src) +func (dst *ApplyToAddFriendResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ApplyToAddFriendResp.Merge(dst, src) } -func (m *AddFriendResp) XXX_Size() int { - return xxx_messageInfo_AddFriendResp.Size(m) +func (m *ApplyToAddFriendResp) XXX_Size() int { + return xxx_messageInfo_ApplyToAddFriendResp.Size(m) } -func (m *AddFriendResp) XXX_DiscardUnknown() { - xxx_messageInfo_AddFriendResp.DiscardUnknown(m) +func (m *ApplyToAddFriendResp) XXX_DiscardUnknown() { + xxx_messageInfo_ApplyToAddFriendResp.DiscardUnknown(m) } -var xxx_messageInfo_AddFriendResp proto.InternalMessageInfo +var xxx_messageInfo_ApplyToAddFriendResp proto.InternalMessageInfo type ImportFriendReq struct { OwnerUserID string `protobuf:"bytes,1,opt,name=ownerUserID" json:"ownerUserID,omitempty"` @@ -212,7 +212,7 @@ func (m *ImportFriendReq) Reset() { *m = ImportFriendReq{} } func (m *ImportFriendReq) String() string { return proto.CompactTextString(m) } func (*ImportFriendReq) ProtoMessage() {} func (*ImportFriendReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{4} + return fileDescriptor_friend_b44dbd852f0b513f, []int{4} } func (m *ImportFriendReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ImportFriendReq.Unmarshal(m, b) @@ -256,7 +256,7 @@ func (m *ImportFriendResp) Reset() { *m = ImportFriendResp{} } func (m *ImportFriendResp) String() string { return proto.CompactTextString(m) } func (*ImportFriendResp) ProtoMessage() {} func (*ImportFriendResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{5} + return fileDescriptor_friend_b44dbd852f0b513f, []int{5} } func (m *ImportFriendResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ImportFriendResp.Unmarshal(m, b) @@ -276,7 +276,7 @@ func (m *ImportFriendResp) XXX_DiscardUnknown() { var xxx_messageInfo_ImportFriendResp proto.InternalMessageInfo -type GetToFriendsApplyReq struct { +type GetPaginationFriendsApplyToReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` Pagination *sdk_ws.RequestPagination `protobuf:"bytes,2,opt,name=pagination" json:"pagination,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -284,45 +284,45 @@ type GetToFriendsApplyReq struct { XXX_sizecache int32 `json:"-"` } -func (m *GetToFriendsApplyReq) Reset() { *m = GetToFriendsApplyReq{} } -func (m *GetToFriendsApplyReq) String() string { return proto.CompactTextString(m) } -func (*GetToFriendsApplyReq) ProtoMessage() {} -func (*GetToFriendsApplyReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{6} +func (m *GetPaginationFriendsApplyToReq) Reset() { *m = GetPaginationFriendsApplyToReq{} } +func (m *GetPaginationFriendsApplyToReq) String() string { return proto.CompactTextString(m) } +func (*GetPaginationFriendsApplyToReq) ProtoMessage() {} +func (*GetPaginationFriendsApplyToReq) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{6} } -func (m *GetToFriendsApplyReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetToFriendsApplyReq.Unmarshal(m, b) +func (m *GetPaginationFriendsApplyToReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationFriendsApplyToReq.Unmarshal(m, b) } -func (m *GetToFriendsApplyReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetToFriendsApplyReq.Marshal(b, m, deterministic) +func (m *GetPaginationFriendsApplyToReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationFriendsApplyToReq.Marshal(b, m, deterministic) } -func (dst *GetToFriendsApplyReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetToFriendsApplyReq.Merge(dst, src) +func (dst *GetPaginationFriendsApplyToReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationFriendsApplyToReq.Merge(dst, src) } -func (m *GetToFriendsApplyReq) XXX_Size() int { - return xxx_messageInfo_GetToFriendsApplyReq.Size(m) +func (m *GetPaginationFriendsApplyToReq) XXX_Size() int { + return xxx_messageInfo_GetPaginationFriendsApplyToReq.Size(m) } -func (m *GetToFriendsApplyReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetToFriendsApplyReq.DiscardUnknown(m) +func (m *GetPaginationFriendsApplyToReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationFriendsApplyToReq.DiscardUnknown(m) } -var xxx_messageInfo_GetToFriendsApplyReq proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationFriendsApplyToReq proto.InternalMessageInfo -func (m *GetToFriendsApplyReq) GetUserID() string { +func (m *GetPaginationFriendsApplyToReq) GetUserID() string { if m != nil { return m.UserID } return "" } -func (m *GetToFriendsApplyReq) GetPagination() *sdk_ws.RequestPagination { +func (m *GetPaginationFriendsApplyToReq) GetPagination() *sdk_ws.RequestPagination { if m != nil { return m.Pagination } return nil } -type GetToFriendsApplyResp struct { +type GetPaginationFriendsApplyToResp struct { FriendRequests []*sdk_ws.FriendRequest `protobuf:"bytes,1,rep,name=FriendRequests" json:"FriendRequests,omitempty"` Total int32 `protobuf:"varint,2,opt,name=total" json:"total,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -330,45 +330,45 @@ type GetToFriendsApplyResp struct { XXX_sizecache int32 `json:"-"` } -func (m *GetToFriendsApplyResp) Reset() { *m = GetToFriendsApplyResp{} } -func (m *GetToFriendsApplyResp) String() string { return proto.CompactTextString(m) } -func (*GetToFriendsApplyResp) ProtoMessage() {} -func (*GetToFriendsApplyResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{7} +func (m *GetPaginationFriendsApplyToResp) Reset() { *m = GetPaginationFriendsApplyToResp{} } +func (m *GetPaginationFriendsApplyToResp) String() string { return proto.CompactTextString(m) } +func (*GetPaginationFriendsApplyToResp) ProtoMessage() {} +func (*GetPaginationFriendsApplyToResp) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{7} } -func (m *GetToFriendsApplyResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetToFriendsApplyResp.Unmarshal(m, b) +func (m *GetPaginationFriendsApplyToResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationFriendsApplyToResp.Unmarshal(m, b) } -func (m *GetToFriendsApplyResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetToFriendsApplyResp.Marshal(b, m, deterministic) +func (m *GetPaginationFriendsApplyToResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationFriendsApplyToResp.Marshal(b, m, deterministic) } -func (dst *GetToFriendsApplyResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetToFriendsApplyResp.Merge(dst, src) +func (dst *GetPaginationFriendsApplyToResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationFriendsApplyToResp.Merge(dst, src) } -func (m *GetToFriendsApplyResp) XXX_Size() int { - return xxx_messageInfo_GetToFriendsApplyResp.Size(m) +func (m *GetPaginationFriendsApplyToResp) XXX_Size() int { + return xxx_messageInfo_GetPaginationFriendsApplyToResp.Size(m) } -func (m *GetToFriendsApplyResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetToFriendsApplyResp.DiscardUnknown(m) +func (m *GetPaginationFriendsApplyToResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationFriendsApplyToResp.DiscardUnknown(m) } -var xxx_messageInfo_GetToFriendsApplyResp proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationFriendsApplyToResp proto.InternalMessageInfo -func (m *GetToFriendsApplyResp) GetFriendRequests() []*sdk_ws.FriendRequest { +func (m *GetPaginationFriendsApplyToResp) GetFriendRequests() []*sdk_ws.FriendRequest { if m != nil { return m.FriendRequests } return nil } -func (m *GetToFriendsApplyResp) GetTotal() int32 { +func (m *GetPaginationFriendsApplyToResp) GetTotal() int32 { if m != nil { return m.Total } return 0 } -type GetFriendsReq struct { +type GetDesignatedFriendsReq struct { Pagination *sdk_ws.RequestPagination `protobuf:"bytes,1,opt,name=pagination" json:"pagination,omitempty"` UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -376,45 +376,45 @@ type GetFriendsReq struct { XXX_sizecache int32 `json:"-"` } -func (m *GetFriendsReq) Reset() { *m = GetFriendsReq{} } -func (m *GetFriendsReq) String() string { return proto.CompactTextString(m) } -func (*GetFriendsReq) ProtoMessage() {} -func (*GetFriendsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{8} +func (m *GetDesignatedFriendsReq) Reset() { *m = GetDesignatedFriendsReq{} } +func (m *GetDesignatedFriendsReq) String() string { return proto.CompactTextString(m) } +func (*GetDesignatedFriendsReq) ProtoMessage() {} +func (*GetDesignatedFriendsReq) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{8} } -func (m *GetFriendsReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFriendsReq.Unmarshal(m, b) +func (m *GetDesignatedFriendsReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetDesignatedFriendsReq.Unmarshal(m, b) } -func (m *GetFriendsReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFriendsReq.Marshal(b, m, deterministic) +func (m *GetDesignatedFriendsReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetDesignatedFriendsReq.Marshal(b, m, deterministic) } -func (dst *GetFriendsReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFriendsReq.Merge(dst, src) +func (dst *GetDesignatedFriendsReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetDesignatedFriendsReq.Merge(dst, src) } -func (m *GetFriendsReq) XXX_Size() int { - return xxx_messageInfo_GetFriendsReq.Size(m) +func (m *GetDesignatedFriendsReq) XXX_Size() int { + return xxx_messageInfo_GetDesignatedFriendsReq.Size(m) } -func (m *GetFriendsReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetFriendsReq.DiscardUnknown(m) +func (m *GetDesignatedFriendsReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetDesignatedFriendsReq.DiscardUnknown(m) } -var xxx_messageInfo_GetFriendsReq proto.InternalMessageInfo +var xxx_messageInfo_GetDesignatedFriendsReq proto.InternalMessageInfo -func (m *GetFriendsReq) GetPagination() *sdk_ws.RequestPagination { +func (m *GetDesignatedFriendsReq) GetPagination() *sdk_ws.RequestPagination { if m != nil { return m.Pagination } return nil } -func (m *GetFriendsReq) GetUserID() string { +func (m *GetDesignatedFriendsReq) GetUserID() string { if m != nil { return m.UserID } return "" } -type GetFriendsResp struct { +type GetDesignatedFriendsResp struct { FriendsInfo []*sdk_ws.FriendInfo `protobuf:"bytes,1,rep,name=FriendsInfo" json:"FriendsInfo,omitempty"` Total int32 `protobuf:"varint,2,opt,name=total" json:"total,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -422,38 +422,38 @@ type GetFriendsResp struct { XXX_sizecache int32 `json:"-"` } -func (m *GetFriendsResp) Reset() { *m = GetFriendsResp{} } -func (m *GetFriendsResp) String() string { return proto.CompactTextString(m) } -func (*GetFriendsResp) ProtoMessage() {} -func (*GetFriendsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{9} +func (m *GetDesignatedFriendsResp) Reset() { *m = GetDesignatedFriendsResp{} } +func (m *GetDesignatedFriendsResp) String() string { return proto.CompactTextString(m) } +func (*GetDesignatedFriendsResp) ProtoMessage() {} +func (*GetDesignatedFriendsResp) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{9} } -func (m *GetFriendsResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFriendsResp.Unmarshal(m, b) +func (m *GetDesignatedFriendsResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetDesignatedFriendsResp.Unmarshal(m, b) } -func (m *GetFriendsResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFriendsResp.Marshal(b, m, deterministic) +func (m *GetDesignatedFriendsResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetDesignatedFriendsResp.Marshal(b, m, deterministic) } -func (dst *GetFriendsResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFriendsResp.Merge(dst, src) +func (dst *GetDesignatedFriendsResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetDesignatedFriendsResp.Merge(dst, src) } -func (m *GetFriendsResp) XXX_Size() int { - return xxx_messageInfo_GetFriendsResp.Size(m) +func (m *GetDesignatedFriendsResp) XXX_Size() int { + return xxx_messageInfo_GetDesignatedFriendsResp.Size(m) } -func (m *GetFriendsResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetFriendsResp.DiscardUnknown(m) +func (m *GetDesignatedFriendsResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetDesignatedFriendsResp.DiscardUnknown(m) } -var xxx_messageInfo_GetFriendsResp proto.InternalMessageInfo +var xxx_messageInfo_GetDesignatedFriendsResp proto.InternalMessageInfo -func (m *GetFriendsResp) GetFriendsInfo() []*sdk_ws.FriendInfo { +func (m *GetDesignatedFriendsResp) GetFriendsInfo() []*sdk_ws.FriendInfo { if m != nil { return m.FriendsInfo } return nil } -func (m *GetFriendsResp) GetTotal() int32 { +func (m *GetDesignatedFriendsResp) GetTotal() int32 { if m != nil { return m.Total } @@ -472,7 +472,7 @@ func (m *AddBlackReq) Reset() { *m = AddBlackReq{} } func (m *AddBlackReq) String() string { return proto.CompactTextString(m) } func (*AddBlackReq) ProtoMessage() {} func (*AddBlackReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{10} + return fileDescriptor_friend_b44dbd852f0b513f, []int{10} } func (m *AddBlackReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AddBlackReq.Unmarshal(m, b) @@ -516,7 +516,7 @@ func (m *AddBlackResp) Reset() { *m = AddBlackResp{} } func (m *AddBlackResp) String() string { return proto.CompactTextString(m) } func (*AddBlackResp) ProtoMessage() {} func (*AddBlackResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{11} + return fileDescriptor_friend_b44dbd852f0b513f, []int{11} } func (m *AddBlackResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AddBlackResp.Unmarshal(m, b) @@ -548,7 +548,7 @@ func (m *RemoveBlackReq) Reset() { *m = RemoveBlackReq{} } func (m *RemoveBlackReq) String() string { return proto.CompactTextString(m) } func (*RemoveBlackReq) ProtoMessage() {} func (*RemoveBlackReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{12} + return fileDescriptor_friend_b44dbd852f0b513f, []int{12} } func (m *RemoveBlackReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RemoveBlackReq.Unmarshal(m, b) @@ -592,7 +592,7 @@ func (m *RemoveBlackResp) Reset() { *m = RemoveBlackResp{} } func (m *RemoveBlackResp) String() string { return proto.CompactTextString(m) } func (*RemoveBlackResp) ProtoMessage() {} func (*RemoveBlackResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{13} + return fileDescriptor_friend_b44dbd852f0b513f, []int{13} } func (m *RemoveBlackResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RemoveBlackResp.Unmarshal(m, b) @@ -612,7 +612,7 @@ func (m *RemoveBlackResp) XXX_DiscardUnknown() { var xxx_messageInfo_RemoveBlackResp proto.InternalMessageInfo -type GetBlacksReq struct { +type GetPaginationBlacksReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` Pagination *sdk_ws.RequestPagination `protobuf:"bytes,2,opt,name=pagination" json:"pagination,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -620,45 +620,45 @@ type GetBlacksReq struct { XXX_sizecache int32 `json:"-"` } -func (m *GetBlacksReq) Reset() { *m = GetBlacksReq{} } -func (m *GetBlacksReq) String() string { return proto.CompactTextString(m) } -func (*GetBlacksReq) ProtoMessage() {} -func (*GetBlacksReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{14} +func (m *GetPaginationBlacksReq) Reset() { *m = GetPaginationBlacksReq{} } +func (m *GetPaginationBlacksReq) String() string { return proto.CompactTextString(m) } +func (*GetPaginationBlacksReq) ProtoMessage() {} +func (*GetPaginationBlacksReq) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{14} } -func (m *GetBlacksReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetBlacksReq.Unmarshal(m, b) +func (m *GetPaginationBlacksReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationBlacksReq.Unmarshal(m, b) } -func (m *GetBlacksReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetBlacksReq.Marshal(b, m, deterministic) +func (m *GetPaginationBlacksReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationBlacksReq.Marshal(b, m, deterministic) } -func (dst *GetBlacksReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetBlacksReq.Merge(dst, src) +func (dst *GetPaginationBlacksReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationBlacksReq.Merge(dst, src) } -func (m *GetBlacksReq) XXX_Size() int { - return xxx_messageInfo_GetBlacksReq.Size(m) +func (m *GetPaginationBlacksReq) XXX_Size() int { + return xxx_messageInfo_GetPaginationBlacksReq.Size(m) } -func (m *GetBlacksReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetBlacksReq.DiscardUnknown(m) +func (m *GetPaginationBlacksReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationBlacksReq.DiscardUnknown(m) } -var xxx_messageInfo_GetBlacksReq proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationBlacksReq proto.InternalMessageInfo -func (m *GetBlacksReq) GetUserID() string { +func (m *GetPaginationBlacksReq) GetUserID() string { if m != nil { return m.UserID } return "" } -func (m *GetBlacksReq) GetPagination() *sdk_ws.RequestPagination { +func (m *GetPaginationBlacksReq) GetPagination() *sdk_ws.RequestPagination { if m != nil { return m.Pagination } return nil } -type GetBlacksResp struct { +type GetPaginationBlacksResp struct { Blacks []*sdk_ws.BlackInfo `protobuf:"bytes,1,rep,name=blacks" json:"blacks,omitempty"` Total int32 `protobuf:"varint,2,opt,name=total" json:"total,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -666,38 +666,38 @@ type GetBlacksResp struct { XXX_sizecache int32 `json:"-"` } -func (m *GetBlacksResp) Reset() { *m = GetBlacksResp{} } -func (m *GetBlacksResp) String() string { return proto.CompactTextString(m) } -func (*GetBlacksResp) ProtoMessage() {} -func (*GetBlacksResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{15} +func (m *GetPaginationBlacksResp) Reset() { *m = GetPaginationBlacksResp{} } +func (m *GetPaginationBlacksResp) String() string { return proto.CompactTextString(m) } +func (*GetPaginationBlacksResp) ProtoMessage() {} +func (*GetPaginationBlacksResp) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{15} } -func (m *GetBlacksResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetBlacksResp.Unmarshal(m, b) +func (m *GetPaginationBlacksResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationBlacksResp.Unmarshal(m, b) } -func (m *GetBlacksResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetBlacksResp.Marshal(b, m, deterministic) +func (m *GetPaginationBlacksResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationBlacksResp.Marshal(b, m, deterministic) } -func (dst *GetBlacksResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetBlacksResp.Merge(dst, src) +func (dst *GetPaginationBlacksResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationBlacksResp.Merge(dst, src) } -func (m *GetBlacksResp) XXX_Size() int { - return xxx_messageInfo_GetBlacksResp.Size(m) +func (m *GetPaginationBlacksResp) XXX_Size() int { + return xxx_messageInfo_GetPaginationBlacksResp.Size(m) } -func (m *GetBlacksResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetBlacksResp.DiscardUnknown(m) +func (m *GetPaginationBlacksResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationBlacksResp.DiscardUnknown(m) } -var xxx_messageInfo_GetBlacksResp proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationBlacksResp proto.InternalMessageInfo -func (m *GetBlacksResp) GetBlacks() []*sdk_ws.BlackInfo { +func (m *GetPaginationBlacksResp) GetBlacks() []*sdk_ws.BlackInfo { if m != nil { return m.Blacks } return nil } -func (m *GetBlacksResp) GetTotal() int32 { +func (m *GetPaginationBlacksResp) GetTotal() int32 { if m != nil { return m.Total } @@ -716,7 +716,7 @@ func (m *IsFriendReq) Reset() { *m = IsFriendReq{} } func (m *IsFriendReq) String() string { return proto.CompactTextString(m) } func (*IsFriendReq) ProtoMessage() {} func (*IsFriendReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{16} + return fileDescriptor_friend_b44dbd852f0b513f, []int{16} } func (m *IsFriendReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_IsFriendReq.Unmarshal(m, b) @@ -762,7 +762,7 @@ func (m *IsFriendResp) Reset() { *m = IsFriendResp{} } func (m *IsFriendResp) String() string { return proto.CompactTextString(m) } func (*IsFriendResp) ProtoMessage() {} func (*IsFriendResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{17} + return fileDescriptor_friend_b44dbd852f0b513f, []int{17} } func (m *IsFriendResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_IsFriendResp.Unmarshal(m, b) @@ -808,7 +808,7 @@ func (m *IsBlackReq) Reset() { *m = IsBlackReq{} } func (m *IsBlackReq) String() string { return proto.CompactTextString(m) } func (*IsBlackReq) ProtoMessage() {} func (*IsBlackReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{18} + return fileDescriptor_friend_b44dbd852f0b513f, []int{18} } func (m *IsBlackReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_IsBlackReq.Unmarshal(m, b) @@ -854,7 +854,7 @@ func (m *IsBlackResp) Reset() { *m = IsBlackResp{} } func (m *IsBlackResp) String() string { return proto.CompactTextString(m) } func (*IsBlackResp) ProtoMessage() {} func (*IsBlackResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{19} + return fileDescriptor_friend_b44dbd852f0b513f, []int{19} } func (m *IsBlackResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_IsBlackResp.Unmarshal(m, b) @@ -900,7 +900,7 @@ func (m *DeleteFriendReq) Reset() { *m = DeleteFriendReq{} } func (m *DeleteFriendReq) String() string { return proto.CompactTextString(m) } func (*DeleteFriendReq) ProtoMessage() {} func (*DeleteFriendReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{20} + return fileDescriptor_friend_b44dbd852f0b513f, []int{20} } func (m *DeleteFriendReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteFriendReq.Unmarshal(m, b) @@ -944,7 +944,7 @@ func (m *DeleteFriendResp) Reset() { *m = DeleteFriendResp{} } func (m *DeleteFriendResp) String() string { return proto.CompactTextString(m) } func (*DeleteFriendResp) ProtoMessage() {} func (*DeleteFriendResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{21} + return fileDescriptor_friend_b44dbd852f0b513f, []int{21} } func (m *DeleteFriendResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DeleteFriendResp.Unmarshal(m, b) @@ -979,7 +979,7 @@ func (m *RespondFriendApplyReq) Reset() { *m = RespondFriendApplyReq{} } func (m *RespondFriendApplyReq) String() string { return proto.CompactTextString(m) } func (*RespondFriendApplyReq) ProtoMessage() {} func (*RespondFriendApplyReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{22} + return fileDescriptor_friend_b44dbd852f0b513f, []int{22} } func (m *RespondFriendApplyReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RespondFriendApplyReq.Unmarshal(m, b) @@ -1037,7 +1037,7 @@ func (m *RespondFriendApplyResp) Reset() { *m = RespondFriendApplyResp{} func (m *RespondFriendApplyResp) String() string { return proto.CompactTextString(m) } func (*RespondFriendApplyResp) ProtoMessage() {} func (*RespondFriendApplyResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{23} + return fileDescriptor_friend_b44dbd852f0b513f, []int{23} } func (m *RespondFriendApplyResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_RespondFriendApplyResp.Unmarshal(m, b) @@ -1070,7 +1070,7 @@ func (m *SetFriendRemarkReq) Reset() { *m = SetFriendRemarkReq{} } func (m *SetFriendRemarkReq) String() string { return proto.CompactTextString(m) } func (*SetFriendRemarkReq) ProtoMessage() {} func (*SetFriendRemarkReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{24} + return fileDescriptor_friend_b44dbd852f0b513f, []int{24} } func (m *SetFriendRemarkReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetFriendRemarkReq.Unmarshal(m, b) @@ -1121,7 +1121,7 @@ func (m *SetFriendRemarkResp) Reset() { *m = SetFriendRemarkResp{} } func (m *SetFriendRemarkResp) String() string { return proto.CompactTextString(m) } func (*SetFriendRemarkResp) ProtoMessage() {} func (*SetFriendRemarkResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{25} + return fileDescriptor_friend_b44dbd852f0b513f, []int{25} } func (m *SetFriendRemarkResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetFriendRemarkResp.Unmarshal(m, b) @@ -1141,7 +1141,7 @@ func (m *SetFriendRemarkResp) XXX_DiscardUnknown() { var xxx_messageInfo_SetFriendRemarkResp proto.InternalMessageInfo -type GetFromFriendsApplyReq struct { +type GetPaginationFriendsApplyFromReq struct { UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` Pagination *sdk_ws.RequestPagination `protobuf:"bytes,2,opt,name=pagination" json:"pagination,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1149,45 +1149,45 @@ type GetFromFriendsApplyReq struct { XXX_sizecache int32 `json:"-"` } -func (m *GetFromFriendsApplyReq) Reset() { *m = GetFromFriendsApplyReq{} } -func (m *GetFromFriendsApplyReq) String() string { return proto.CompactTextString(m) } -func (*GetFromFriendsApplyReq) ProtoMessage() {} -func (*GetFromFriendsApplyReq) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{26} +func (m *GetPaginationFriendsApplyFromReq) Reset() { *m = GetPaginationFriendsApplyFromReq{} } +func (m *GetPaginationFriendsApplyFromReq) String() string { return proto.CompactTextString(m) } +func (*GetPaginationFriendsApplyFromReq) ProtoMessage() {} +func (*GetPaginationFriendsApplyFromReq) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{26} } -func (m *GetFromFriendsApplyReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFromFriendsApplyReq.Unmarshal(m, b) +func (m *GetPaginationFriendsApplyFromReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationFriendsApplyFromReq.Unmarshal(m, b) } -func (m *GetFromFriendsApplyReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFromFriendsApplyReq.Marshal(b, m, deterministic) +func (m *GetPaginationFriendsApplyFromReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationFriendsApplyFromReq.Marshal(b, m, deterministic) } -func (dst *GetFromFriendsApplyReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFromFriendsApplyReq.Merge(dst, src) +func (dst *GetPaginationFriendsApplyFromReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationFriendsApplyFromReq.Merge(dst, src) } -func (m *GetFromFriendsApplyReq) XXX_Size() int { - return xxx_messageInfo_GetFromFriendsApplyReq.Size(m) +func (m *GetPaginationFriendsApplyFromReq) XXX_Size() int { + return xxx_messageInfo_GetPaginationFriendsApplyFromReq.Size(m) } -func (m *GetFromFriendsApplyReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetFromFriendsApplyReq.DiscardUnknown(m) +func (m *GetPaginationFriendsApplyFromReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationFriendsApplyFromReq.DiscardUnknown(m) } -var xxx_messageInfo_GetFromFriendsApplyReq proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationFriendsApplyFromReq proto.InternalMessageInfo -func (m *GetFromFriendsApplyReq) GetUserID() string { +func (m *GetPaginationFriendsApplyFromReq) GetUserID() string { if m != nil { return m.UserID } return "" } -func (m *GetFromFriendsApplyReq) GetPagination() *sdk_ws.RequestPagination { +func (m *GetPaginationFriendsApplyFromReq) GetPagination() *sdk_ws.RequestPagination { if m != nil { return m.Pagination } return nil } -type GetFromFriendsApplyResp struct { +type GetPaginationFriendsApplyFromResp struct { FriendRequests []*sdk_ws.FriendRequest `protobuf:"bytes,1,rep,name=friendRequests" json:"friendRequests,omitempty"` Total int32 `protobuf:"varint,2,opt,name=total" json:"total,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1195,38 +1195,38 @@ type GetFromFriendsApplyResp struct { XXX_sizecache int32 `json:"-"` } -func (m *GetFromFriendsApplyResp) Reset() { *m = GetFromFriendsApplyResp{} } -func (m *GetFromFriendsApplyResp) String() string { return proto.CompactTextString(m) } -func (*GetFromFriendsApplyResp) ProtoMessage() {} -func (*GetFromFriendsApplyResp) Descriptor() ([]byte, []int) { - return fileDescriptor_friend_ae999c738a77e4f8, []int{27} +func (m *GetPaginationFriendsApplyFromResp) Reset() { *m = GetPaginationFriendsApplyFromResp{} } +func (m *GetPaginationFriendsApplyFromResp) String() string { return proto.CompactTextString(m) } +func (*GetPaginationFriendsApplyFromResp) ProtoMessage() {} +func (*GetPaginationFriendsApplyFromResp) Descriptor() ([]byte, []int) { + return fileDescriptor_friend_b44dbd852f0b513f, []int{27} } -func (m *GetFromFriendsApplyResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetFromFriendsApplyResp.Unmarshal(m, b) +func (m *GetPaginationFriendsApplyFromResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationFriendsApplyFromResp.Unmarshal(m, b) } -func (m *GetFromFriendsApplyResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetFromFriendsApplyResp.Marshal(b, m, deterministic) +func (m *GetPaginationFriendsApplyFromResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationFriendsApplyFromResp.Marshal(b, m, deterministic) } -func (dst *GetFromFriendsApplyResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetFromFriendsApplyResp.Merge(dst, src) +func (dst *GetPaginationFriendsApplyFromResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationFriendsApplyFromResp.Merge(dst, src) } -func (m *GetFromFriendsApplyResp) XXX_Size() int { - return xxx_messageInfo_GetFromFriendsApplyResp.Size(m) +func (m *GetPaginationFriendsApplyFromResp) XXX_Size() int { + return xxx_messageInfo_GetPaginationFriendsApplyFromResp.Size(m) } -func (m *GetFromFriendsApplyResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetFromFriendsApplyResp.DiscardUnknown(m) +func (m *GetPaginationFriendsApplyFromResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationFriendsApplyFromResp.DiscardUnknown(m) } -var xxx_messageInfo_GetFromFriendsApplyResp proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationFriendsApplyFromResp proto.InternalMessageInfo -func (m *GetFromFriendsApplyResp) GetFriendRequests() []*sdk_ws.FriendRequest { +func (m *GetPaginationFriendsApplyFromResp) GetFriendRequests() []*sdk_ws.FriendRequest { if m != nil { return m.FriendRequests } return nil } -func (m *GetFromFriendsApplyResp) GetTotal() int32 { +func (m *GetPaginationFriendsApplyFromResp) GetTotal() int32 { if m != nil { return m.Total } @@ -1234,22 +1234,22 @@ func (m *GetFromFriendsApplyResp) GetTotal() int32 { } func init() { - proto.RegisterType((*GetFriendsInfoReq)(nil), "friend.getFriendsInfoReq") - proto.RegisterType((*GetFriendsInfoResp)(nil), "friend.getFriendsInfoResp") - proto.RegisterType((*AddFriendReq)(nil), "friend.addFriendReq") - proto.RegisterType((*AddFriendResp)(nil), "friend.addFriendResp") + proto.RegisterType((*GetPaginationFriendsReq)(nil), "friend.getPaginationFriendsReq") + proto.RegisterType((*GetPaginationFriendsResp)(nil), "friend.getPaginationFriendsResp") + proto.RegisterType((*ApplyToAddFriendReq)(nil), "friend.applyToAddFriendReq") + proto.RegisterType((*ApplyToAddFriendResp)(nil), "friend.applyToAddFriendResp") proto.RegisterType((*ImportFriendReq)(nil), "friend.importFriendReq") proto.RegisterType((*ImportFriendResp)(nil), "friend.importFriendResp") - proto.RegisterType((*GetToFriendsApplyReq)(nil), "friend.getToFriendsApplyReq") - proto.RegisterType((*GetToFriendsApplyResp)(nil), "friend.getToFriendsApplyResp") - proto.RegisterType((*GetFriendsReq)(nil), "friend.getFriendsReq") - proto.RegisterType((*GetFriendsResp)(nil), "friend.getFriendsResp") + proto.RegisterType((*GetPaginationFriendsApplyToReq)(nil), "friend.getPaginationFriendsApplyToReq") + proto.RegisterType((*GetPaginationFriendsApplyToResp)(nil), "friend.getPaginationFriendsApplyToResp") + proto.RegisterType((*GetDesignatedFriendsReq)(nil), "friend.getDesignatedFriendsReq") + proto.RegisterType((*GetDesignatedFriendsResp)(nil), "friend.getDesignatedFriendsResp") proto.RegisterType((*AddBlackReq)(nil), "friend.addBlackReq") proto.RegisterType((*AddBlackResp)(nil), "friend.addBlackResp") proto.RegisterType((*RemoveBlackReq)(nil), "friend.removeBlackReq") proto.RegisterType((*RemoveBlackResp)(nil), "friend.removeBlackResp") - proto.RegisterType((*GetBlacksReq)(nil), "friend.getBlacksReq") - proto.RegisterType((*GetBlacksResp)(nil), "friend.getBlacksResp") + proto.RegisterType((*GetPaginationBlacksReq)(nil), "friend.getPaginationBlacksReq") + proto.RegisterType((*GetPaginationBlacksResp)(nil), "friend.getPaginationBlacksResp") proto.RegisterType((*IsFriendReq)(nil), "friend.isFriendReq") proto.RegisterType((*IsFriendResp)(nil), "friend.isFriendResp") proto.RegisterType((*IsBlackReq)(nil), "friend.isBlackReq") @@ -1260,8 +1260,8 @@ func init() { proto.RegisterType((*RespondFriendApplyResp)(nil), "friend.respondFriendApplyResp") proto.RegisterType((*SetFriendRemarkReq)(nil), "friend.setFriendRemarkReq") proto.RegisterType((*SetFriendRemarkResp)(nil), "friend.setFriendRemarkResp") - proto.RegisterType((*GetFromFriendsApplyReq)(nil), "friend.getFromFriendsApplyReq") - proto.RegisterType((*GetFromFriendsApplyResp)(nil), "friend.getFromFriendsApplyResp") + proto.RegisterType((*GetPaginationFriendsApplyFromReq)(nil), "friend.getPaginationFriendsApplyFromReq") + proto.RegisterType((*GetPaginationFriendsApplyFromResp)(nil), "friend.getPaginationFriendsApplyFromResp") } // Reference imports to suppress errors if they are not otherwise used. @@ -1276,13 +1276,11 @@ const _ = grpc.SupportPackageIsVersion4 type FriendClient interface { // 申请加好友 - AddFriend(ctx context.Context, in *AddFriendReq, opts ...grpc.CallOption) (*AddFriendResp, error) + ApplyToAddFriend(ctx context.Context, in *ApplyToAddFriendReq, opts ...grpc.CallOption) (*ApplyToAddFriendResp, error) // 获取收到的好友申请列表 - GetToFriendsApply(ctx context.Context, in *GetToFriendsApplyReq, opts ...grpc.CallOption) (*GetToFriendsApplyResp, error) + GetPaginationFriendsApplyTo(ctx context.Context, in *GetPaginationFriendsApplyToReq, opts ...grpc.CallOption) (*GetPaginationFriendsApplyToResp, error) // 获取主动发出去的好友申请列表 - GetFromFriendsApply(ctx context.Context, in *GetFromFriendsApplyReq, opts ...grpc.CallOption) (*GetFromFriendsApplyResp, error) - // 获取好友列表 - GetFriends(ctx context.Context, in *GetFriendsReq, opts ...grpc.CallOption) (*GetFriendsResp, error) + GetPaginationFriendsApplyFrom(ctx context.Context, in *GetPaginationFriendsApplyFromReq, opts ...grpc.CallOption) (*GetPaginationFriendsApplyFromResp, error) // 添加黑名单 AddBlack(ctx context.Context, in *AddBlackReq, opts ...grpc.CallOption) (*AddBlackResp, error) // 移除黑名单 @@ -1292,7 +1290,7 @@ type FriendClient interface { // 判断是否在黑名单中 IsBlack(ctx context.Context, in *IsBlackReq, opts ...grpc.CallOption) (*IsBlackResp, error) // 获取黑名单列表 - GetBlacks(ctx context.Context, in *GetBlacksReq, opts ...grpc.CallOption) (*GetBlacksResp, error) + GetPaginationBlacks(ctx context.Context, in *GetPaginationBlacksReq, opts ...grpc.CallOption) (*GetPaginationBlacksResp, error) // 删除好友 DeleteFriend(ctx context.Context, in *DeleteFriendReq, opts ...grpc.CallOption) (*DeleteFriendResp, error) // 对好友申请响应(同意或拒绝) @@ -1301,8 +1299,10 @@ type FriendClient interface { SetFriendRemark(ctx context.Context, in *SetFriendRemarkReq, opts ...grpc.CallOption) (*SetFriendRemarkResp, error) // 导入好友关系 ImportFriends(ctx context.Context, in *ImportFriendReq, opts ...grpc.CallOption) (*ImportFriendResp, error) - // 获取指定好友信息 - GetFriendsInfo(ctx context.Context, in *GetFriendsInfoReq, opts ...grpc.CallOption) (*GetFriendsInfoResp, error) + // 翻页获取好友列表 无结果不返回错误 + GetDesignatedFriends(ctx context.Context, in *GetDesignatedFriendsReq, opts ...grpc.CallOption) (*GetDesignatedFriendsResp, error) + // 获取指定好友信息 有id不存在也返回错误 + GetPaginationFriends(ctx context.Context, in *GetPaginationFriendsReq, opts ...grpc.CallOption) (*GetPaginationFriendsResp, error) } type friendClient struct { @@ -1313,36 +1313,27 @@ func NewFriendClient(cc *grpc.ClientConn) FriendClient { return &friendClient{cc} } -func (c *friendClient) AddFriend(ctx context.Context, in *AddFriendReq, opts ...grpc.CallOption) (*AddFriendResp, error) { - out := new(AddFriendResp) - err := grpc.Invoke(ctx, "/friend.friend/addFriend", in, out, c.cc, opts...) +func (c *friendClient) ApplyToAddFriend(ctx context.Context, in *ApplyToAddFriendReq, opts ...grpc.CallOption) (*ApplyToAddFriendResp, error) { + out := new(ApplyToAddFriendResp) + err := grpc.Invoke(ctx, "/friend.friend/applyToAddFriend", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *friendClient) GetToFriendsApply(ctx context.Context, in *GetToFriendsApplyReq, opts ...grpc.CallOption) (*GetToFriendsApplyResp, error) { - out := new(GetToFriendsApplyResp) - err := grpc.Invoke(ctx, "/friend.friend/getToFriendsApply", in, out, c.cc, opts...) +func (c *friendClient) GetPaginationFriendsApplyTo(ctx context.Context, in *GetPaginationFriendsApplyToReq, opts ...grpc.CallOption) (*GetPaginationFriendsApplyToResp, error) { + out := new(GetPaginationFriendsApplyToResp) + err := grpc.Invoke(ctx, "/friend.friend/getPaginationFriendsApplyTo", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *friendClient) GetFromFriendsApply(ctx context.Context, in *GetFromFriendsApplyReq, opts ...grpc.CallOption) (*GetFromFriendsApplyResp, error) { - out := new(GetFromFriendsApplyResp) - err := grpc.Invoke(ctx, "/friend.friend/getFromFriendsApply", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *friendClient) GetFriends(ctx context.Context, in *GetFriendsReq, opts ...grpc.CallOption) (*GetFriendsResp, error) { - out := new(GetFriendsResp) - err := grpc.Invoke(ctx, "/friend.friend/getFriends", in, out, c.cc, opts...) +func (c *friendClient) GetPaginationFriendsApplyFrom(ctx context.Context, in *GetPaginationFriendsApplyFromReq, opts ...grpc.CallOption) (*GetPaginationFriendsApplyFromResp, error) { + out := new(GetPaginationFriendsApplyFromResp) + err := grpc.Invoke(ctx, "/friend.friend/getPaginationFriendsApplyFrom", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1385,9 +1376,9 @@ func (c *friendClient) IsBlack(ctx context.Context, in *IsBlackReq, opts ...grpc return out, nil } -func (c *friendClient) GetBlacks(ctx context.Context, in *GetBlacksReq, opts ...grpc.CallOption) (*GetBlacksResp, error) { - out := new(GetBlacksResp) - err := grpc.Invoke(ctx, "/friend.friend/getBlacks", in, out, c.cc, opts...) +func (c *friendClient) GetPaginationBlacks(ctx context.Context, in *GetPaginationBlacksReq, opts ...grpc.CallOption) (*GetPaginationBlacksResp, error) { + out := new(GetPaginationBlacksResp) + err := grpc.Invoke(ctx, "/friend.friend/getPaginationBlacks", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1430,9 +1421,18 @@ func (c *friendClient) ImportFriends(ctx context.Context, in *ImportFriendReq, o return out, nil } -func (c *friendClient) GetFriendsInfo(ctx context.Context, in *GetFriendsInfoReq, opts ...grpc.CallOption) (*GetFriendsInfoResp, error) { - out := new(GetFriendsInfoResp) - err := grpc.Invoke(ctx, "/friend.friend/getFriendsInfo", in, out, c.cc, opts...) +func (c *friendClient) GetDesignatedFriends(ctx context.Context, in *GetDesignatedFriendsReq, opts ...grpc.CallOption) (*GetDesignatedFriendsResp, error) { + out := new(GetDesignatedFriendsResp) + err := grpc.Invoke(ctx, "/friend.friend/getDesignatedFriends", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *friendClient) GetPaginationFriends(ctx context.Context, in *GetPaginationFriendsReq, opts ...grpc.CallOption) (*GetPaginationFriendsResp, error) { + out := new(GetPaginationFriendsResp) + err := grpc.Invoke(ctx, "/friend.friend/getPaginationFriends", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1443,13 +1443,11 @@ func (c *friendClient) GetFriendsInfo(ctx context.Context, in *GetFriendsInfoReq type FriendServer interface { // 申请加好友 - AddFriend(context.Context, *AddFriendReq) (*AddFriendResp, error) + ApplyToAddFriend(context.Context, *ApplyToAddFriendReq) (*ApplyToAddFriendResp, error) // 获取收到的好友申请列表 - GetToFriendsApply(context.Context, *GetToFriendsApplyReq) (*GetToFriendsApplyResp, error) + GetPaginationFriendsApplyTo(context.Context, *GetPaginationFriendsApplyToReq) (*GetPaginationFriendsApplyToResp, error) // 获取主动发出去的好友申请列表 - GetFromFriendsApply(context.Context, *GetFromFriendsApplyReq) (*GetFromFriendsApplyResp, error) - // 获取好友列表 - GetFriends(context.Context, *GetFriendsReq) (*GetFriendsResp, error) + GetPaginationFriendsApplyFrom(context.Context, *GetPaginationFriendsApplyFromReq) (*GetPaginationFriendsApplyFromResp, error) // 添加黑名单 AddBlack(context.Context, *AddBlackReq) (*AddBlackResp, error) // 移除黑名单 @@ -1459,7 +1457,7 @@ type FriendServer interface { // 判断是否在黑名单中 IsBlack(context.Context, *IsBlackReq) (*IsBlackResp, error) // 获取黑名单列表 - GetBlacks(context.Context, *GetBlacksReq) (*GetBlacksResp, error) + GetPaginationBlacks(context.Context, *GetPaginationBlacksReq) (*GetPaginationBlacksResp, error) // 删除好友 DeleteFriend(context.Context, *DeleteFriendReq) (*DeleteFriendResp, error) // 对好友申请响应(同意或拒绝) @@ -1468,82 +1466,66 @@ type FriendServer interface { SetFriendRemark(context.Context, *SetFriendRemarkReq) (*SetFriendRemarkResp, error) // 导入好友关系 ImportFriends(context.Context, *ImportFriendReq) (*ImportFriendResp, error) - // 获取指定好友信息 - GetFriendsInfo(context.Context, *GetFriendsInfoReq) (*GetFriendsInfoResp, error) + // 翻页获取好友列表 无结果不返回错误 + GetDesignatedFriends(context.Context, *GetDesignatedFriendsReq) (*GetDesignatedFriendsResp, error) + // 获取指定好友信息 有id不存在也返回错误 + GetPaginationFriends(context.Context, *GetPaginationFriendsReq) (*GetPaginationFriendsResp, error) } func RegisterFriendServer(s *grpc.Server, srv FriendServer) { s.RegisterService(&_Friend_serviceDesc, srv) } -func _Friend_AddFriend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AddFriendReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(FriendServer).AddFriend(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/friend.friend/AddFriend", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FriendServer).AddFriend(ctx, req.(*AddFriendReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _Friend_GetToFriendsApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetToFriendsApplyReq) +func _Friend_ApplyToAddFriend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApplyToAddFriendReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(FriendServer).GetToFriendsApply(ctx, in) + return srv.(FriendServer).ApplyToAddFriend(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/friend.friend/GetToFriendsApply", + FullMethod: "/friend.friend/ApplyToAddFriend", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FriendServer).GetToFriendsApply(ctx, req.(*GetToFriendsApplyReq)) + return srv.(FriendServer).ApplyToAddFriend(ctx, req.(*ApplyToAddFriendReq)) } return interceptor(ctx, in, info, handler) } -func _Friend_GetFromFriendsApply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetFromFriendsApplyReq) +func _Friend_GetPaginationFriendsApplyTo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPaginationFriendsApplyToReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(FriendServer).GetFromFriendsApply(ctx, in) + return srv.(FriendServer).GetPaginationFriendsApplyTo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/friend.friend/GetFromFriendsApply", + FullMethod: "/friend.friend/GetPaginationFriendsApplyTo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FriendServer).GetFromFriendsApply(ctx, req.(*GetFromFriendsApplyReq)) + return srv.(FriendServer).GetPaginationFriendsApplyTo(ctx, req.(*GetPaginationFriendsApplyToReq)) } return interceptor(ctx, in, info, handler) } -func _Friend_GetFriends_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetFriendsReq) +func _Friend_GetPaginationFriendsApplyFrom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPaginationFriendsApplyFromReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(FriendServer).GetFriends(ctx, in) + return srv.(FriendServer).GetPaginationFriendsApplyFrom(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/friend.friend/GetFriends", + FullMethod: "/friend.friend/GetPaginationFriendsApplyFrom", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FriendServer).GetFriends(ctx, req.(*GetFriendsReq)) + return srv.(FriendServer).GetPaginationFriendsApplyFrom(ctx, req.(*GetPaginationFriendsApplyFromReq)) } return interceptor(ctx, in, info, handler) } @@ -1620,20 +1602,20 @@ func _Friend_IsBlack_Handler(srv interface{}, ctx context.Context, dec func(inte return interceptor(ctx, in, info, handler) } -func _Friend_GetBlacks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetBlacksReq) +func _Friend_GetPaginationBlacks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPaginationBlacksReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(FriendServer).GetBlacks(ctx, in) + return srv.(FriendServer).GetPaginationBlacks(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/friend.friend/GetBlacks", + FullMethod: "/friend.friend/GetPaginationBlacks", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FriendServer).GetBlacks(ctx, req.(*GetBlacksReq)) + return srv.(FriendServer).GetPaginationBlacks(ctx, req.(*GetPaginationBlacksReq)) } return interceptor(ctx, in, info, handler) } @@ -1710,20 +1692,38 @@ func _Friend_ImportFriends_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Friend_GetFriendsInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetFriendsInfoReq) +func _Friend_GetDesignatedFriends_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDesignatedFriendsReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(FriendServer).GetFriendsInfo(ctx, in) + return srv.(FriendServer).GetDesignatedFriends(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/friend.friend/GetFriendsInfo", + FullMethod: "/friend.friend/GetDesignatedFriends", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(FriendServer).GetFriendsInfo(ctx, req.(*GetFriendsInfoReq)) + return srv.(FriendServer).GetDesignatedFriends(ctx, req.(*GetDesignatedFriendsReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Friend_GetPaginationFriends_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPaginationFriendsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FriendServer).GetPaginationFriends(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/friend.friend/GetPaginationFriends", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FriendServer).GetPaginationFriends(ctx, req.(*GetPaginationFriendsReq)) } return interceptor(ctx, in, info, handler) } @@ -1733,20 +1733,16 @@ var _Friend_serviceDesc = grpc.ServiceDesc{ HandlerType: (*FriendServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "addFriend", - Handler: _Friend_AddFriend_Handler, - }, - { - MethodName: "getToFriendsApply", - Handler: _Friend_GetToFriendsApply_Handler, + MethodName: "applyToAddFriend", + Handler: _Friend_ApplyToAddFriend_Handler, }, { - MethodName: "getFromFriendsApply", - Handler: _Friend_GetFromFriendsApply_Handler, + MethodName: "getPaginationFriendsApplyTo", + Handler: _Friend_GetPaginationFriendsApplyTo_Handler, }, { - MethodName: "getFriends", - Handler: _Friend_GetFriends_Handler, + MethodName: "getPaginationFriendsApplyFrom", + Handler: _Friend_GetPaginationFriendsApplyFrom_Handler, }, { MethodName: "addBlack", @@ -1765,8 +1761,8 @@ var _Friend_serviceDesc = grpc.ServiceDesc{ Handler: _Friend_IsBlack_Handler, }, { - MethodName: "getBlacks", - Handler: _Friend_GetBlacks_Handler, + MethodName: "getPaginationBlacks", + Handler: _Friend_GetPaginationBlacks_Handler, }, { MethodName: "deleteFriend", @@ -1785,76 +1781,81 @@ var _Friend_serviceDesc = grpc.ServiceDesc{ Handler: _Friend_ImportFriends_Handler, }, { - MethodName: "getFriendsInfo", - Handler: _Friend_GetFriendsInfo_Handler, + MethodName: "getDesignatedFriends", + Handler: _Friend_GetDesignatedFriends_Handler, + }, + { + MethodName: "getPaginationFriends", + Handler: _Friend_GetPaginationFriends_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "friend/friend.proto", } -func init() { proto.RegisterFile("friend/friend.proto", fileDescriptor_friend_ae999c738a77e4f8) } - -var fileDescriptor_friend_ae999c738a77e4f8 = []byte{ - // 955 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xef, 0x6e, 0x1b, 0x45, - 0x10, 0x97, 0x1d, 0xe2, 0x24, 0x63, 0xc7, 0xa6, 0xe3, 0xd8, 0x3d, 0x8e, 0x24, 0x35, 0xab, 0x0a, - 0xe5, 0x4b, 0x63, 0xd5, 0x80, 0x84, 0x54, 0x09, 0x48, 0x54, 0x15, 0x82, 0x14, 0x51, 0xae, 0x2d, - 0xa8, 0x54, 0x22, 0xba, 0x72, 0x6b, 0x73, 0x8a, 0x7d, 0xb7, 0xb9, 0xb9, 0xc4, 0xed, 0x83, 0xf0, - 0x2a, 0x3c, 0x1f, 0xba, 0xdd, 0xbd, 0xdb, 0x3d, 0xfb, 0x1c, 0x35, 0x21, 0xf0, 0xc9, 0x9a, 0xdf, - 0xcc, 0xec, 0xfc, 0xd9, 0xf1, 0xfc, 0xf6, 0xa0, 0x3b, 0x4e, 0x42, 0x1e, 0x05, 0x43, 0xf5, 0x73, - 0x28, 0x92, 0x38, 0x8d, 0xb1, 0xa1, 0x24, 0xf7, 0xe0, 0x27, 0xc1, 0xa3, 0x47, 0x27, 0xa7, 0x8f, - 0x5e, 0xf0, 0xe4, 0x8a, 0x27, 0x43, 0x71, 0x3e, 0x19, 0x4a, 0x8b, 0x21, 0x05, 0xe7, 0x67, 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8, 0xbc, 0x22, 0x70, 0xcf, 0xb4, 0xa5, 0x62, 0xab, 0xb9, - 0xfb, 0xd7, 0xa9, 0x49, 0xe0, 0x8f, 0xd0, 0x59, 0xf8, 0xa7, 0xa3, 0x9b, 0xbb, 0x2c, 0xaf, 0x1d, - 0xf7, 0xd3, 0x95, 0x3a, 0x12, 0x78, 0x0c, 0xdb, 0xf6, 0xd3, 0x93, 0x4c, 0x91, 0x0b, 0x8f, 0x5d, - 0x53, 0xe4, 0xe2, 0x53, 0x15, 0xbf, 0xb7, 0x1f, 0x53, 0xf2, 0x2d, 0xf4, 0xc9, 0xf2, 0xb4, 0xe9, - 0x4f, 0x0d, 0xd7, 0x5d, 0xa5, 0x22, 0x71, 0xfc, 0xd9, 0x6f, 0x0f, 0xb2, 0xef, 0x98, 0xb3, 0x93, - 0x53, 0xeb, 0x03, 0x46, 0x99, 0x3f, 0x51, 0x3f, 0x6f, 0x1b, 0x12, 0xfc, 0xe2, 0x9f, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xdd, 0xee, 0xa4, 0x0d, 0x0e, 0x0d, 0x00, 0x00, +func init() { proto.RegisterFile("friend/friend.proto", fileDescriptor_friend_b44dbd852f0b513f) } + +var fileDescriptor_friend_b44dbd852f0b513f = []byte{ + // 974 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x5f, 0x6f, 0x1b, 0x45, + 0x10, 0x97, 0x1d, 0xe2, 0x26, 0x63, 0xd7, 0x29, 0xe3, 0xd4, 0x3d, 0x5d, 0xfe, 0xb9, 0xab, 0xaa, + 0x98, 0x87, 0xc6, 0xaa, 0x81, 0x27, 0x24, 0x20, 0x51, 0x14, 0x11, 0xa4, 0x08, 0xb8, 0x16, 0x50, + 0x40, 0x22, 0xba, 0x72, 0x6b, 0x73, 0x8a, 0x7d, 0xb7, 0xb9, 0xb9, 0x24, 0xed, 0x0b, 0x02, 0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, 0x8a, 0xc2, 0x69, 0x21, 0x74, 0x83, 0x83, 0x36, 0xac, 0xc5, 0xa1, 0x96, + 0xd6, 0xa5, 0x34, 0xa3, 0xb1, 0x0b, 0x8d, 0x88, 0x5f, 0x9e, 0xd2, 0xd8, 0x5a, 0x91, 0x12, 0x4d, + 0x61, 0x1b, 0xea, 0xfc, 0xb5, 0xf5, 0x81, 0xe4, 0xd5, 0xf9, 0x6b, 0xd6, 0x85, 0xcd, 0x59, 0xd7, + 0x24, 0xd8, 0x19, 0x6c, 0xf8, 0x53, 0x11, 0x46, 0x71, 0x1e, 0xce, 0x5d, 0x95, 0x12, 0xe1, 0x41, + 0xd1, 0x34, 0x09, 0xf6, 0x07, 0xec, 0x56, 0x95, 0xf7, 0x40, 0x85, 0x96, 0x78, 0xef, 0x42, 0xe3, + 0xca, 0x74, 0xac, 0x29, 0x3c, 0x02, 0x10, 0x99, 0x9a, 0x2c, 0x43, 0x73, 0xf8, 0xa4, 0xa2, 0xf6, + 0x0e, 0xbf, 0xbc, 0xe2, 0x64, 0xb8, 0x70, 0x0c, 0x3d, 0xf6, 0x57, 0x0d, 0xf6, 0x16, 0x06, 0x40, + 0x02, 0xbf, 0x86, 0x76, 0x56, 0x8c, 0xc4, 0x14, 0xe9, 0x97, 0xee, 0xcd, 0x7d, 0x69, 0x0d, 0x74, + 0x4a, 0x7a, 0xb8, 0x09, 0xab, 0x71, 0x18, 0xbb, 0x13, 0x19, 0xee, 0xaa, 0xa3, 0x08, 0x76, 0x23, + 0xbb, 0xf8, 0x88, 0x93, 0x3f, 0x0e, 0xdc, 0x98, 0x7b, 0x46, 0x17, 0x17, 0x93, 0xac, 0xdd, 0x2e, + 0x49, 0xa3, 0x84, 0x75, 0xb3, 0x84, 0xec, 0x52, 0xf6, 0x76, 0x85, 0x63, 0xd5, 0xdb, 0xc7, 0xef, + 0xdc, 0xdb, 0x86, 0xc6, 0x9c, 0x5c, 0xbf, 0x87, 0xa6, 0xeb, 0x79, 0x87, 0x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, 0x76, 0x0b, 0x76, 0x53, 0x50, 0x71, 0x8d, + 0xd9, 0x8f, 0x2a, 0xf9, 0xca, 0x6d, 0x3a, 0x66, 0x73, 0xb7, 0xc6, 0xec, 0xce, 0xdd, 0x16, 0xa6, + 0xf1, 0x10, 0xee, 0xe9, 0xd9, 0x87, 0x98, 0x03, 0x32, 0x77, 0x9d, 0x19, 0x1e, 0x09, 0xfc, 0x11, + 0x3a, 0x15, 0xbb, 0x07, 0x77, 0x2b, 0x6b, 0x94, 0x2d, 0x44, 0x7b, 0x6f, 0xa1, 0x9c, 0x04, 0x1e, + 0x40, 0xcb, 0x9c, 0x69, 0x98, 0xe5, 0x5a, 0x1a, 0xa1, 0xb6, 0x55, 0x2d, 0x20, 0x81, 0x2f, 0x00, + 0x67, 0x47, 0x0d, 0xee, 0xe4, 0x45, 0xab, 0x98, 0x8e, 0xf6, 0xee, 0x22, 0x31, 0x09, 0xfc, 0x06, + 0x36, 0x4a, 0x13, 0x03, 0xed, 0x54, 0x65, 0x76, 0x7c, 0xd9, 0x5b, 0x73, 0x65, 0x24, 0xf0, 0x10, + 0xee, 0x9b, 0xf7, 0x2f, 0xe5, 0x49, 0x96, 0x2e, 0xee, 0x3c, 0xc9, 0xf2, 0xbd, 0x8c, 0x67, 0xb0, + 0x59, 0x75, 0xb2, 0xa1, 0x59, 0xe0, 0xaa, 0x4b, 0xd2, 0xee, 0x2d, 0x06, 0x64, 0xa6, 0x67, 0x3a, + 0x1c, 0xf7, 0x16, 0xf5, 0x7f, 0xd9, 0x74, 0xe5, 0x87, 0xd2, 0xe1, 0xe3, 0x9f, 0xf7, 0x92, 0x6f, + 0xba, 0xf3, 0x93, 0x53, 0xe3, 0x63, 0x4e, 0x29, 0x7d, 0xae, 0x7e, 0x5e, 0x35, 0x24, 0xf3, 0x93, + 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xaf, 0x0f, 0xd2, 0x1a, 0x0e, 0x00, 0x00, } diff --git a/pkg/proto/friend/friend.proto b/pkg/proto/friend/friend.proto index a5814a807..a7e7df8bd 100644 --- a/pkg/proto/friend/friend.proto +++ b/pkg/proto/friend/friend.proto @@ -3,22 +3,22 @@ import "Open-IM-Server/pkg/proto/sdk_ws/ws.proto"; option go_package = "Open_IM/pkg/proto/friend;friend"; package friend; -message getFriendsInfoReq{ +message getPaginationFriendsReq{ string ownerUserID = 1; repeated string friendUserIDs = 2; } -message getFriendsInfoResp{ +message getPaginationFriendsResp{ repeated server_api_params.FriendInfo friendsInfo = 1; } -message addFriendReq{ +message applyToAddFriendReq{ string fromUserID = 1; string toUserID = 2; string reqMsg = 3; string ex = 4; } -message addFriendResp{ +message applyToAddFriendResp{ } @@ -31,22 +31,22 @@ message importFriendResp{ } -message getToFriendsApplyReq{ +message getPaginationFriendsApplyToReq{ string userID = 1; server_api_params.RequestPagination pagination = 2; } -message getToFriendsApplyResp{ +message getPaginationFriendsApplyToResp{ repeated server_api_params.FriendRequest FriendRequests = 1; int32 total = 2; } -message getFriendsReq{ +message getDesignatedFriendsReq{ server_api_params.RequestPagination pagination = 1; string userID = 2; } -message getFriendsResp{ +message getDesignatedFriendsResp{ repeated server_api_params.FriendInfo FriendsInfo = 1; int32 total = 2; } @@ -67,11 +67,11 @@ message removeBlackReq{ message removeBlackResp{ } -message getBlacksReq{ +message getPaginationBlacksReq{ string userID = 1; server_api_params.RequestPagination pagination = 2; } -message getBlacksResp{ +message getPaginationBlacksResp{ repeated server_api_params.BlackInfo blacks= 1; int32 total = 2; } @@ -122,24 +122,22 @@ message setFriendRemarkReq{ message setFriendRemarkResp{ } -message getFromFriendsApplyReq{ +message getPaginationFriendsApplyFromReq{ string userID = 1; server_api_params.RequestPagination pagination = 2; } -message getFromFriendsApplyResp{ +message getPaginationFriendsApplyFromResp{ repeated server_api_params.FriendRequest friendRequests = 1; int32 total = 2; } service friend{ //申请加好友 - rpc addFriend(addFriendReq) returns(addFriendResp); + rpc applyToAddFriend(applyToAddFriendReq) returns(applyToAddFriendResp); //获取收到的好友申请列表 - rpc getToFriendsApply(getToFriendsApplyReq) returns(getToFriendsApplyResp); + rpc getPaginationFriendsApplyTo(getPaginationFriendsApplyToReq) returns(getPaginationFriendsApplyToResp); //获取主动发出去的好友申请列表 - rpc getFromFriendsApply(getFromFriendsApplyReq) returns(getFromFriendsApplyResp); - //获取好友列表 - rpc getFriends(getFriendsReq) returns(getFriendsResp); + rpc getPaginationFriendsApplyFrom(getPaginationFriendsApplyFromReq) returns(getPaginationFriendsApplyFromResp); //添加黑名单 rpc addBlack(addBlackReq) returns(addBlackResp); //移除黑名单 @@ -149,7 +147,7 @@ service friend{ //判断是否在黑名单中 rpc isBlack(isBlackReq) returns(isBlackResp); //获取黑名单列表 - rpc getBlacks(getBlacksReq) returns(getBlacksResp); + rpc getPaginationBlacks(getPaginationBlacksReq) returns(getPaginationBlacksResp); //删除好友 rpc deleteFriend(deleteFriendReq) returns(deleteFriendResp); //对好友申请响应(同意或拒绝) @@ -158,6 +156,8 @@ service friend{ rpc setFriendRemark(setFriendRemarkReq) returns(setFriendRemarkResp); //导入好友关系 rpc importFriends(importFriendReq) returns(importFriendResp); - //获取指定好友信息 - rpc getFriendsInfo(getFriendsInfoReq) returns (getFriendsInfoResp); + //翻页获取好友列表 无结果不返回错误 + rpc getDesignatedFriends(getDesignatedFriendsReq) returns(getDesignatedFriendsResp); + //获取指定好友信息 有id不存在也返回错误 + rpc getPaginationFriends(getPaginationFriendsReq) returns (getPaginationFriendsResp); } \ No newline at end of file diff --git a/pkg/proto/user/user.pb.go b/pkg/proto/user/user.pb.go index c4ffc22aa..ceddb4b11 100644 --- a/pkg/proto/user/user.pb.go +++ b/pkg/proto/user/user.pb.go @@ -36,7 +36,7 @@ func (m *GetAllUserIDReq) Reset() { *m = GetAllUserIDReq{} } func (m *GetAllUserIDReq) String() string { return proto.CompactTextString(m) } func (*GetAllUserIDReq) ProtoMessage() {} func (*GetAllUserIDReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{0} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{0} } func (m *GetAllUserIDReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetAllUserIDReq.Unmarshal(m, b) @@ -75,7 +75,7 @@ func (m *GetAllUserIDResp) Reset() { *m = GetAllUserIDResp{} } func (m *GetAllUserIDResp) String() string { return proto.CompactTextString(m) } func (*GetAllUserIDResp) ProtoMessage() {} func (*GetAllUserIDResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{1} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{1} } func (m *GetAllUserIDResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetAllUserIDResp.Unmarshal(m, b) @@ -120,7 +120,7 @@ func (m *AccountCheckReq) Reset() { *m = AccountCheckReq{} } func (m *AccountCheckReq) String() string { return proto.CompactTextString(m) } func (*AccountCheckReq) ProtoMessage() {} func (*AccountCheckReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{2} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{2} } func (m *AccountCheckReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AccountCheckReq.Unmarshal(m, b) @@ -158,7 +158,7 @@ func (m *AccountCheckResp) Reset() { *m = AccountCheckResp{} } func (m *AccountCheckResp) String() string { return proto.CompactTextString(m) } func (*AccountCheckResp) ProtoMessage() {} func (*AccountCheckResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{3} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{3} } func (m *AccountCheckResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AccountCheckResp.Unmarshal(m, b) @@ -197,7 +197,7 @@ func (m *AccountCheckRespSingleUserStatus) Reset() { *m = AccountCheckRe func (m *AccountCheckRespSingleUserStatus) String() string { return proto.CompactTextString(m) } func (*AccountCheckRespSingleUserStatus) ProtoMessage() {} func (*AccountCheckRespSingleUserStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{3, 0} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{3, 0} } func (m *AccountCheckRespSingleUserStatus) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AccountCheckRespSingleUserStatus.Unmarshal(m, b) @@ -231,76 +231,76 @@ func (m *AccountCheckRespSingleUserStatus) GetAccountStatus() string { return "" } -type GetUsersInfoReq struct { +type GetDesignateUsersReq struct { UserIDs []string `protobuf:"bytes,1,rep,name=userIDs" json:"userIDs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *GetUsersInfoReq) Reset() { *m = GetUsersInfoReq{} } -func (m *GetUsersInfoReq) String() string { return proto.CompactTextString(m) } -func (*GetUsersInfoReq) ProtoMessage() {} -func (*GetUsersInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{4} +func (m *GetDesignateUsersReq) Reset() { *m = GetDesignateUsersReq{} } +func (m *GetDesignateUsersReq) String() string { return proto.CompactTextString(m) } +func (*GetDesignateUsersReq) ProtoMessage() {} +func (*GetDesignateUsersReq) Descriptor() ([]byte, []int) { + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{4} } -func (m *GetUsersInfoReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetUsersInfoReq.Unmarshal(m, b) +func (m *GetDesignateUsersReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetDesignateUsersReq.Unmarshal(m, b) } -func (m *GetUsersInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetUsersInfoReq.Marshal(b, m, deterministic) +func (m *GetDesignateUsersReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetDesignateUsersReq.Marshal(b, m, deterministic) } -func (dst *GetUsersInfoReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetUsersInfoReq.Merge(dst, src) +func (dst *GetDesignateUsersReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetDesignateUsersReq.Merge(dst, src) } -func (m *GetUsersInfoReq) XXX_Size() int { - return xxx_messageInfo_GetUsersInfoReq.Size(m) +func (m *GetDesignateUsersReq) XXX_Size() int { + return xxx_messageInfo_GetDesignateUsersReq.Size(m) } -func (m *GetUsersInfoReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetUsersInfoReq.DiscardUnknown(m) +func (m *GetDesignateUsersReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetDesignateUsersReq.DiscardUnknown(m) } -var xxx_messageInfo_GetUsersInfoReq proto.InternalMessageInfo +var xxx_messageInfo_GetDesignateUsersReq proto.InternalMessageInfo -func (m *GetUsersInfoReq) GetUserIDs() []string { +func (m *GetDesignateUsersReq) GetUserIDs() []string { if m != nil { return m.UserIDs } return nil } -type GetUsersInfoResp struct { +type GetDesignateUsersResp struct { UsersInfo []*sdk_ws.UserInfo `protobuf:"bytes,1,rep,name=usersInfo" json:"usersInfo,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *GetUsersInfoResp) Reset() { *m = GetUsersInfoResp{} } -func (m *GetUsersInfoResp) String() string { return proto.CompactTextString(m) } -func (*GetUsersInfoResp) ProtoMessage() {} -func (*GetUsersInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{5} +func (m *GetDesignateUsersResp) Reset() { *m = GetDesignateUsersResp{} } +func (m *GetDesignateUsersResp) String() string { return proto.CompactTextString(m) } +func (*GetDesignateUsersResp) ProtoMessage() {} +func (*GetDesignateUsersResp) Descriptor() ([]byte, []int) { + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{5} } -func (m *GetUsersInfoResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetUsersInfoResp.Unmarshal(m, b) +func (m *GetDesignateUsersResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetDesignateUsersResp.Unmarshal(m, b) } -func (m *GetUsersInfoResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetUsersInfoResp.Marshal(b, m, deterministic) +func (m *GetDesignateUsersResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetDesignateUsersResp.Marshal(b, m, deterministic) } -func (dst *GetUsersInfoResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetUsersInfoResp.Merge(dst, src) +func (dst *GetDesignateUsersResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetDesignateUsersResp.Merge(dst, src) } -func (m *GetUsersInfoResp) XXX_Size() int { - return xxx_messageInfo_GetUsersInfoResp.Size(m) +func (m *GetDesignateUsersResp) XXX_Size() int { + return xxx_messageInfo_GetDesignateUsersResp.Size(m) } -func (m *GetUsersInfoResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetUsersInfoResp.DiscardUnknown(m) +func (m *GetDesignateUsersResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetDesignateUsersResp.DiscardUnknown(m) } -var xxx_messageInfo_GetUsersInfoResp proto.InternalMessageInfo +var xxx_messageInfo_GetDesignateUsersResp proto.InternalMessageInfo -func (m *GetUsersInfoResp) GetUsersInfo() []*sdk_ws.UserInfo { +func (m *GetDesignateUsersResp) GetUsersInfo() []*sdk_ws.UserInfo { if m != nil { return m.UsersInfo } @@ -318,7 +318,7 @@ func (m *UpdateUserInfoReq) Reset() { *m = UpdateUserInfoReq{} } func (m *UpdateUserInfoReq) String() string { return proto.CompactTextString(m) } func (*UpdateUserInfoReq) ProtoMessage() {} func (*UpdateUserInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{6} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{6} } func (m *UpdateUserInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateUserInfoReq.Unmarshal(m, b) @@ -355,7 +355,7 @@ func (m *UpdateUserInfoResp) Reset() { *m = UpdateUserInfoResp{} } func (m *UpdateUserInfoResp) String() string { return proto.CompactTextString(m) } func (*UpdateUserInfoResp) ProtoMessage() {} func (*UpdateUserInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{7} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{7} } func (m *UpdateUserInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UpdateUserInfoResp.Unmarshal(m, b) @@ -387,7 +387,7 @@ func (m *SetGlobalRecvMessageOptReq) Reset() { *m = SetGlobalRecvMessage func (m *SetGlobalRecvMessageOptReq) String() string { return proto.CompactTextString(m) } func (*SetGlobalRecvMessageOptReq) ProtoMessage() {} func (*SetGlobalRecvMessageOptReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{8} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{8} } func (m *SetGlobalRecvMessageOptReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGlobalRecvMessageOptReq.Unmarshal(m, b) @@ -431,7 +431,7 @@ func (m *SetGlobalRecvMessageOptResp) Reset() { *m = SetGlobalRecvMessag func (m *SetGlobalRecvMessageOptResp) String() string { return proto.CompactTextString(m) } func (*SetGlobalRecvMessageOptResp) ProtoMessage() {} func (*SetGlobalRecvMessageOptResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{9} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{9} } func (m *SetGlobalRecvMessageOptResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGlobalRecvMessageOptResp.Unmarshal(m, b) @@ -464,7 +464,7 @@ func (m *SetConversationReq) Reset() { *m = SetConversationReq{} } func (m *SetConversationReq) String() string { return proto.CompactTextString(m) } func (*SetConversationReq) ProtoMessage() {} func (*SetConversationReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{10} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{10} } func (m *SetConversationReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetConversationReq.Unmarshal(m, b) @@ -515,7 +515,7 @@ func (m *SetConversationResp) Reset() { *m = SetConversationResp{} } func (m *SetConversationResp) String() string { return proto.CompactTextString(m) } func (*SetConversationResp) ProtoMessage() {} func (*SetConversationResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{11} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{11} } func (m *SetConversationResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetConversationResp.Unmarshal(m, b) @@ -550,7 +550,7 @@ func (m *SetRecvMsgOptReq) Reset() { *m = SetRecvMsgOptReq{} } func (m *SetRecvMsgOptReq) String() string { return proto.CompactTextString(m) } func (*SetRecvMsgOptReq) ProtoMessage() {} func (*SetRecvMsgOptReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{12} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{12} } func (m *SetRecvMsgOptReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetRecvMsgOptReq.Unmarshal(m, b) @@ -615,7 +615,7 @@ func (m *SetRecvMsgOptResp) Reset() { *m = SetRecvMsgOptResp{} } func (m *SetRecvMsgOptResp) String() string { return proto.CompactTextString(m) } func (*SetRecvMsgOptResp) ProtoMessage() {} func (*SetRecvMsgOptResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{13} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{13} } func (m *SetRecvMsgOptResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetRecvMsgOptResp.Unmarshal(m, b) @@ -648,7 +648,7 @@ func (m *GetConversationReq) Reset() { *m = GetConversationReq{} } func (m *GetConversationReq) String() string { return proto.CompactTextString(m) } func (*GetConversationReq) ProtoMessage() {} func (*GetConversationReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{14} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{14} } func (m *GetConversationReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetConversationReq.Unmarshal(m, b) @@ -700,7 +700,7 @@ func (m *GetConversationResp) Reset() { *m = GetConversationResp{} } func (m *GetConversationResp) String() string { return proto.CompactTextString(m) } func (*GetConversationResp) ProtoMessage() {} func (*GetConversationResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{15} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{15} } func (m *GetConversationResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetConversationResp.Unmarshal(m, b) @@ -740,7 +740,7 @@ func (m *GetConversationsReq) Reset() { *m = GetConversationsReq{} } func (m *GetConversationsReq) String() string { return proto.CompactTextString(m) } func (*GetConversationsReq) ProtoMessage() {} func (*GetConversationsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{16} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{16} } func (m *GetConversationsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetConversationsReq.Unmarshal(m, b) @@ -792,7 +792,7 @@ func (m *GetConversationsResp) Reset() { *m = GetConversationsResp{} } func (m *GetConversationsResp) String() string { return proto.CompactTextString(m) } func (*GetConversationsResp) ProtoMessage() {} func (*GetConversationsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{17} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{17} } func (m *GetConversationsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetConversationsResp.Unmarshal(m, b) @@ -831,7 +831,7 @@ func (m *GetAllConversationsReq) Reset() { *m = GetAllConversationsReq{} func (m *GetAllConversationsReq) String() string { return proto.CompactTextString(m) } func (*GetAllConversationsReq) ProtoMessage() {} func (*GetAllConversationsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{18} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{18} } func (m *GetAllConversationsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetAllConversationsReq.Unmarshal(m, b) @@ -876,7 +876,7 @@ func (m *GetAllConversationsResp) Reset() { *m = GetAllConversationsResp func (m *GetAllConversationsResp) String() string { return proto.CompactTextString(m) } func (*GetAllConversationsResp) ProtoMessage() {} func (*GetAllConversationsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{19} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{19} } func (m *GetAllConversationsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetAllConversationsResp.Unmarshal(m, b) @@ -917,7 +917,7 @@ func (m *BatchSetConversationsReq) Reset() { *m = BatchSetConversationsR func (m *BatchSetConversationsReq) String() string { return proto.CompactTextString(m) } func (*BatchSetConversationsReq) ProtoMessage() {} func (*BatchSetConversationsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{20} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{20} } func (m *BatchSetConversationsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BatchSetConversationsReq.Unmarshal(m, b) @@ -977,7 +977,7 @@ func (m *BatchSetConversationsResp) Reset() { *m = BatchSetConversations func (m *BatchSetConversationsResp) String() string { return proto.CompactTextString(m) } func (*BatchSetConversationsResp) ProtoMessage() {} func (*BatchSetConversationsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{21} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{21} } func (m *BatchSetConversationsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_BatchSetConversationsResp.Unmarshal(m, b) @@ -1011,69 +1011,45 @@ func (m *BatchSetConversationsResp) GetFailed() []string { return nil } -type GetUsersReq struct { +type GetPaginationUsersReq struct { Pagination *sdk_ws.RequestPagination `protobuf:"bytes,2,opt,name=pagination" json:"pagination,omitempty"` - UserName string `protobuf:"bytes,3,opt,name=userName" json:"userName,omitempty"` - UserID string `protobuf:"bytes,4,opt,name=userID" json:"userID,omitempty"` - Content string `protobuf:"bytes,5,opt,name=content" json:"content,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } -func (m *GetUsersReq) Reset() { *m = GetUsersReq{} } -func (m *GetUsersReq) String() string { return proto.CompactTextString(m) } -func (*GetUsersReq) ProtoMessage() {} -func (*GetUsersReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{22} +func (m *GetPaginationUsersReq) Reset() { *m = GetPaginationUsersReq{} } +func (m *GetPaginationUsersReq) String() string { return proto.CompactTextString(m) } +func (*GetPaginationUsersReq) ProtoMessage() {} +func (*GetPaginationUsersReq) Descriptor() ([]byte, []int) { + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{22} } -func (m *GetUsersReq) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetUsersReq.Unmarshal(m, b) +func (m *GetPaginationUsersReq) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationUsersReq.Unmarshal(m, b) } -func (m *GetUsersReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetUsersReq.Marshal(b, m, deterministic) +func (m *GetPaginationUsersReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationUsersReq.Marshal(b, m, deterministic) } -func (dst *GetUsersReq) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetUsersReq.Merge(dst, src) +func (dst *GetPaginationUsersReq) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationUsersReq.Merge(dst, src) } -func (m *GetUsersReq) XXX_Size() int { - return xxx_messageInfo_GetUsersReq.Size(m) +func (m *GetPaginationUsersReq) XXX_Size() int { + return xxx_messageInfo_GetPaginationUsersReq.Size(m) } -func (m *GetUsersReq) XXX_DiscardUnknown() { - xxx_messageInfo_GetUsersReq.DiscardUnknown(m) +func (m *GetPaginationUsersReq) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationUsersReq.DiscardUnknown(m) } -var xxx_messageInfo_GetUsersReq proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationUsersReq proto.InternalMessageInfo -func (m *GetUsersReq) GetPagination() *sdk_ws.RequestPagination { +func (m *GetPaginationUsersReq) GetPagination() *sdk_ws.RequestPagination { if m != nil { return m.Pagination } return nil } -func (m *GetUsersReq) GetUserName() string { - if m != nil { - return m.UserName - } - return "" -} - -func (m *GetUsersReq) GetUserID() string { - if m != nil { - return m.UserID - } - return "" -} - -func (m *GetUsersReq) GetContent() string { - if m != nil { - return m.Content - } - return "" -} - -type GetUsersResp struct { +type GetPaginationUsersResp struct { Total int32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` Users []*sdk_ws.UserInfo `protobuf:"bytes,2,rep,name=users" json:"users,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1081,38 +1057,38 @@ type GetUsersResp struct { XXX_sizecache int32 `json:"-"` } -func (m *GetUsersResp) Reset() { *m = GetUsersResp{} } -func (m *GetUsersResp) String() string { return proto.CompactTextString(m) } -func (*GetUsersResp) ProtoMessage() {} -func (*GetUsersResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{23} +func (m *GetPaginationUsersResp) Reset() { *m = GetPaginationUsersResp{} } +func (m *GetPaginationUsersResp) String() string { return proto.CompactTextString(m) } +func (*GetPaginationUsersResp) ProtoMessage() {} +func (*GetPaginationUsersResp) Descriptor() ([]byte, []int) { + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{23} } -func (m *GetUsersResp) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetUsersResp.Unmarshal(m, b) +func (m *GetPaginationUsersResp) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetPaginationUsersResp.Unmarshal(m, b) } -func (m *GetUsersResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetUsersResp.Marshal(b, m, deterministic) +func (m *GetPaginationUsersResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetPaginationUsersResp.Marshal(b, m, deterministic) } -func (dst *GetUsersResp) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetUsersResp.Merge(dst, src) +func (dst *GetPaginationUsersResp) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetPaginationUsersResp.Merge(dst, src) } -func (m *GetUsersResp) XXX_Size() int { - return xxx_messageInfo_GetUsersResp.Size(m) +func (m *GetPaginationUsersResp) XXX_Size() int { + return xxx_messageInfo_GetPaginationUsersResp.Size(m) } -func (m *GetUsersResp) XXX_DiscardUnknown() { - xxx_messageInfo_GetUsersResp.DiscardUnknown(m) +func (m *GetPaginationUsersResp) XXX_DiscardUnknown() { + xxx_messageInfo_GetPaginationUsersResp.DiscardUnknown(m) } -var xxx_messageInfo_GetUsersResp proto.InternalMessageInfo +var xxx_messageInfo_GetPaginationUsersResp proto.InternalMessageInfo -func (m *GetUsersResp) GetTotal() int32 { +func (m *GetPaginationUsersResp) GetTotal() int32 { if m != nil { return m.Total } return 0 } -func (m *GetUsersResp) GetUsers() []*sdk_ws.UserInfo { +func (m *GetPaginationUsersResp) GetUsers() []*sdk_ws.UserInfo { if m != nil { return m.Users } @@ -1130,7 +1106,7 @@ func (m *UserRegisterReq) Reset() { *m = UserRegisterReq{} } func (m *UserRegisterReq) String() string { return proto.CompactTextString(m) } func (*UserRegisterReq) ProtoMessage() {} func (*UserRegisterReq) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{24} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{24} } func (m *UserRegisterReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UserRegisterReq.Unmarshal(m, b) @@ -1167,7 +1143,7 @@ func (m *UserRegisterResp) Reset() { *m = UserRegisterResp{} } func (m *UserRegisterResp) String() string { return proto.CompactTextString(m) } func (*UserRegisterResp) ProtoMessage() {} func (*UserRegisterResp) Descriptor() ([]byte, []int) { - return fileDescriptor_user_ca0d4cfbb41aa43a, []int{25} + return fileDescriptor_user_c6c77fe2e81ca7ab, []int{25} } func (m *UserRegisterResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_UserRegisterResp.Unmarshal(m, b) @@ -1193,8 +1169,8 @@ func init() { proto.RegisterType((*AccountCheckReq)(nil), "user.accountCheckReq") proto.RegisterType((*AccountCheckResp)(nil), "user.accountCheckResp") proto.RegisterType((*AccountCheckRespSingleUserStatus)(nil), "user.accountCheckResp.singleUserStatus") - proto.RegisterType((*GetUsersInfoReq)(nil), "user.getUsersInfoReq") - proto.RegisterType((*GetUsersInfoResp)(nil), "user.getUsersInfoResp") + proto.RegisterType((*GetDesignateUsersReq)(nil), "user.getDesignateUsersReq") + proto.RegisterType((*GetDesignateUsersResp)(nil), "user.getDesignateUsersResp") proto.RegisterType((*UpdateUserInfoReq)(nil), "user.updateUserInfoReq") proto.RegisterType((*UpdateUserInfoResp)(nil), "user.updateUserInfoResp") proto.RegisterType((*SetGlobalRecvMessageOptReq)(nil), "user.setGlobalRecvMessageOptReq") @@ -1211,8 +1187,8 @@ func init() { proto.RegisterType((*GetAllConversationsResp)(nil), "user.getAllConversationsResp") proto.RegisterType((*BatchSetConversationsReq)(nil), "user.batchSetConversationsReq") proto.RegisterType((*BatchSetConversationsResp)(nil), "user.batchSetConversationsResp") - proto.RegisterType((*GetUsersReq)(nil), "user.getUsersReq") - proto.RegisterType((*GetUsersResp)(nil), "user.getUsersResp") + proto.RegisterType((*GetPaginationUsersReq)(nil), "user.getPaginationUsersReq") + proto.RegisterType((*GetPaginationUsersResp)(nil), "user.getPaginationUsersResp") proto.RegisterType((*UserRegisterReq)(nil), "user.userRegisterReq") proto.RegisterType((*UserRegisterResp)(nil), "user.userRegisterResp") } @@ -1229,7 +1205,7 @@ const _ = grpc.SupportPackageIsVersion4 type UserClient interface { // 获取指定的用户信息 全字段 - GetUsersInfo(ctx context.Context, in *GetUsersInfoReq, opts ...grpc.CallOption) (*GetUsersInfoResp, error) + GetDesignateUsers(ctx context.Context, in *GetDesignateUsersReq, opts ...grpc.CallOption) (*GetDesignateUsersResp, error) // 更新用户信息 UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*UpdateUserInfoResp, error) // 设置用户消息接收选项 @@ -1237,7 +1213,7 @@ type UserClient interface { // 检查userID是否存在 AccountCheck(ctx context.Context, in *AccountCheckReq, opts ...grpc.CallOption) (*AccountCheckResp, error) // 翻页(或指定userID,昵称)拉取用户信息 全字段 - GetUsers(ctx context.Context, in *GetUsersReq, opts ...grpc.CallOption) (*GetUsersResp, error) + GetPaginationUsers(ctx context.Context, in *GetPaginationUsersReq, opts ...grpc.CallOption) (*GetPaginationUsersResp, error) // 用户注册 UserRegister(ctx context.Context, in *UserRegisterReq, opts ...grpc.CallOption) (*UserRegisterResp, error) } @@ -1250,9 +1226,9 @@ func NewUserClient(cc *grpc.ClientConn) UserClient { return &userClient{cc} } -func (c *userClient) GetUsersInfo(ctx context.Context, in *GetUsersInfoReq, opts ...grpc.CallOption) (*GetUsersInfoResp, error) { - out := new(GetUsersInfoResp) - err := grpc.Invoke(ctx, "/user.user/getUsersInfo", in, out, c.cc, opts...) +func (c *userClient) GetDesignateUsers(ctx context.Context, in *GetDesignateUsersReq, opts ...grpc.CallOption) (*GetDesignateUsersResp, error) { + out := new(GetDesignateUsersResp) + err := grpc.Invoke(ctx, "/user.user/getDesignateUsers", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1286,9 +1262,9 @@ func (c *userClient) AccountCheck(ctx context.Context, in *AccountCheckReq, opts return out, nil } -func (c *userClient) GetUsers(ctx context.Context, in *GetUsersReq, opts ...grpc.CallOption) (*GetUsersResp, error) { - out := new(GetUsersResp) - err := grpc.Invoke(ctx, "/user.user/getUsers", in, out, c.cc, opts...) +func (c *userClient) GetPaginationUsers(ctx context.Context, in *GetPaginationUsersReq, opts ...grpc.CallOption) (*GetPaginationUsersResp, error) { + out := new(GetPaginationUsersResp) + err := grpc.Invoke(ctx, "/user.user/getPaginationUsers", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -1308,7 +1284,7 @@ func (c *userClient) UserRegister(ctx context.Context, in *UserRegisterReq, opts type UserServer interface { // 获取指定的用户信息 全字段 - GetUsersInfo(context.Context, *GetUsersInfoReq) (*GetUsersInfoResp, error) + GetDesignateUsers(context.Context, *GetDesignateUsersReq) (*GetDesignateUsersResp, error) // 更新用户信息 UpdateUserInfo(context.Context, *UpdateUserInfoReq) (*UpdateUserInfoResp, error) // 设置用户消息接收选项 @@ -1316,7 +1292,7 @@ type UserServer interface { // 检查userID是否存在 AccountCheck(context.Context, *AccountCheckReq) (*AccountCheckResp, error) // 翻页(或指定userID,昵称)拉取用户信息 全字段 - GetUsers(context.Context, *GetUsersReq) (*GetUsersResp, error) + GetPaginationUsers(context.Context, *GetPaginationUsersReq) (*GetPaginationUsersResp, error) // 用户注册 UserRegister(context.Context, *UserRegisterReq) (*UserRegisterResp, error) } @@ -1325,20 +1301,20 @@ func RegisterUserServer(s *grpc.Server, srv UserServer) { s.RegisterService(&_User_serviceDesc, srv) } -func _User_GetUsersInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetUsersInfoReq) +func _User_GetDesignateUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDesignateUsersReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(UserServer).GetUsersInfo(ctx, in) + return srv.(UserServer).GetDesignateUsers(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/user.user/GetUsersInfo", + FullMethod: "/user.user/GetDesignateUsers", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).GetUsersInfo(ctx, req.(*GetUsersInfoReq)) + return srv.(UserServer).GetDesignateUsers(ctx, req.(*GetDesignateUsersReq)) } return interceptor(ctx, in, info, handler) } @@ -1397,20 +1373,20 @@ func _User_AccountCheck_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } -func _User_GetUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetUsersReq) +func _User_GetPaginationUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPaginationUsersReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(UserServer).GetUsers(ctx, in) + return srv.(UserServer).GetPaginationUsers(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/user.user/GetUsers", + FullMethod: "/user.user/GetPaginationUsers", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).GetUsers(ctx, req.(*GetUsersReq)) + return srv.(UserServer).GetPaginationUsers(ctx, req.(*GetPaginationUsersReq)) } return interceptor(ctx, in, info, handler) } @@ -1438,8 +1414,8 @@ var _User_serviceDesc = grpc.ServiceDesc{ HandlerType: (*UserServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "getUsersInfo", - Handler: _User_GetUsersInfo_Handler, + MethodName: "getDesignateUsers", + Handler: _User_GetDesignateUsers_Handler, }, { MethodName: "updateUserInfo", @@ -1454,8 +1430,8 @@ var _User_serviceDesc = grpc.ServiceDesc{ Handler: _User_AccountCheck_Handler, }, { - MethodName: "getUsers", - Handler: _User_GetUsers_Handler, + MethodName: "getPaginationUsers", + Handler: _User_GetPaginationUsers_Handler, }, { MethodName: "userRegister", @@ -1466,66 +1442,65 @@ var _User_serviceDesc = grpc.ServiceDesc{ Metadata: "user/user.proto", } -func init() { proto.RegisterFile("user/user.proto", fileDescriptor_user_ca0d4cfbb41aa43a) } - -var fileDescriptor_user_ca0d4cfbb41aa43a = []byte{ - // 926 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x51, 0x6f, 0xdc, 0x44, - 0x10, 0x96, 0xef, 0x72, 0x4d, 0x33, 0x49, 0x9b, 0xcb, 0x26, 0x4d, 0x8c, 0xa3, 0xa2, 0xb0, 0xaa, - 0x20, 0x02, 0xf5, 0x4e, 0x0d, 0x42, 0x80, 0x10, 0x88, 0x92, 0x13, 0x70, 0x52, 0x8f, 0xab, 0x1c, - 0xa2, 0x22, 0x40, 0x04, 0xc7, 0xd9, 0xba, 0x56, 0xae, 0xf6, 0xc6, 0xb3, 0x4e, 0xc4, 0x1b, 0x12, - 0x3f, 0x83, 0x27, 0x78, 0xe1, 0xbf, 0x20, 0x7e, 0x14, 0xda, 0x5d, 0x3b, 0xb7, 0xf6, 0xda, 0x69, - 0x1a, 0xf5, 0x25, 0xb9, 0x99, 0x9d, 0xf9, 0x76, 0xbe, 0x99, 0x59, 0xcf, 0xc0, 0x6a, 0x8e, 0x2c, - 0x1b, 0xca, 0x3f, 0x03, 0x9e, 0xa5, 0x22, 0x25, 0x0b, 0xf2, 0xb7, 0xb7, 0x3b, 0xe5, 0x2c, 0x79, - 0x38, 0x9e, 0x3c, 0x3c, 0x60, 0xd9, 0x39, 0xcb, 0x86, 0xfc, 0x34, 0x1a, 0xaa, 0xf3, 0x21, 0x9e, - 0x9c, 0x1e, 0x5d, 0xe0, 0xf0, 0x02, 0xb5, 0xbd, 0xf7, 0x49, 0xab, 0x65, 0x98, 0x26, 0xe7, 0x2c, - 0xc3, 0x40, 0xc4, 0x69, 0x52, 0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94, 0x97, 0x37, 0xd6, 0x8a, 0x59, 0xde, 0x58, 0xaf, 0xce, 0x57, 0xf7, 0x7f, 0xdc, 0x96, 0x6b, - 0xf4, 0xd1, 0x78, 0x62, 0xec, 0xcf, 0xd2, 0xea, 0x33, 0xf9, 0xe7, 0xf8, 0x96, 0x52, 0x7c, 0xf8, - 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x20, 0xab, 0x70, 0x2d, 0xad, 0x0b, 0x00, 0x00, +func init() { proto.RegisterFile("user/user.proto", fileDescriptor_user_c6c77fe2e81ca7ab) } + +var fileDescriptor_user_c6c77fe2e81ca7ab = []byte{ + // 911 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x6d, 0x6f, 0xe3, 0x44, + 0x10, 0x96, 0x93, 0xe6, 0x8e, 0x4e, 0x7b, 0xd7, 0x74, 0xfb, 0x66, 0x5c, 0x0e, 0x95, 0xd5, 0x09, + 0x2a, 0xa4, 0x4b, 0xa0, 0x08, 0x01, 0x42, 0x20, 0x8e, 0x46, 0x40, 0xa4, 0x46, 0x39, 0x39, 0x54, + 0x20, 0xde, 0x82, 0xeb, 0x6e, 0x7d, 0x56, 0x8d, 0xbd, 0xf1, 0xac, 0x5b, 0xf1, 0x0d, 0x89, 0x7f, + 0xc2, 0x17, 0xfe, 0x0a, 0x42, 0xfc, 0x28, 0xb4, 0x6b, 0xa7, 0x59, 0x7b, 0xed, 0x5e, 0xae, 0xba, + 0x2f, 0x89, 0x77, 0x76, 0xe6, 0xd9, 0x79, 0x66, 0x66, 0x77, 0x06, 0x36, 0x32, 0x64, 0x69, 0x5f, + 0xfe, 0xf4, 0x78, 0x9a, 0x88, 0x84, 0xac, 0xc8, 0x6f, 0xe7, 0x70, 0xcc, 0x59, 0xfc, 0x64, 0x38, + 0x7a, 0x32, 0x61, 0xe9, 0x15, 0x4b, 0xfb, 0xfc, 0x32, 0x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, 0xe0, 0xad, 0x97, 0x84, 0x97, 0xec, + 0xc6, 0x66, 0x51, 0x6a, 0xa2, 0xda, 0x8b, 0xd5, 0x6e, 0xbe, 0x58, 0x63, 0x2d, 0x56, 0x2b, 0x05, + 0x9a, 0x16, 0xab, 0x11, 0xbc, 0xde, 0xc0, 0x06, 0xb9, 0xec, 0x28, 0x93, 0xcc, 0xf7, 0x19, 0xce, + 0x8b, 0x68, 0xbe, 0x94, 0x6f, 0xef, 0x57, 0x5e, 0x18, 0xb1, 0x73, 0xbb, 0xad, 0x36, 0x8a, 0x15, + 0xfd, 0x59, 0x75, 0x9a, 0x45, 0x8f, 0xbf, 0x69, 0x4e, 0xe5, 0x29, 0xa1, 0x75, 0xc7, 0x29, 0xc1, + 0x53, 0x75, 0x63, 0xc0, 0x37, 0xce, 0x0a, 0xef, 0x43, 0x47, 0x75, 0xac, 0x22, 0xcd, 0xb7, 0x36, + 0xa3, 0x5c, 0x93, 0x0e, 0xf2, 0xf1, 0xca, 0x65, 0x41, 0x88, 0x42, 0xfe, 0xcf, 0x16, 0x28, 0xd6, + 0xd2, 0x28, 0x04, 0xba, 0x65, 0x14, 0xe4, 0x47, 0xff, 0xb4, 0x41, 0x0d, 0x6a, 0xe4, 0x04, 0x36, + 0x8d, 0x76, 0x4c, 0x9c, 0x7c, 0xb2, 0xa8, 0xeb, 0xec, 0xce, 0x7e, 0xe3, 0x1e, 0x72, 0x72, 0x0c, + 0x0f, 0xcb, 0xad, 0x93, 0xec, 0xe5, 0xea, 0x46, 0x7b, 0x76, 0xec, 0xfa, 0x0d, 0xe4, 0xe4, 0x17, + 0xd8, 0x6b, 0xe8, 0x83, 0xe4, 0x20, 0x37, 0x6a, 0x6e, 0xc4, 0xce, 0x5b, 0x2f, 0xd0, 0x40, 0x4e, + 0x3e, 0x83, 0x75, 0x7d, 0x66, 0x22, 0x3b, 0x75, 0x73, 0xd4, 0xcc, 0xd9, 0xad, 0x1f, 0xaf, 0xc8, + 0x58, 0x3d, 0xf4, 0x95, 0xbc, 0x93, 0x45, 0x58, 0xcc, 0x82, 0x73, 0xde, 0x68, 0xde, 0xcc, 0xfd, + 0xd1, 0xf3, 0x33, 0xf7, 0xa7, 0x92, 0xf9, 0xb9, 0x3f, 0xd5, 0x54, 0x7e, 0xf9, 0xe8, 0x87, 0x7d, + 0x39, 0x42, 0x4f, 0x87, 0x23, 0x6d, 0x76, 0x96, 0x5a, 0x9f, 0xca, 0x9f, 0xb3, 0x7b, 0x4a, 0xf0, + 0xc1, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x3a, 0xa4, 0xbe, 0xa9, 0x0b, 0x00, 0x00, } diff --git a/pkg/proto/user/user.proto b/pkg/proto/user/user.proto index fc78a3902..5755963d4 100644 --- a/pkg/proto/user/user.proto +++ b/pkg/proto/user/user.proto @@ -28,10 +28,10 @@ message accountCheckResp{ } -message getUsersInfoReq{ +message getDesignateUsersReq{ repeated string userIDs = 1; } -message getUsersInfoResp{ +message getDesignateUsersResp{ repeated server_api_params.UserInfo usersInfo = 1; } @@ -112,14 +112,11 @@ message batchSetConversationsResp{ } -message getUsersReq { +message getPaginationUsersReq { server_api_params.RequestPagination pagination = 2; - string userName = 3; - string userID = 4; - string content = 5; } -message getUsersResp{ +message getPaginationUsersResp{ int32 total = 1; repeated server_api_params.UserInfo users = 2; } @@ -135,7 +132,7 @@ message userRegisterResp { service user { //获取指定的用户信息 全字段 - rpc getUsersInfo(getUsersInfoReq) returns(getUsersInfoResp); + rpc getDesignateUsers(getDesignateUsersReq) returns(getDesignateUsersResp); //更新用户信息 rpc updateUserInfo(updateUserInfoReq) returns(updateUserInfoResp); //设置用户消息接收选项 @@ -143,7 +140,7 @@ service user { //检查userID是否存在 rpc accountCheck(accountCheckReq)returns(accountCheckResp); //翻页(或指定userID,昵称)拉取用户信息 全字段 - rpc getUsers(getUsersReq) returns (getUsersResp); + rpc getPaginationUsers(getPaginationUsersReq) returns (getPaginationUsersResp); //用户注册 rpc userRegister(userRegisterReq) returns (userRegisterResp); } diff --git a/pkg/utils/utils_v2.go b/pkg/utils/utils_v2.go index 88123808a..76d3946f8 100644 --- a/pkg/utils/utils_v2.go +++ b/pkg/utils/utils_v2.go @@ -144,6 +144,16 @@ func SliceSetAny[E any, K comparable](es []E, fn func(e E) K) map[K]struct{} { }) } +func Filter[E any](es []E, fn func(e E) bool) []E { + rs := make([]E, 0, len(es)) + for i := 0; i < len(es); i++ { + if e := es[i]; fn(e) { + rs = append(rs, e) + } + } + return rs +} + // Slice 批量转换切片类型 func Slice[E any, T any](es []E, fn func(e E) T) []T { v := make([]T, len(es))