mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
This commit is contained in:
commit
6d700765d2
11
go.mod
11
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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
})
|
||||
groups, err := s.GroupInterface.FindGroup(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupMemberNum, err := s.GroupInterface.MapGroupMemberNum(ctx, groupIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupOwnerUserID, err := s.GroupInterface.MapGroupOwnerUserID(ctx, groupIDs)
|
||||
owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner})
|
||||
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])))
|
||||
}
|
||||
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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -300,10 +300,8 @@ const (
|
||||
ReliableNotificationMsg = 3
|
||||
)
|
||||
const (
|
||||
BecomeFriendByImport = 1 //管理员导入
|
||||
BecomeFriendByMyApply = 2 //自己主动申请添加
|
||||
BecomeFriendByPeerApply = 3 //对方主动申请添加
|
||||
BecomeFriendByApply = 4 //申请添加
|
||||
BecomeFriendByImport = 1 //管理员导入
|
||||
BecomeFriendByApply = 2 //申请添加
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -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 //不能添加自己为好友
|
||||
)
|
||||
|
||||
// 群组错误码
|
||||
|
@ -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,79 +238,90 @@ 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 {
|
||||
//先find 找出重复的 去掉重复的
|
||||
fs1, err := f.friend.FindFriends(ctx, friendRequest.FromUserID, []string{friendRequest.ToUserID}, tx)
|
||||
_, err = f.friendRequest.Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
|
||||
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
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
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, ownerUserID, friendUserIDs, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
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 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 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
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
@ -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) SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, 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) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
return g.TakeGroup(ctx, groupID)
|
||||
}
|
||||
|
||||
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) FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) {
|
||||
return g.database.FindGroup(ctx, groupIDs)
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
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")
|
||||
return g.database.TakeGroupMember(ctx, groupID, userID)
|
||||
}
|
||||
|
||||
func (g *GroupController) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
return g.database.TakeGroupOwner(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) FindGroupOwnerUser(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) CreateGroupMember(ctx context.Context, groupMember []*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) 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")
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupController) DeleteSuperGroup(ctx context.Context, groupID string) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
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.TakeSuperGroup(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
return g.database.FindJoinSuperGroup(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
|
||||
return g.database.CreateSuperGroup(ctx, groupID, initMemberIDList)
|
||||
}
|
||||
|
||||
func (g *GroupController) DeleteSuperGroup(ctx context.Context, groupID string) error {
|
||||
return g.database.DeleteSuperGroup(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.database.DeleteSuperGroupMember(ctx, groupID, userIDs)
|
||||
}
|
||||
|
||||
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)
|
||||
//}
|
||||
var _ GroupDataBaseInterface = (*GroupDataBase)(nil)
|
||||
|
||||
func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) {
|
||||
return g.groupDB.Find(ctx, groupIDs)
|
||||
}
|
||||
type GroupDataBase struct {
|
||||
groupDB *relation.GroupGorm
|
||||
groupMemberDB *relation.GroupMemberGorm
|
||||
groupRequestDB *relation.GroupRequestGorm
|
||||
db *gorm.DB
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) {
|
||||
return g.groupDB.Take(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, keyword string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) {
|
||||
return g.groupDB.Search(ctx, keyword, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error {
|
||||
return g.groupDB.UpdateMap(ctx, groupID, data)
|
||||
}
|
||||
|
||||
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) FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error) {
|
||||
return g.groupMemberDB.FindGroupUser(ctx, []string{groupID}, userIDs, nil)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error) {
|
||||
return g.groupMemberDB.FindGroupUser(ctx, []string{groupID}, nil, nil)
|
||||
}
|
||||
|
||||
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) 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) 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) 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) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
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) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
return g.groupMemberDB.Delete(ctx, groupID, userIDs)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, 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) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, 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) MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) DeleteSuperGroup(ctx context.Context, groupID string) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) 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) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
return g.mongoDB.GetJoinGroup(ctx, userID, pageNumber, showNumber)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
|
||||
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 {
|
||||
return g.mongoDB.DeleteSuperGroup(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.mongoDB.RemoverUserFromSuperGroup(ctx, groupID, userIDs)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
|
||||
return g.mongoDB.AddUserToSuperGroup(ctx, groupID, userIDs)
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
return g.mongoDB.MapGroupMemberCount(ctx, groupIDs)
|
||||
}
|
||||
|
||||
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), "")
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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, "")
|
||||
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) FindOwnerUserID(ctx context.Context, ownerUserID string) (friends []*relation.FriendModel, err 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, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friends", friends)
|
||||
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 = ?", ownerUserID).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, "")
|
||||
}
|
||||
|
||||
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) FindUserState(ctx context.Context, userID1, userID2 string) (friends []*relation.FriendModel, err error) {
|
||||
defer func() {
|
||||
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "userID1", userID1, "userID2", userID2)
|
||||
}()
|
||||
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, "")
|
||||
}
|
||||
|
||||
// 获取 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
|
||||
}
|
||||
|
@ -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) (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) FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendRequestModel, total int64, err 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.GetSelfFuncName(), err, "toUserID", toUserID, "friends", friends)
|
||||
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) 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
|
||||
}
|
||||
|
||||
// 获取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.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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
return groupList, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "")
|
||||
if len(userIDs) > 0 {
|
||||
db = db.Where("user_id in (?)", userIDs)
|
||||
}
|
||||
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, "userID", userID, "total", total, "groupList", groupList)
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "groupIDs", groupIDs, "userIDs", userIDs, "roleLevels", roleLevels, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList)
|
||||
}()
|
||||
return gormPage[relation.GroupMemberModel](getDBConn(g.DB, tx).Where("user_id = ?", userID), pageNumber, showNumber)
|
||||
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) SearchMember(ctx context.Context, groupID string, name string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groupList []*relation.GroupMemberModel, err error) {
|
||||
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, "groupID", groupID, "name", name, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList)
|
||||
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "count", count)
|
||||
}()
|
||||
return gormSearch[relation.GroupMemberModel](getDBConn(g.DB, tx).Where("group_id = ?", groupID), "nickname", name, pageNumber, showNumber)
|
||||
return mapCount(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs), "group_id")
|
||||
}
|
||||
|
||||
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, "groupIDs", groupIDs, "groupUsers", groupUsers)
|
||||
}()
|
||||
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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"`
|
||||
|
@ -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"`
|
||||
|
@ -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"`
|
||||
}
|
||||
|
@ -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 {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
}
|
@ -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) }
|
||||
func init() { proto.RegisterFile("user/user.proto", fileDescriptor_user_c6c77fe2e81ca7ab) }
|
||||
|
||||
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, 0x11, 0xb4, 0x27, 0x7d, 0x06, 0xab, 0x11, 0x13, 0x8f, 0x67, 0xb3,
|
||||
0x43, 0x64, 0xd9, 0x78, 0xe4, 0xb3, 0x33, 0x32, 0x02, 0xe0, 0x41, 0x14, 0x27, 0xca, 0xcc, 0x75,
|
||||
0x76, 0x9c, 0xdd, 0xe5, 0xbd, 0x07, 0x03, 0x54, 0xc8, 0x47, 0x01, 0x8f, 0x8f, 0x78, 0x90, 0x05,
|
||||
0x2f, 0x71, 0xe0, 0xb3, 0xb3, 0x9c, 0xa1, 0x78, 0x7a, 0x69, 0xeb, 0x1b, 0x7e, 0xf4, 0x5b, 0xe8,
|
||||
0x57, 0x81, 0x91, 0x93, 0x0d, 0xe8, 0x89, 0x54, 0x04, 0x33, 0x05, 0xda, 0xf3, 0xb5, 0x40, 0xde,
|
||||
0x06, 0xc8, 0x95, 0xcd, 0x93, 0x18, 0x85, 0xdb, 0xd9, 0xe9, 0xee, 0x2e, 0xf9, 0x86, 0x86, 0x7e,
|
||||
0x04, 0xab, 0x41, 0x18, 0xa6, 0x79, 0x22, 0xf6, 0x5f, 0xb0, 0xf0, 0x54, 0x86, 0x48, 0x61, 0x25,
|
||||
0x94, 0xbf, 0x35, 0x36, 0xba, 0x8e, 0x72, 0xaa, 0xe8, 0xe8, 0x3f, 0x0e, 0xf4, 0xab, 0x7e, 0xc8,
|
||||
0xc9, 0x63, 0x58, 0xcc, 0x18, 0xe6, 0x33, 0xa1, 0x7d, 0x96, 0xf7, 0xde, 0x1b, 0xa8, 0xb4, 0xd7,
|
||||
0x0d, 0x07, 0x18, 0x27, 0xd1, 0x8c, 0x49, 0xac, 0x03, 0x11, 0x88, 0x1c, 0xfd, 0xd2, 0xcf, 0x7b,
|
||||
0x0a, 0xfd, 0xfa, 0x21, 0xd9, 0x84, 0x5b, 0x3a, 0x60, 0xc5, 0x6c, 0xc9, 0x2f, 0x24, 0xf2, 0x00,
|
||||
0xee, 0x14, 0xc8, 0xda, 0xd0, 0xed, 0xa8, 0xe3, 0xaa, 0x92, 0x7e, 0xa0, 0x6a, 0x20, 0xe1, 0x70,
|
||||
0x9c, 0x3c, 0x4f, 0x25, 0x41, 0x17, 0x16, 0xf3, 0x0a, 0xb7, 0x52, 0xa4, 0x13, 0x95, 0x57, 0xc3,
|
||||
0x18, 0x39, 0xf9, 0x14, 0x96, 0xf2, 0x52, 0x51, 0xf0, 0xda, 0x6e, 0x28, 0x98, 0xca, 0x8c, 0xf4,
|
||||
0x99, 0x5b, 0xd3, 0x27, 0xb0, 0x96, 0xf3, 0x93, 0x40, 0xb0, 0xcb, 0x43, 0x76, 0x46, 0x3e, 0x86,
|
||||
0xdb, 0x79, 0x21, 0x16, 0xf5, 0xbf, 0x12, 0xee, 0xd2, 0x98, 0x6e, 0x00, 0xa9, 0xa3, 0x21, 0xa7,
|
||||
0xbf, 0x82, 0x87, 0x4c, 0x7c, 0x33, 0x4b, 0x8f, 0x83, 0x99, 0xcf, 0xc2, 0xf3, 0x09, 0x43, 0x0c,
|
||||
0x22, 0x36, 0xe5, 0x42, 0x5e, 0xd6, 0x96, 0xbb, 0xf7, 0xa1, 0x1f, 0xcd, 0x5d, 0x30, 0x9a, 0x72,
|
||||
0xe1, 0x76, 0x55, 0xdf, 0x58, 0x7a, 0x7a, 0x1f, 0xb6, 0x5b, 0x6f, 0x40, 0x4e, 0xff, 0x76, 0x80,
|
||||
0x20, 0x13, 0xfb, 0x46, 0xfb, 0xcb, 0x9b, 0xbf, 0x80, 0x15, 0xf3, 0x45, 0x14, 0x54, 0xbd, 0x41,
|
||||
0xe5, 0x99, 0x54, 0x9c, 0x2a, 0xf6, 0x32, 0xc2, 0x24, 0x15, 0xf1, 0xf3, 0x38, 0x54, 0xf2, 0xf7,
|
||||
0xbf, 0x71, 0xa6, 0x0a, 0xdc, 0xf3, 0x2d, 0x3d, 0xd9, 0x81, 0xe5, 0x94, 0xb3, 0x4c, 0x29, 0xc6,
|
||||
0x23, 0x45, 0x64, 0xc9, 0x37, 0x55, 0xf4, 0x1e, 0xac, 0x5b, 0x31, 0x22, 0xa7, 0xff, 0x3a, 0xd0,
|
||||
0x47, 0x26, 0xe6, 0x64, 0x65, 0xe4, 0x12, 0xed, 0x22, 0x61, 0xd9, 0xa1, 0x99, 0x38, 0x53, 0x45,
|
||||
0xde, 0x85, 0xbb, 0x66, 0xac, 0xe3, 0x51, 0xd1, 0x7a, 0x35, 0xad, 0x7c, 0x7c, 0x59, 0x3d, 0xbf,
|
||||
0x86, 0xa6, 0x91, 0xe3, 0xc2, 0xf5, 0x38, 0xf6, 0x6c, 0x8e, 0xeb, 0xb0, 0x56, 0xe3, 0x82, 0x9c,
|
||||
0xfe, 0xee, 0x00, 0x89, 0xec, 0xea, 0xd8, 0x0c, 0x9c, 0x46, 0x06, 0xb5, 0x5c, 0x74, 0xec, 0x5c,
|
||||
0xbc, 0x3a, 0xf7, 0x87, 0xb0, 0x1e, 0xd9, 0xb9, 0xb7, 0x1a, 0xa4, 0xf3, 0x7a, 0x0d, 0x42, 0xff,
|
||||
0x70, 0x2c, 0x5c, 0xbc, 0x5e, 0xf9, 0x76, 0x61, 0xb5, 0x4a, 0x13, 0x8b, 0x0f, 0x63, 0x5d, 0x7d,
|
||||
0x0d, 0x72, 0x3f, 0xc0, 0x86, 0x1d, 0x04, 0x72, 0xf2, 0x25, 0xdc, 0x31, 0xc1, 0xf4, 0x0d, 0x57,
|
||||
0xd3, 0xab, 0x3a, 0xd0, 0x9f, 0x61, 0x53, 0x7f, 0xe3, 0x6f, 0xc0, 0xb0, 0x16, 0x77, 0xc7, 0x8e,
|
||||
0xfb, 0x27, 0xd8, 0x6a, 0x44, 0x7f, 0x23, 0xa1, 0xff, 0xe7, 0x80, 0x7b, 0x1c, 0x88, 0xf0, 0xc5,
|
||||
0x41, 0x43, 0x7d, 0x2c, 0x78, 0xe7, 0x35, 0xe1, 0x25, 0xbb, 0xa9, 0xdd, 0x94, 0x86, 0xaa, 0xf1,
|
||||
0x61, 0x75, 0xdb, 0x1f, 0xd6, 0xd4, 0xc8, 0xd5, 0x42, 0x81, 0x66, 0xe4, 0x6a, 0x02, 0x6f, 0xb5,
|
||||
0xb0, 0x41, 0x2e, 0x87, 0xc9, 0x41, 0x1e, 0x86, 0x0c, 0xcb, 0x26, 0x2a, 0x45, 0xf9, 0xed, 0xfd,
|
||||
0x3a, 0x88, 0x67, 0xec, 0xc4, 0xed, 0xaa, 0x83, 0x42, 0xa2, 0x7f, 0x39, 0xb0, 0x5c, 0x4e, 0x19,
|
||||
0x7b, 0x25, 0xe8, 0xdc, 0x6c, 0x25, 0x20, 0x9e, 0x1e, 0x2b, 0xdf, 0x05, 0x2f, 0x59, 0xd1, 0xa7,
|
||||
0x97, 0xb2, 0x31, 0x05, 0x16, 0x2a, 0x53, 0xc0, 0x85, 0xc5, 0x30, 0x4d, 0x04, 0x4b, 0x44, 0xf1,
|
||||
0x3d, 0x29, 0x45, 0xfa, 0x0c, 0x56, 0xe6, 0x21, 0xb6, 0x2e, 0x17, 0x8f, 0xa0, 0xa7, 0x86, 0x5d,
|
||||
0xd1, 0x21, 0x57, 0xce, 0x31, 0x6d, 0x49, 0x47, 0x7a, 0x1f, 0xf3, 0x59, 0x14, 0xa3, 0x90, 0xff,
|
||||
0xcf, 0xe6, 0x28, 0xce, 0xb5, 0x51, 0x08, 0xf4, 0xab, 0x28, 0xc8, 0xf7, 0xfe, 0xec, 0x82, 0xda,
|
||||
0xec, 0xc8, 0xe7, 0xf3, 0xd8, 0xa5, 0x0f, 0xb9, 0xa7, 0xb7, 0x90, 0xda, 0x16, 0xe0, 0x6d, 0x36,
|
||||
0xa9, 0x91, 0x93, 0x7d, 0xb8, 0x5b, 0x1d, 0xb3, 0x64, 0x4b, 0x5b, 0x5a, 0xa3, 0xdc, 0x73, 0x9b,
|
||||
0x0f, 0x90, 0x93, 0x5f, 0x60, 0xab, 0x65, 0x66, 0x92, 0x1d, 0xed, 0xd4, 0x3e, 0xb4, 0xbd, 0x77,
|
||||
0x5e, 0x61, 0x81, 0x5c, 0x72, 0x34, 0xb7, 0xaa, 0x92, 0x63, 0x6d, 0x95, 0x2b, 0x39, 0x5a, 0x9b,
|
||||
0xda, 0x23, 0xb8, 0x5d, 0xf2, 0x26, 0x6b, 0xd5, 0x3c, 0x48, 0x37, 0x52, 0x57, 0xe9, 0x1b, 0xcd,
|
||||
0x94, 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,
|
||||
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, 0xe8, 0xab, 0xfd, 0x3e, 0x9e, 0x5f, 0x4e,
|
||||
0xaf, 0xb1, 0x7f, 0x8d, 0xb9, 0xbe, 0xf3, 0x71, 0xa3, 0xa6, 0x9f, 0xc4, 0x57, 0x2c, 0x45, 0x4f,
|
||||
0x84, 0x49, 0x5c, 0x5a, 0xe4, 0x96, 0xf4, 0x3b, 0xd8, 0x08, 0x98, 0x78, 0x1a, 0x45, 0xa7, 0xc8,
|
||||
0xd2, 0xe1, 0xc0, 0x65, 0x33, 0x32, 0x00, 0xe0, 0x5e, 0x10, 0xc6, 0x4a, 0xcd, 0xb6, 0x0e, 0xac,
|
||||
0xc3, 0xb5, 0xa3, 0xc7, 0x3d, 0x54, 0xc8, 0x53, 0x8f, 0x87, 0x53, 0xee, 0xa5, 0xde, 0x6f, 0xd8,
|
||||
0x73, 0xd9, 0x2c, 0x63, 0x28, 0x9e, 0xdd, 0xe8, 0xba, 0x9a, 0x1d, 0xfd, 0x06, 0xba, 0x65, 0x60,
|
||||
0xe4, 0x64, 0x1b, 0x3a, 0x22, 0x11, 0x5e, 0xa4, 0x40, 0x3b, 0x6e, 0xbe, 0x20, 0x6f, 0x02, 0x64,
|
||||
0x4a, 0xe7, 0x24, 0x44, 0x61, 0xb7, 0x0e, 0xda, 0x87, 0xab, 0xae, 0x26, 0xa1, 0x1f, 0xc2, 0x86,
|
||||
0xe7, 0xfb, 0x49, 0x16, 0x8b, 0xe3, 0xe7, 0xcc, 0xbf, 0x94, 0x2e, 0x52, 0x58, 0xf7, 0xe5, 0x77,
|
||||
0x8e, 0x8d, 0xb6, 0xa5, 0x8c, 0x4a, 0x32, 0xfa, 0xb7, 0x05, 0xdd, 0xb2, 0x1d, 0x72, 0xf2, 0x14,
|
||||
0xee, 0xa7, 0x0c, 0xb3, 0x48, 0xe4, 0x36, 0x6b, 0x47, 0xef, 0xf4, 0x54, 0xd8, 0xab, 0x8a, 0x3d,
|
||||
0x0c, 0xe3, 0x20, 0x62, 0x12, 0x6b, 0x22, 0x3c, 0x91, 0xa1, 0x3b, 0xb7, 0x73, 0x9e, 0x41, 0xb7,
|
||||
0xba, 0x49, 0x76, 0xe1, 0x5e, 0xee, 0xb0, 0x62, 0xb6, 0xea, 0x16, 0x2b, 0xf2, 0x18, 0x1e, 0x14,
|
||||
0xc8, 0xb9, 0xa2, 0xdd, 0x52, 0xdb, 0x65, 0x21, 0x7d, 0x0f, 0xb6, 0x03, 0x26, 0x06, 0x0c, 0xc3,
|
||||
0x20, 0xf6, 0x84, 0xc2, 0x45, 0xc9, 0xd2, 0x86, 0xfb, 0x59, 0x89, 0xe0, 0x7c, 0x49, 0x5d, 0xd8,
|
||||
0xa9, 0xb1, 0x40, 0x4e, 0x3e, 0x81, 0x55, 0xa9, 0x83, 0xc3, 0xf8, 0x22, 0x29, 0x18, 0xee, 0xd7,
|
||||
0xa4, 0x4e, 0xc5, 0x28, 0xbe, 0x48, 0xdc, 0x85, 0x36, 0x3d, 0x81, 0xcd, 0x8c, 0x9f, 0x17, 0x68,
|
||||
0x6a, 0x93, 0xcd, 0xc8, 0x47, 0xf0, 0x5a, 0x56, 0x2c, 0x8b, 0x4a, 0xb8, 0x15, 0xee, 0x46, 0x99,
|
||||
0x6e, 0x03, 0xa9, 0xa2, 0x21, 0xa7, 0xbf, 0x82, 0x83, 0x4c, 0x7c, 0x1d, 0x25, 0x67, 0x5e, 0xe4,
|
||||
0x32, 0xff, 0x6a, 0xc4, 0x10, 0xbd, 0x80, 0x8d, 0xb9, 0x90, 0x87, 0x35, 0x45, 0xf1, 0x5d, 0xe8,
|
||||
0x06, 0x0b, 0x13, 0x0c, 0xc6, 0x5c, 0xd8, 0x6d, 0x55, 0x41, 0x86, 0x9c, 0x3e, 0x82, 0xfd, 0xc6,
|
||||
0x13, 0x90, 0xd3, 0xbf, 0x2c, 0x20, 0xc8, 0xc4, 0xb1, 0x76, 0x11, 0xe4, 0xc9, 0x9f, 0xc3, 0xba,
|
||||
0x7e, 0x37, 0x0a, 0xaa, 0x4e, 0xaf, 0x74, 0x61, 0x4a, 0x46, 0x25, 0x7d, 0xe9, 0x61, 0x9c, 0x88,
|
||||
0xf0, 0x22, 0xf4, 0xd5, 0xfa, 0xdb, 0xdf, 0x39, 0x53, 0xa9, 0xee, 0xb8, 0x86, 0x9c, 0x1c, 0xc0,
|
||||
0x5a, 0xc2, 0x59, 0xaa, 0x04, 0xc3, 0x81, 0x22, 0xb2, 0xea, 0xea, 0x22, 0xba, 0x03, 0x5b, 0x86,
|
||||
0x8f, 0xc8, 0xe9, 0xbf, 0x16, 0x74, 0x91, 0x89, 0x05, 0x59, 0xe9, 0xb9, 0x44, 0xbb, 0x8e, 0x59,
|
||||
0x7a, 0xaa, 0x07, 0x4e, 0x17, 0x91, 0xb7, 0xe1, 0xa1, 0xee, 0xeb, 0x70, 0x50, 0x14, 0x61, 0x45,
|
||||
0x2a, 0xaf, 0x61, 0x5a, 0x8d, 0xaf, 0x26, 0xa9, 0xe5, 0xb8, 0xb2, 0x1c, 0xc7, 0x8e, 0xc9, 0x71,
|
||||
0x0b, 0x36, 0x2b, 0x5c, 0x90, 0xd3, 0x3f, 0x2c, 0x20, 0x81, 0x99, 0x1d, 0x93, 0x81, 0x55, 0xcb,
|
||||
0xa0, 0x12, 0x8b, 0x96, 0x19, 0x8b, 0x17, 0xc7, 0xfe, 0x14, 0xb6, 0x02, 0x33, 0xf6, 0x46, 0x81,
|
||||
0xb4, 0x5e, 0xae, 0x40, 0xe8, 0x9f, 0x96, 0x81, 0x8b, 0xcb, 0xa5, 0xef, 0x10, 0x36, 0xca, 0x34,
|
||||
0xb1, 0x78, 0x22, 0xab, 0xe2, 0x25, 0xc8, 0x7d, 0xaf, 0x1e, 0x9a, 0x8a, 0x13, 0xc8, 0xc9, 0x17,
|
||||
0xf0, 0x40, 0x07, 0xcb, 0x4f, 0xb8, 0x9d, 0x5e, 0xd9, 0x80, 0xfe, 0x04, 0xbb, 0xf9, 0x6b, 0x7f,
|
||||
0x07, 0x86, 0x15, 0xbf, 0x5b, 0xa6, 0xdf, 0x3f, 0xc2, 0x5e, 0x2d, 0xfa, 0x2b, 0x71, 0xfd, 0x3f,
|
||||
0x0b, 0xec, 0x33, 0x4f, 0xf8, 0xcf, 0x27, 0x35, 0xf9, 0x31, 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,
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user