diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 0f88381a3..6dcb94456 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -6,8 +6,8 @@ import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/controller" - "Open_IM/pkg/common/db/relation" - relationTb "Open_IM/pkg/common/db/table/relation" + relation_conn "Open_IM/pkg/common/db/relation" + "Open_IM/pkg/common/db/table/relation" "Open_IM/pkg/common/db/unrelation" "Open_IM/pkg/common/log" "Open_IM/pkg/common/middleware" @@ -38,7 +38,7 @@ type groupServer struct { rpcRegisterName string etcdSchema string etcdAddr []string - controller.GroupInterface + GroupInterface controller.GroupInterface etcdConn *getcdv3.EtcdConn //userRpc pbUser.UserClient @@ -71,9 +71,9 @@ func NewGroupServer(port int) *groupServer { //g.conversationRpc = pbConversation.NewConversationClient(conn) //mysql init - var mysql relation.Mysql + var mysql relation_conn.Mysql var mongo unrelation.Mongo - var groupModel relationTb.GroupModel + var groupModel relation.GroupModel var redis cache.RedisClient err = mysql.InitConn().AutoMigrateModel(&groupModel) if err != nil { @@ -98,7 +98,7 @@ func NewGroupServer(port int) *groupServer { } var registerCenter discoveryRegistry.SvcDiscoveryRegistry = zkClient conns, err := registerCenter.GetConns(config.Config.RpcRegisterName.OpenImConversationName) - g.GroupInterface = controller.NewGroupController(groupModel.DB, redis.GetClient(), mongo.GetClient()) + g.GroupInterface = controller.NewGroupInterface(controller.NewGroupDatabase(mysql.GormConn(), redis.GetClient(), mongo.GetClient())) return &g } @@ -200,7 +200,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR if err := callbackBeforeCreateGroup(ctx, req); err != nil { return nil, err } - var groupMembers []*relationTb.GroupMemberModel + var groupMembers []*relation.GroupMemberModel group := PbToDBGroupInfo(req.GroupInfo) group.GroupID = genGroupID(ctx, req.GroupInfo.GroupID) joinGroup := func(userID string, roleLevel int32) error { @@ -235,7 +235,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } } } - if err := s.GroupInterface.CreateGroup(ctx, []*relationTb.GroupModel{group}, groupMembers); err != nil { + if err := s.GroupInterface.CreateGroup(ctx, []*relation.GroupModel{group}, groupMembers); err != nil { return nil, err } resp.GroupInfo = DbToPbGroupInfo(group, req.OwnerUserID, uint32(len(userIDs))) @@ -265,7 +265,7 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo if len(members) == 0 { return resp, nil } - groupIDs := utils.Slice(members, func(e *relationTb.GroupMemberModel) string { + groupIDs := utils.Slice(members, func(e *relation.GroupMemberModel) string { return e.GroupID }) groups, err := s.GroupInterface.FindGroup(ctx, groupIDs) @@ -280,12 +280,12 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo if err != nil { return nil, err } - ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string { + ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string { return e.GroupID }) - resp.Groups = utils.Slice(utils.Order(groupIDs, groups, func(group *relationTb.GroupModel) string { + resp.Groups = utils.Slice(utils.Order(groupIDs, groups, func(group *relation.GroupModel) string { return group.GroupID - }), func(group *relationTb.GroupModel) *open_im_sdk.GroupInfo { + }), func(group *relation.GroupModel) *open_im_sdk.GroupInfo { return DbToPbGroupInfo(group, ownerMap[group.GroupID].UserID, uint32(groupMemberNum[group.GroupID])) }) return resp, nil @@ -310,7 +310,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite if err != nil { return nil, err } - memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) string { + memberMap := utils.SliceToMap(members, func(e *relation.GroupMemberModel) string { return e.UserID }) if ids := utils.Single(req.InvitedUserIDs, utils.Keys(memberMap)); len(ids) > 0 { @@ -331,9 +331,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite return nil, constant.ErrNoPermission.Wrap("not in group") } if !(member.RoleLevel == constant.GroupOwner || member.RoleLevel == constant.GroupAdmin) { - var requests []*relationTb.GroupRequestModel + var requests []*relation.GroupRequestModel for _, userID := range req.InvitedUserIDs { - requests = append(requests, &relationTb.GroupRequestModel{ + requests = append(requests, &relation.GroupRequestModel{ UserID: userID, GroupID: req.GroupID, JoinSource: constant.JoinByInvitation, @@ -364,7 +364,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite } } else { opUserID := tracelog.GetOpUserID(ctx) - var groupMembers []*relationTb.GroupMemberModel + var groupMembers []*relation.GroupMemberModel for _, userID := range req.InvitedUserIDs { member := PbToDbGroupMember(userMap[userID]) member.GroupID = req.GroupID @@ -398,7 +398,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro if err != nil { return nil, err } - resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { + resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { return DbToPbGroupMembersCMSResp(e) }) return resp, nil @@ -411,7 +411,7 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGr return nil, err } resp.Total = total - resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { + resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { return DbToPbGroupMembersCMSResp(e) }) return resp, nil @@ -447,7 +447,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou if err != nil { return nil, err } - memberMap := make(map[string]*relationTb.GroupMemberModel) + memberMap := make(map[string]*relation.GroupMemberModel) for i, member := range members { memberMap[member.UserID] = members[i] } @@ -496,7 +496,7 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG if err != nil { return nil, err } - resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { + resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { return DbToPbGroupMembersCMSResp(e) }) return resp, nil @@ -533,7 +533,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup. if err != nil { return nil, err } - groupMap := utils.SliceToMap(groups, func(e *relationTb.GroupModel) string { + groupMap := utils.SliceToMap(groups, func(e *relation.GroupModel) string { return e.GroupID }) if ids := utils.Single(utils.Keys(groupMap), groupIDs); len(ids) > 0 { @@ -547,10 +547,10 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup. if err != nil { return nil, err } - ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string { + ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string { return e.GroupID }) - resp.GroupRequests = utils.Slice(groupRequests, func(e *relationTb.GroupRequestModel) *open_im_sdk.GroupRequest { + resp.GroupRequests = utils.Slice(groupRequests, func(e *relation.GroupRequestModel) *open_im_sdk.GroupRequest { return DbToPbGroupRequest(e, userMap[e.UserID], DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID]))) }) return resp, nil @@ -573,10 +573,10 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI if err != nil { return nil, err } - ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string { + ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string { return e.GroupID }) - resp.GroupInfos = utils.Slice(groups, func(e *relationTb.GroupModel) *open_im_sdk.GroupInfo { + resp.GroupInfos = utils.Slice(groups, func(e *relation.GroupModel) *open_im_sdk.GroupInfo { return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(groupMemberNumMap[e.GroupID])) }) return resp, nil @@ -618,9 +618,9 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup if err != nil { return nil, err } - var member *relationTb.GroupMemberModel + var member *relation.GroupMemberModel if req.HandleResult == constant.GroupResponseAgree { - member = &relationTb.GroupMemberModel{ + member = &relation.GroupMemberModel{ GroupID: req.GroupID, UserID: user.UserID, Nickname: user.Nickname, @@ -664,7 +664,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) if group.GroupType == constant.SuperGroup { return nil, constant.ErrGroupTypeNotSupport.Wrap() } - user, err := relation.GetUserByUserID(tracelog.GetOpUserID(ctx)) + user, err := relation_conn.GetUserByUserID(tracelog.GetOpUserID(ctx)) if err != nil { return nil, err } @@ -677,20 +677,20 @@ 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.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil { + if err := s.GroupInterface.CreateGroup(ctx, nil, []*relation.GroupMemberModel{groupMember}); err != nil { return nil, err } chat.MemberEnterDirectlyNotification(req.GroupID, tracelog.GetOpUserID(ctx), tracelog.GetOperationID(ctx)) return resp, nil } - groupRequest := relationTb.GroupRequestModel{ + groupRequest := relation.GroupRequestModel{ UserID: tracelog.GetOpUserID(ctx), ReqMsg: req.ReqMessage, GroupID: req.GroupID, JoinSource: req.JoinSource, ReqTime: time.Now(), } - if err := s.GroupInterface.CreateGroupRequest(ctx, []*relationTb.GroupRequestModel{&groupRequest}); err != nil { + if err := s.GroupInterface.CreateGroupRequest(ctx, []*relation.GroupRequestModel{&groupRequest}); err != nil { return nil, err } chat.JoinGroupApplicationNotification(ctx, req) @@ -770,7 +770,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans if err != nil { return nil, err } - memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) string { return e.UserID }) + memberMap := utils.SliceToMap(members, func(e *relation.GroupMemberModel) string { return e.UserID }) if ids := utils.Single([]string{req.OldOwnerUserID, req.NewOwnerUserID}, utils.Keys(memberMap)); len(ids) > 0 { return nil, constant.ErrArgs.Wrap("user not in group " + strings.Join(ids, ",")) } @@ -804,26 +804,26 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) { resp := &pbGroup.GetGroupsResp{} var ( - groups []*relationTb.GroupModel + groups []*relation.GroupModel err error ) if req.GroupID != "" { groups, err = s.GroupInterface.FindGroup(ctx, []string{req.GroupID}) - resp.GroupNum = int32(len(groups)) + resp.Total = uint32(len(groups)) } else { - resp.GroupNum, groups, err = s.GroupInterface.SearchGroup(ctx, req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber) + resp.Total, groups, err = s.GroupInterface.SearchGroup(ctx, req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber) } if err != nil { return nil, err } - groupIDs := utils.Slice(groups, func(e *relationTb.GroupModel) string { + groupIDs := utils.Slice(groups, func(e *relation.GroupModel) string { return e.GroupID }) ownerMembers, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner}) if err != nil { return nil, err } - ownerMemberMap := utils.SliceToMap(ownerMembers, func(e *relationTb.GroupMemberModel) string { + ownerMemberMap := utils.SliceToMap(ownerMembers, func(e *relation.GroupMemberModel) string { return e.GroupID }) if ids := utils.Single(groupIDs, utils.Keys(ownerMemberMap)); len(ids) > 0 { @@ -833,7 +833,7 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq) if err != nil { return nil, err } - resp.Groups = utils.Slice(groups, func(group *relationTb.GroupModel) *pbGroup.CMSGroup { + resp.Groups = utils.Slice(groups, func(group *relation.GroupModel) *pbGroup.CMSGroup { member := ownerMemberMap[group.GroupID] return DbToPbCMSGroup(group, member.UserID, member.Nickname, uint32(groupMemberNumMap[group.GroupID])) }) @@ -846,8 +846,8 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGr if err != nil { return nil, err } - resp.MemberNums = total - resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { + resp.Total = total + resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { return DbToPbGroupMembersCMSResp(e) }) return resp, nil @@ -867,14 +867,14 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou if len(requests) == 0 { return resp, nil } - groupIDs := utils.Distinct(utils.Slice(requests, func(e *relationTb.GroupRequestModel) string { + groupIDs := utils.Distinct(utils.Slice(requests, func(e *relation.GroupRequestModel) string { return e.GroupID })) groups, err := s.GroupInterface.FindGroup(ctx, groupIDs) if err != nil { return nil, err } - groupMap := utils.SliceToMap(groups, func(e *relationTb.GroupModel) string { + groupMap := utils.SliceToMap(groups, func(e *relation.GroupModel) string { return e.GroupID }) if ids := utils.Single(groupIDs, utils.Keys(groupMap)); len(ids) > 0 { @@ -884,7 +884,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou if err != nil { return nil, err } - ownerMap := utils.SliceToMap(owners, func(e *relationTb.GroupMemberModel) string { + ownerMap := utils.SliceToMap(owners, func(e *relation.GroupMemberModel) string { return e.GroupID }) if ids := utils.Single(groupIDs, utils.Keys(ownerMap)); len(ids) > 0 { @@ -894,7 +894,7 @@ func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGrou if err != nil { return nil, err } - resp.GroupRequests = utils.Slice(requests, func(e *relationTb.GroupRequestModel) *open_im_sdk.GroupRequest { + resp.GroupRequests = utils.Slice(requests, func(e *relation.GroupRequestModel) *open_im_sdk.GroupRequest { return DbToPbGroupRequest(e, user, DbToPbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID]))) }) return resp, nil @@ -1058,7 +1058,7 @@ func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.Get if err != nil { return nil, err } - resp.GroupAbstractInfos = utils.Slice(groups, func(e *relationTb.GroupModel) *pbGroup.GroupAbstractInfo { + resp.GroupAbstractInfos = utils.Slice(groups, func(e *relation.GroupModel) *pbGroup.GroupAbstractInfo { userIDs := groupUserMap[e.GroupID] utils.Sort(userIDs, true) bi := big.NewInt(0) @@ -1077,7 +1077,7 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.Ge if err != nil { return nil, err } - resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { + resp.Members = utils.Slice(members, func(e *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo { return DbToPbGroupMembersCMSResp(e) }) return resp, nil diff --git a/internal/rpc/group/super_group.go b/internal/rpc/group/super_group.go index 5e0fc1892..ebdab3723 100644 --- a/internal/rpc/group/super_group.go +++ b/internal/rpc/group/super_group.go @@ -3,42 +3,53 @@ package group import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/table/relation" + "Open_IM/pkg/common/db/table/unrelation" pbGroup "Open_IM/pkg/proto/group" sdk_ws "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" + "fmt" + "strings" ) func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) { resp := &pbGroup.GetJoinedSuperGroupListResp{} - total, groupIDs, err := s.GroupInterface.FindJoinSuperGroup(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber) + joinSuperGroup, err := s.GroupInterface.FindJoinSuperGroup(ctx, req.UserID) if err != nil { return nil, err } - resp.Total = total - if len(groupIDs) == 0 { + if len(joinSuperGroup.GroupIDs) == 0 { return resp, nil } - numMap, err := s.GroupInterface.MapSuperGroupMemberNum(ctx, groupIDs) - if err != nil { - return nil, err - } - owners, err := s.GroupInterface.FindGroupMember(ctx, groupIDs, nil, []int32{constant.GroupOwner}) + owners, err := s.GroupInterface.FindGroupMember(ctx, joinSuperGroup.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 ids := utils.Single(joinSuperGroup.GroupIDs, utils.Keys(ownerMap)); len(ids) > 0 { + return nil, constant.ErrData.Wrap(fmt.Sprintf("super group %s not owner", strings.Join(ids, ","))) + } + groups, err := s.GroupInterface.FindGroup(ctx, joinSuperGroup.GroupIDs) if err != nil { return nil, err } groupMap := utils.SliceToMap(groups, func(e *relation.GroupModel) string { return e.GroupID }) - resp.Groups = utils.Slice(groupIDs, func(groupID string) *sdk_ws.GroupInfo { - return DbToPbGroupInfo(groupMap[groupID], ownerMap[groupID].UserID, numMap[groupID]) + if ids := utils.Single(joinSuperGroup.GroupIDs, utils.Keys(groupMap)); len(ids) > 0 { + return nil, constant.ErrData.Wrap(fmt.Sprintf("super group info %s not found", strings.Join(ids, ","))) + } + superGroupMembers, err := s.GroupInterface.FindSuperGroup(ctx, joinSuperGroup.GroupIDs) + if err != nil { + return nil, err + } + superGroupMemberMap := utils.SliceToMapAny(superGroupMembers, func(e *unrelation.SuperGroupModel) (string, []string) { + return e.GroupID, e.MemberIDs + }) + resp.Groups = utils.Slice(joinSuperGroup.GroupIDs, func(groupID string) *sdk_ws.GroupInfo { + return DbToPbGroupInfo(groupMap[groupID], ownerMap[groupID].UserID, uint32(len(superGroupMemberMap))) }) return resp, nil } @@ -52,10 +63,13 @@ func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSu if err != nil { return nil, err } - numMap, err := s.GroupInterface.MapSuperGroupMemberNum(ctx, req.GroupIDs) + superGroupMembers, err := s.GroupInterface.FindSuperGroup(ctx, req.GroupIDs) if err != nil { return nil, err } + superGroupMemberMap := utils.SliceToMapAny(superGroupMembers, func(e *unrelation.SuperGroupModel) (string, []string) { + return e.GroupID, e.MemberIDs + }) owners, err := s.GroupInterface.FindGroupMember(ctx, req.GroupIDs, nil, []int32{constant.GroupOwner}) if err != nil { return nil, err @@ -64,7 +78,7 @@ func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSu return e.GroupID }) resp.GroupInfos = utils.Slice(groups, func(e *relation.GroupModel) *sdk_ws.GroupInfo { - return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, numMap[e.GroupID]) + return DbToPbGroupInfo(e, ownerMap[e.GroupID].UserID, uint32(len(superGroupMemberMap[e.GroupID]))) }) return resp, nil } diff --git a/pkg/common/db/cache/conversation.go b/pkg/common/db/cache/conversation.go index 88d068119..3a6b0e0ce 100644 --- a/pkg/common/db/cache/conversation.go +++ b/pkg/common/db/cache/conversation.go @@ -95,7 +95,7 @@ func (c *ConversationRedis) GetUserConversationIDs(ctx context.Context, ownerUse // return nil, utils.Wrap(err, "") //} //return conversationIDs, nil - return GetCache(c.rcClient, c.getConversationIDsKey(ownerUserID), time.Second*30*60, func() ([]string, error) { + return GetCache(ctx, c.rcClient, c.getConversationIDsKey(ownerUserID), time.Second*30*60, func(ctx context.Context) ([]string, error) { return f(ownerUserID) }) } @@ -124,32 +124,32 @@ func (c *ConversationRedis) GetUserConversationIDs1(ctx context.Context, ownerUs return GetCache1[[]string](c.rcClient, c.getConversationIDsKey(ownerUserID), time.Second*30*60, fn) } -func GetCache1[T any](rcClient *rockscache.Client, key string, expire time.Duration, fn func() (any, error)) (T, error) { - v, err := rcClient.Fetch(key, expire, func() (string, error) { - v, err := fn() - if err != nil { - return "", err - } - bs, err := json.Marshal(v) - if err != nil { - return "", utils.Wrap(err, "") - } - return string(bs), nil - }) - var t T - if err != nil { - return t, err - } - err = json.Unmarshal([]byte(v), &t) - if err != nil { - return t, utils.Wrap(err, "") - } - return t, nil -} +//func GetCache1[T any](rcClient *rockscache.Client, key string, expire time.Duration, fn func() (any, error)) (T, error) { +// v, err := rcClient.Fetch(key, expire, func() (string, error) { +// v, err := fn() +// if err != nil { +// return "", err +// } +// bs, err := json.Marshal(v) +// if err != nil { +// return "", utils.Wrap(err, "") +// } +// return string(bs), nil +// }) +// var t T +// if err != nil { +// return t, err +// } +// err = json.Unmarshal([]byte(v), &t) +// if err != nil { +// return t, utils.Wrap(err, "") +// } +// return t, nil +//} -func GetCache[T any](rcClient *rockscache.Client, key string, expire time.Duration, fn func() (T, error)) (T, error) { +func GetCache[T any](ctx context.Context, rcClient *rockscache.Client, key string, expire time.Duration, fn func(ctx context.Context) (T, error)) (T, error) { v, err := rcClient.Fetch(key, expire, func() (string, error) { - v, err := fn() + v, err := fn(ctx) if err != nil { return "", err } diff --git a/pkg/common/db/controller/group.go b/pkg/common/db/controller/group.go index 380d31068..3d0bd5923 100644 --- a/pkg/common/db/controller/group.go +++ b/pkg/common/db/controller/group.go @@ -4,8 +4,8 @@ import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/relation" - relationTb "Open_IM/pkg/common/db/table/relation" - unRelationTb "Open_IM/pkg/common/db/table/unrelation" + relation2 "Open_IM/pkg/common/db/table/relation" + unrelation2 "Open_IM/pkg/common/db/table/unrelation" "Open_IM/pkg/common/db/unrelation" "Open_IM/pkg/utils" "context" @@ -20,57 +20,60 @@ import ( //type GroupInterface GroupDataBaseInterface type GroupInterface interface { - CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error - TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) - FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) - SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relationTb.GroupModel, error) + CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error + TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) + FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) + SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relation2.GroupModel, error) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员 // GroupMember - TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) - TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) - FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) - PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relationTb.GroupMemberModel, error) - SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relationTb.GroupMemberModel, error) - HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error + TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) + TakeGroupOwner(ctx context.Context, groupID string) (*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) (uint32, []*relation2.GroupMemberModel, error) + SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*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 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 []*relationTb.GroupRequestModel) error - TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) - PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relationTb.GroupRequestModel, error) + CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error + TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) + PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relation2.GroupRequestModel, error) // SuperGroup - TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unRelationTb.SuperGroupModel, err error) - FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) + FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelation2.SuperGroupModel, error) + FindJoinSuperGroup(ctx context.Context, userID string) (superGroup *unrelation2.UserToSuperGroupModel, 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 CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error - MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) } var _ GroupInterface = (*GroupController)(nil) +func NewGroupInterface(database GroupDataBaseInterface) GroupInterface { + return &GroupController{database: database} +} + type GroupController struct { database GroupDataBaseInterface } -func (g *GroupController) CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error { +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 *relationTb.GroupModel, err error) { +func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) { return g.TakeGroup(ctx, groupID) } -func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) { +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, []*relationTb.GroupModel, error) { +func (g *GroupController) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relation2.GroupModel, error) { return g.database.SearchGroup(ctx, keyword, pageNumber, showNumber) } @@ -82,27 +85,27 @@ func (g *GroupController) DismissGroup(ctx context.Context, groupID string) erro return g.database.DismissGroup(ctx, groupID) } -func (g *GroupController) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) { +func (g *GroupController) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) { return g.database.TakeGroupMember(ctx, groupID, userID) } -func (g *GroupController) TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) { +func (g *GroupController) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) { return g.database.TakeGroupOwner(ctx, groupID) } -func (g *GroupController) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) { +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) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relationTb.GroupMemberModel, error) { +func (g *GroupController) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*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, []*relationTb.GroupMemberModel, error) { +func (g *GroupController) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*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 *relationTb.GroupMemberModel) error { +func (g *GroupController) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error { return g.database.HandlerGroupRequest(ctx, groupID, userID, handledMsg, handleResult, member) } @@ -126,24 +129,27 @@ func (g *GroupController) UpdateGroupMember(ctx context.Context, groupID, userID return g.database.UpdateGroupMember(ctx, groupID, userID, data) } -func (g *GroupController) CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error { +func (g *GroupController) CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error { return g.database.CreateGroupRequest(ctx, requests) } -func (g *GroupController) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) { +func (g *GroupController) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) { return g.database.TakeGroupRequest(ctx, groupID, userID) } -func (g *GroupController) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relationTb.GroupRequestModel, error) { +func (g *GroupController) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relation2.GroupRequestModel, error) { return g.database.PageGroupRequestUser(ctx, userID, pageNumber, showNumber) } -func (g *GroupController) TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unRelationTb.SuperGroupModel, err error) { - return g.database.TakeSuperGroup(ctx, groupID) +// func (g *GroupController) TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error) { +// return g.database.TakeSuperGroup(ctx, groupID) +// } +func (g *GroupController) FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelation2.SuperGroupModel, error) { + return g.database.FindSuperGroup(ctx, groupIDs) } -func (g *GroupController) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) { - return g.database.FindJoinSuperGroup(ctx, userID, pageNumber, showNumber) +func (g *GroupController) FindJoinSuperGroup(ctx context.Context, userID string) (*unrelation2.UserToSuperGroupModel, error) { + return g.database.FindJoinSuperGroup(ctx, userID) } func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error { @@ -162,44 +168,39 @@ func (g *GroupController) CreateSuperGroupMember(ctx context.Context, groupID st return g.database.CreateSuperGroupMember(ctx, groupID, userIDs) } -func (g *GroupController) MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) { - return g.database.MapSuperGroupMemberNum(ctx, groupIDs) -} - type GroupDataBaseInterface interface { - CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error - TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) - FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) - SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (int32, []*relationTb.GroupModel, error) + CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error + TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) + FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) + SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relation2.GroupModel, error) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员 // GroupMember - TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) - TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) - FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) - PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relationTb.GroupMemberModel, error) - SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relationTb.GroupMemberModel, error) - HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error + TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) + TakeGroupOwner(ctx context.Context, groupID string) (*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) (uint32, []*relation2.GroupMemberModel, error) + SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*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 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 []*relationTb.GroupRequestModel) error - TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) - PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relationTb.GroupRequestModel, error) + CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error + TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) + PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relation2.GroupRequestModel, error) // SuperGroup - TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unRelationTb.SuperGroupModel, err error) - FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) + FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelation2.SuperGroupModel, error) + FindJoinSuperGroup(ctx context.Context, userID string) (*unrelation2.UserToSuperGroupModel, 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 CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error - MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) } -func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupDataBaseInterface { +func NewGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupDataBaseInterface { groupDB := relation.NewGroupDB(db) groupMemberDB := relation.NewGroupMemberDB(db) groupRequestDB := relation.NewGroupRequest(db) @@ -224,16 +225,16 @@ func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.C var _ GroupDataBaseInterface = (*GroupDataBase)(nil) type GroupDataBase struct { - groupDB *relation.GroupGorm - groupMemberDB *relation.GroupMemberGorm - groupRequestDB *relation.GroupRequestGorm + groupDB relation2.GroupModelInterface + groupMemberDB relation2.GroupMemberModelInterface + groupRequestDB relation2.GroupRequestModelInterface db *gorm.DB cache *cache.GroupCache mongoDB *unrelation.SuperGroupMongoDriver } -func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error { +func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error { if len(groups) > 0 && len(groupMembers) > 0 { return g.db.Transaction(func(tx *gorm.DB) error { if err := g.groupDB.Create(ctx, groups, tx); err != nil { @@ -251,15 +252,15 @@ func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relationTb.Gr return nil } -func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) { +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 []*relationTb.GroupModel, err error) { +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, []*relationTb.GroupModel, error) { +func (g *GroupDataBase) SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relation2.GroupModel, error) { return g.groupDB.Search(ctx, keyword, pageNumber, showNumber) } @@ -276,27 +277,27 @@ func (g *GroupDataBase) DismissGroup(ctx context.Context, groupID string) error }) } -func (g *GroupDataBase) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error) { +func (g *GroupDataBase) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) { return g.groupMemberDB.Take(ctx, groupID, userID) } -func (g *GroupDataBase) TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error) { +func (g *GroupDataBase) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) { return g.groupMemberDB.TakeOwner(ctx, groupID) } -func (g *GroupDataBase) FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error) { +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) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (int32, []*relationTb.GroupMemberModel, error) { +func (g *GroupDataBase) PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*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, []*relationTb.GroupMemberModel, error) { +func (g *GroupDataBase) SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*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 *relationTb.GroupMemberModel) error { +func (g *GroupDataBase) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error { if member == nil { return g.groupRequestDB.UpdateHandler(ctx, groupID, userID, handledMsg, handleResult) } @@ -304,7 +305,7 @@ func (g *GroupDataBase) HandlerGroupRequest(ctx context.Context, groupID string, if err := g.groupRequestDB.UpdateHandler(ctx, groupID, userID, handledMsg, handleResult, tx); err != nil { return err } - return g.groupMemberDB.Create(ctx, []*relationTb.GroupMemberModel{member}, tx) + return g.groupMemberDB.Create(ctx, []*relation2.GroupMemberModel{member}, tx) }) } @@ -344,47 +345,46 @@ func (g *GroupDataBase) UpdateGroupMember(ctx context.Context, groupID, userID s return g.groupMemberDB.Update(ctx, groupID, userID, data) } -func (g *GroupDataBase) CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error { +func (g *GroupDataBase) CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error { return g.groupRequestDB.Create(ctx, requests) } -func (g *GroupDataBase) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error) { +func (g *GroupDataBase) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) { return g.groupRequestDB.Take(ctx, groupID, userID) } -func (g *GroupDataBase) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relationTb.GroupRequestModel, error) { +func (g *GroupDataBase) PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relation2.GroupRequestModel, error) { return g.groupRequestDB.Page(ctx, userID, pageNumber, showNumber) } -func (g *GroupDataBase) TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unRelationTb.SuperGroupModel, err error) { - return g.mongoDB.GetSuperGroup(ctx, groupID) +func (g *GroupDataBase) FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelation2.SuperGroupModel, error) { + return g.mongoDB.FindSuperGroup(ctx, groupIDs) } -func (g *GroupDataBase) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) { - return g.mongoDB.GetJoinGroup(ctx, userID, pageNumber, showNumber) +func (g *GroupDataBase) FindJoinSuperGroup(ctx context.Context, userID string) (*unrelation2.UserToSuperGroupModel, error) { + return g.mongoDB.GetSuperGroupByUserID(ctx, userID) } func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error { - return unrelation.MongoTransaction(ctx, g.mongoDB.MgoClient, func(sctx mongo.SessionContext) error { - if err := g.mongoDB.CreateSuperGroup(ctx, groupID, initMemberIDList, sctx); err != nil { - return err - } - return g.cache.BatchDelJoinedSuperGroupIDs(ctx, initMemberIDList) + return g.mongoDB.Transaction(ctx, func(s unrelation2.SuperGroupModelInterface, tx any) error { + return s.CreateSuperGroup(ctx, groupID, initMemberIDList, tx) }) } func (g *GroupDataBase) DeleteSuperGroup(ctx context.Context, groupID string) error { - return g.mongoDB.DeleteSuperGroup(ctx, groupID) + return g.mongoDB.Transaction(ctx, func(s unrelation2.SuperGroupModelInterface, tx any) error { + return s.DeleteSuperGroup(ctx, groupID, tx) + }) } func (g *GroupDataBase) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error { - return g.mongoDB.RemoverUserFromSuperGroup(ctx, groupID, userIDs) + return g.mongoDB.Transaction(ctx, func(s unrelation2.SuperGroupModelInterface, tx any) error { + return s.RemoverUserFromSuperGroup(ctx, groupID, userIDs, tx) + }) } 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) { - return g.mongoDB.MapGroupMemberCount(ctx, groupIDs) + return g.mongoDB.Transaction(ctx, func(s unrelation2.SuperGroupModelInterface, tx any) error { + return s.AddUserToSuperGroup(ctx, groupID, userIDs, tx) + }) } diff --git a/pkg/common/db/relation/group_member_model.go b/pkg/common/db/relation/group_member_model.go index 0cd76f9ce..15745da1c 100644 --- a/pkg/common/db/relation/group_member_model.go +++ b/pkg/common/db/relation/group_member_model.go @@ -1,234 +1,151 @@ package relation -//type GroupMember struct { -// GroupID string `gorm:"column:group_id;primaryKey;"` -// UserID string `gorm:"column:user_id;primaryKey;"` -// NickName string `gorm:"column:nickname"` -// FaceUrl string `gorm:"user_group_face_url"` -// RoleLevel int32 `gorm:"column:role_level"` -// JoinTime time.Time `gorm:"column:join_time"` -// JoinSource int32 `gorm:"column:join_source"` -// OperatorUserID string `gorm:"column:operator_user_id"` -// Ex string `gorm:"column:ex"` +import ( + "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/db/table/relation" + "Open_IM/pkg/common/tracelog" + "Open_IM/pkg/utils" + "context" + "gorm.io/gorm" +) + +var _ relation.GroupMemberModelInterface = (*GroupMemberGorm)(nil) + +type GroupMemberGorm struct { + DB *gorm.DB +} + +func NewGroupMemberDB(db *gorm.DB) relation.GroupMemberModelInterface { + return &GroupMemberGorm{DB: db} +} + +func (g *GroupMemberGorm) Create(ctx context.Context, groupMemberList []*relation.GroupMemberModel, tx ...any) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMemberList", groupMemberList) + }() + return utils.Wrap(getDBConn(g.DB, tx).Create(&groupMemberList).Error, "") +} + +func (g *GroupMemberGorm) Delete(ctx context.Context, groupID string, userIDs []string, tx ...any) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userIDs", userIDs) + }() + return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id in (?)", groupID, userIDs).Delete(&relation.GroupMemberModel{}).Error, "") +} + +func (g *GroupMemberGorm) DeleteGroup(ctx context.Context, groupIDs []string, tx ...any) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs) + }() + return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.GroupMemberModel{}).Error, "") +} + +//func (g *GroupMemberGorm) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...any) (err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args) +// }() +// return utils.Wrap(getDBConn(g.DB, tx).Model(&relation.GroupMemberModel{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).Error, "") //} -//func InsertIntoGroupMember(toInsertInfo GroupMember) error { -// toInsertInfo.JoinTime = time.Now() -// if toInsertInfo.RoleLevel == 0 { -// toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers +func (g *GroupMemberGorm) Update(ctx context.Context, groupID string, userID string, data map[string]any, tx ...any) (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) UpdateRoleLevel(ctx context.Context, groupID string, userID string, roleLevel int32, tx ...any) (rowsAffected int64, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "roleLevel", roleLevel) + }() + 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 ...any) (groupList []*relation.GroupMemberModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "userIDs", userIDs, "groupList", groupList) + }() + db := getDBConn(g.DB, tx) + if len(groupIDs) > 0 { + db = db.Where("group_id in (?)", groupIDs) + } + if len(userIDs) > 0 { + db = db.Where("user_id in (?)", userIDs) + } + 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 ...any) (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(groupList) > 0 { +// db = db.Where("group_id in (?)", groupIDs) // } -// toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0) -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Create(toInsertInfo).Error -// if err != nil { -// return err +// if len(userIDs) > 0 { +// db = db.Where("user_id in (?)", userIDs) // } -// return nil +// if len(roleLevels) > 0 { +// db = db.Where("role_level in (?)", roleLevels) +// } +// return groupList, utils.Wrap(db.Find(&groupList).Error, "") //} -//func BatchInsertIntoGroupMember(toInsertInfoList []*GroupMember) error { -// for _, toInsertInfo := range toInsertInfoList { -// toInsertInfo.JoinTime = time.Now() -// if toInsertInfo.RoleLevel == 0 { -// toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers -// } -// toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0) -// } -// return DB.DB.MysqlDB.DefaultGormDB().Create(toInsertInfoList).Error -// -//} -// -//func FindGroupMember(userID string) ([]GroupMember, error) { -// var groupMemberList []GroupMember -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error -// if err != nil { -// return nil, err -// } -// return groupMemberList, nil -//} -// -//func GetGroupMemberListByGroupID(groupID string) ([]GroupMember, error) { -// var groupMemberList []GroupMember -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Find(&groupMemberList).Error -// if err != nil { -// return nil, err -// } -// return groupMemberList, nil -//} -// -//func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) { -// var groupMemberIDList []string -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Pluck("user_id", &groupMemberIDList).Error -// if err != nil { -// return nil, err -// } -// return groupMemberIDList, nil -//} -// -//func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]GroupMember, error) { -// var groupMemberList []GroupMember -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and role_level=?", groupID, roleLevel).Find(&groupMemberList).Error -// if err != nil { -// return nil, err -// } -// return groupMemberList, nil -//} -// -//func GetGroupMemberInfoByGroupIDAndUserID(groupID, userID string) (*GroupMember, error) { -// var groupMember GroupMember -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Limit(1).Take(&groupMember).Error -// if err != nil { -// return nil, err -// } -// return &groupMember, nil -//} -// -//func DeleteGroupMemberByGroupIDAndUserID(groupID, userID string) error { -// return DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Delete(GroupMember{}).Error -//} -// -//func DeleteGroupMemberByGroupID(groupID string) error { -// return DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? ", groupID).Delete(GroupMember{}).Error -//} -// -//func UpdateGroupMemberInfo(groupMemberInfo GroupMember) error { -// return DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(&groupMemberInfo).Error -//} -// -//func UpdateGroupMemberInfoByMap(groupMemberInfo GroupMember, m map[string]interface{}) error { -// return DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(m).Error -//} -// -//func GetOwnerManagerByGroupID(groupID string) ([]GroupMember, error) { -// var groupMemberList []GroupMember -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=? and role_level>?", groupID, constant.GroupOrdinaryUsers).Find(&groupMemberList).Error -// if err != nil { -// return nil, err -// } -// return groupMemberList, nil -//} -// -//func GetGroupMemberNumByGroupID(groupID string) (int64, error) { -// var number int64 -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Count(&number).Error -// if err != nil { -// return 0, utils.Wrap(err, "") -// } -// return number, nil -//} +func (g *GroupMemberGorm) Take(ctx context.Context, groupID string, userID string, tx ...any) (groupMember *relation.GroupMemberModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember) + }() + groupMember = &relation.GroupMemberModel{} + return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "") +} -//func GetGroupOwnerInfoByGroupID(groupID string) (*GroupMember, error) { -// omList, err := GetOwnerManagerByGroupID(groupID) -// if err != nil { -// return nil, err -// } -// for _, v := range omList { -// if v.RoleLevel == constant.GroupOwner { -// return &v, nil -// } -// } -// return nil, utils.Wrap(constant.ErrNoGroupOwner, "") -//} -// -//func IsExistGroupMember(groupID, userID string) bool { -// var number int64 -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id = ? and user_id = ?", groupID, userID).Count(&number).Error -// if err != nil { -// return false -// } -// if number != 1 { -// return false -// } -// return true -//} -// -//func GetGroupMemberByGroupID(groupID string, filter int32, begin int32, maxNumber int32) ([]GroupMember, error) { -// var memberList []GroupMember -// var err error -// if filter >= 0 { -// memberList, err = GetGroupMemberListByGroupIDAndRoleLevel(groupID, filter) //sorted by join time -// } else { -// memberList, err = GetGroupMemberListByGroupID(groupID) -// } -// -// if err != nil { -// return nil, err -// } -// if begin >= int32(len(memberList)) { -// return nil, nil -// } -// -// var end int32 -// if begin+int32(maxNumber) < int32(len(memberList)) { -// end = begin + maxNumber -// } else { -// end = int32(len(memberList)) -// } -// return memberList[begin:end], nil -//} -// -//func GetJoinedGroupIDListByUserID(userID string) ([]string, error) { -// memberList, err := FindGroupMember(userID) -// if err != nil { -// return nil, err -// } -// var groupIDList []string -// for _, v := range memberList { -// groupIDList = append(groupIDList, v.GroupID) -// } -// return groupIDList, nil -//} -// -//func IsGroupOwnerAdmin(groupID, UserID string) bool { -// groupMemberList, err := GetOwnerManagerByGroupID(groupID) -// if err != nil { -// return false -// } -// for _, v := range groupMemberList { -// if v.UserID == UserID && v.RoleLevel > constant.GroupOrdinaryUsers { -// return true -// } -// } -// return false -//} -// -//func GetGroupMembersByGroupIdCMS(groupId string, userName string, showNumber, pageNumber int32) ([]GroupMember, error) { -// var groupMembers []GroupMember -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupId).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&groupMembers).Error -// if err != nil { -// return nil, err -// } -// return groupMembers, nil -//} -// -//func GetGroupMembersCount(groupID, userName string) (int64, error) { -// var count int64 -// if err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("group_id=?", groupID).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Count(&count).Error; err != nil { -// return count, err -// } -// return count, nil -//} -// -//func UpdateGroupMemberInfoDefaultZero(groupMemberInfo GroupMember, args map[string]interface{}) error { -// return DB.DB.MysqlDB.DefaultGormDB().Model(groupMemberInfo).Updates(args).Error -//} +func (g *GroupMemberGorm) TakeOwner(ctx context.Context, groupID string, tx ...any) (groupMember *relation.GroupMemberModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember) + }() + groupMember = &relation.GroupMemberModel{} + return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "") +} -// -//func SelectGroupList(groupID string) ([]string, error) { -// var groupUserID string -// var groupList []string -// dbConn, err := DB.DB.MysqlDB.DefaultGormDB() -// if err != nil { -// return groupList, err -// } -// -// rows, err := dbConn.Model(&GroupMember{}).Where("group_id = ?", groupID).Select("user_id").Rows() -// if err != nil { -// return groupList, err -// } -// defer rows.Close() -// for rows.Next() { -// rows.Scan(&groupUserID) -// groupList = append(groupList, groupUserID) -// } -// return groupList, nil -//} +func (g *GroupMemberGorm) SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32, tx ...any) (total uint32, groupList []*relation.GroupMemberModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "groupIDs", groupIDs, "userIDs", userIDs, "roleLevels", roleLevels, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList) + }() + db := getDBConn(g.DB, tx) + gormIn(&db, "group_id", groupIDs) + gormIn(&db, "user_id", userIDs) + gormIn(&db, "role_level", roleLevels) + return gormSearch[relation.GroupMemberModel](db, []string{"nickname"}, keyword, pageNumber, showNumber) +} + +func (g *GroupMemberGorm) MapGroupMemberNum(ctx context.Context, groupIDs []string, tx ...any) (count map[string]uint32, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "count", count) + }() + return mapCount(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs), "group_id") +} + +func (g *GroupMemberGorm) FindJoinUserID(ctx context.Context, groupIDs []string, tx ...any) (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 +} diff --git a/pkg/common/db/relation/group_member_model_k.go b/pkg/common/db/relation/group_member_model_k.go deleted file mode 100644 index 3f9a6bc62..000000000 --- a/pkg/common/db/relation/group_member_model_k.go +++ /dev/null @@ -1,156 +0,0 @@ -package relation - -import ( - "Open_IM/pkg/common/constant" - "Open_IM/pkg/common/db/table/relation" - "Open_IM/pkg/common/tracelog" - "Open_IM/pkg/utils" - "context" - "gorm.io/gorm" -) - -type GroupMemberGorm struct { - DB *gorm.DB -} - -func NewGroupMemberDB(db *gorm.DB) *GroupMemberGorm { - return &GroupMemberGorm{DB: db} -} - -func (g *GroupMemberGorm) Create(ctx context.Context, groupMemberList []*relation.GroupMemberModel, tx ...*gorm.DB) (err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupMemberList", groupMemberList) - }() - return utils.Wrap(getDBConn(g.DB, tx).Create(&groupMemberList).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, "groupID", groupID, "userIDs", userIDs) - }() - 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) - }() - return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.GroupMemberModel{}).Error, "") -} - -func (g *GroupMemberGorm) UpdateByMap(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).Model(&relation.GroupMemberModel{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(args).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) 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, "groupID", groupID, "userID", userID, "roleLevel", roleLevel) - }() - db := getDBConn(g.DB, tx).Model(&relation.GroupMemberModel{}).Where("group_id = ? and user_id = ?", groupID, userID).Updates(map[string]any{ - "role_level": roleLevel, - }) - return db.RowsAffected, utils.Wrap(db.Error, "") -} - -func (g *GroupMemberGorm) Find(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, tx ...*gorm.DB) (groupList []*relation.GroupMemberModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "userIDs", userIDs, "groupList", groupList) - }() - db := getDBConn(g.DB, tx) - if len(groupIDs) > 0 { - db = db.Where("group_id in (?)", groupIDs) - } - if len(userIDs) > 0 { - db = db.Where("user_id in (?)", userIDs) - } - 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) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "userIDs", userIDs, "groupList", groupList) - }() - db := getDBConn(g.DB, tx) - if len(groupList) > 0 { - db = db.Where("group_id in (?)", groupIDs) - } - 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) Take(ctx context.Context, groupID string, userID string, tx ...*gorm.DB) (groupMember *relation.GroupMemberModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember) - }() - groupMember = &relation.GroupMemberModel{} - return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "") -} - -func (g *GroupMemberGorm) TakeOwner(ctx context.Context, groupID string, tx ...*gorm.DB) (groupMember *relation.GroupMemberModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember) - }() - groupMember = &relation.GroupMemberModel{} - return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "") -} - -func (g *GroupMemberGorm) SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groupList []*relation.GroupMemberModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "keyword", keyword, "groupIDs", groupIDs, "userIDs", userIDs, "roleLevels", roleLevels, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList) - }() - db := getDBConn(g.DB, tx) - gormIn(&db, "group_id", groupIDs) - gormIn(&db, "user_id", userIDs) - gormIn(&db, "role_level", roleLevels) - return gormSearch[relation.GroupMemberModel](db, []string{"nickname"}, keyword, pageNumber, showNumber) -} - -func (g *GroupMemberGorm) MapGroupMemberNum(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (count map[string]uint32, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "count", count) - }() - 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 -} diff --git a/pkg/common/db/relation/group_model.go b/pkg/common/db/relation/group_model.go index 3bc238cd9..bc97aba66 100644 --- a/pkg/common/db/relation/group_model.go +++ b/pkg/common/db/relation/group_model.go @@ -1,98 +1,69 @@ package relation import ( - "Open_IM/pkg/common/constant" + "Open_IM/pkg/common/db/table/relation" + "Open_IM/pkg/common/tracelog" "Open_IM/pkg/utils" - "fmt" - - "time" + "context" + "gorm.io/gorm" ) -func InsertIntoGroup(groupInfo Group) error { - if groupInfo.GroupName == "" { - groupInfo.GroupName = "Group Chat" - } - groupInfo.CreateTime = time.Now() +var _ relation.GroupModelInterface = (*GroupGorm)(nil) - if groupInfo.NotificationUpdateTime.Unix() < 0 { - groupInfo.NotificationUpdateTime = utils.UnixSecondToTime(0) - } - err := GroupDB.Create(groupInfo).Error - if err != nil { - return err - } - return nil +type GroupGorm struct { + DB *gorm.DB } -func TakeGroupInfoByGroupID(groupID string) (*Group, error) { - var groupInfo Group - err := GroupDB.Where("group_id=?", groupID).Take(&groupInfo).Error - return &groupInfo, err +func NewGroupDB(db *gorm.DB) relation.GroupModelInterface { + return &GroupGorm{DB: db} } -func GetGroupInfoByGroupID(groupID string) (*Group, error) { - var groupInfo Group - err := GroupDB.Where("group_id=?", groupID).Take(&groupInfo).Error - return &groupInfo, err +func (g *GroupGorm) Create(ctx context.Context, groups []*relation.GroupModel, tx ...any) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups) + }() + return utils.Wrap(getDBConn(g.DB, tx).Create(&groups).Error, "") } -func SetGroupInfo(groupInfo Group) error { - return GroupDB.Where("group_id=?", groupInfo.GroupID).Updates(&groupInfo).Error +//func (g *GroupGorm) Delete(ctx context.Context, groupIDs []string, tx ...any) (err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs) +// }() +// return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.GroupModel{}).Error, "") +//} + +func (g *GroupGorm) UpdateMap(ctx context.Context, groupID string, args map[string]interface{}, tx ...any) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "args", args) + }() + return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(&relation.GroupModel{}).Updates(args).Error, "") } -type GroupWithNum struct { - Group - MemberCount int `gorm:"column:num"` +func (g *GroupGorm) UpdateStatus(ctx context.Context, groupID string, status int32, tx ...any) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "status", status) + }() + return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(&relation.GroupModel{}).Updates(map[string]any{"status": status}).Error, "") } -func GetGroupsByName(groupName string, pageNumber, showNumber int32) ([]GroupWithNum, int64, error) { - var groups []GroupWithNum - var count int64 - sql := GroupDB.Select("groups.*, (select count(*) from group_members where group_members.group_id=groups.group_id) as num"). - Where(" name like ? and status != ?", fmt.Sprintf("%%%s%%", groupName), constant.GroupStatusDismissed) - if err := sql.Count(&count).Error; err != nil { - return nil, 0, err - } - err := sql.Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&groups).Error - return groups, count, err +func (g *GroupGorm) Find(ctx context.Context, groupIDs []string, tx ...any) (groups []*relation.GroupModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups) + }() + return groups, utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Find(&groups).Error, "") } -func GetGroups(pageNumber, showNumber int) ([]GroupWithNum, error) { - var groups []GroupWithNum - if err := GroupDB.Select("groups.*, (select count(*) from group_members where group_members.group_id=groups.group_id) as num"). - Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&groups).Error; err != nil { - return groups, err - } - return groups, nil +func (g *GroupGorm) Take(ctx context.Context, groupID string, tx ...any) (group *relation.GroupModel, err error) { + group = &relation.GroupModel{} + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", group) + }() + return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "") } -func OperateGroupStatus(groupId string, groupStatus int32) error { - group := Group{ - GroupID: groupId, - Status: groupStatus, - } - if err := SetGroupInfo(group); err != nil { - return err - } - return nil -} - -func GetGroupsCountNum(group Group) (int32, error) { - var count int64 - if err := GroupDB.Where(" name like ? ", fmt.Sprintf("%%%s%%", group.GroupName)).Count(&count).Error; err != nil { - return 0, err - } - return int32(count), nil -} - -func UpdateGroupInfoDefaultZero(groupID string, args map[string]interface{}) error { - return GroupDB.Where("group_id = ? ", groupID).Updates(args).Error -} - -func GetGroupIDListByGroupType(groupType int) ([]string, error) { - var groupIDList []string - if err := GroupDB.Where("group_type = ? ", groupType).Pluck("group_id", &groupIDList).Error; err != nil { - return nil, err - } - return groupIDList, nil +func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32, tx ...any) (total uint32, groups []*relation.GroupModel, err error) { + defer func() { + 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), []string{"name"}, keyword, pageNumber, showNumber) } diff --git a/pkg/common/db/relation/group_model_k.go b/pkg/common/db/relation/group_model_k.go deleted file mode 100644 index 731c83fdd..000000000 --- a/pkg/common/db/relation/group_model_k.go +++ /dev/null @@ -1,74 +0,0 @@ -package relation - -import ( - "Open_IM/pkg/common/db/table/relation" - "Open_IM/pkg/common/tracelog" - "Open_IM/pkg/utils" - "context" - "gorm.io/gorm" -) - -type GroupGorm struct { - DB *gorm.DB -} - -func NewGroupDB(db *gorm.DB) *GroupGorm { - return &GroupGorm{DB: db} -} - -func (g *GroupGorm) Create(ctx context.Context, groups []*relation.GroupModel, tx ...*gorm.DB) (err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups) - }() - return utils.Wrap(getDBConn(g.DB, tx).Create(&groups).Error, "") -} - -func (g *GroupGorm) Delete(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs) - }() - return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.GroupModel{}).Error, "") -} - -func (g *GroupGorm) UpdateMap(ctx context.Context, groupID string, args map[string]interface{}, tx ...*gorm.DB) (err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "args", args) - }() - return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(&relation.GroupModel{}).Updates(args).Error, "") -} - -func (g *GroupGorm) UpdateStatus(ctx context.Context, groupID string, status int32, tx ...*gorm.DB) (err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "status", status) - }() - return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(&relation.GroupModel{}).Updates(map[string]any{"status": status}).Error, "") -} - -//func (g *GroupGorm) Update(ctx context.Context, groups []*relation.GroupModel, tx ...*gorm.DB) (err error) { -// defer func() { -// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups) -// }() -// return utils.Wrap(getDBConn(g.DB, tx).Updates(&groups).Error, "") -//} - -func (g *GroupGorm) Find(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (groups []*relation.GroupModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups) - }() - return groups, utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Find(&groups).Error, "") -} - -func (g *GroupGorm) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (group *relation.GroupModel, err error) { - group = &relation.GroupModel{} - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", group) - }() - return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).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, "keyword", keyword, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups) - }() - return gormSearch[relation.GroupModel](getDBConn(g.DB, tx), []string{"name"}, keyword, pageNumber, showNumber) -} diff --git a/pkg/common/db/relation/group_request_model.go b/pkg/common/db/relation/group_request_model.go index 46b4a7543..a0c4b01fb 100644 --- a/pkg/common/db/relation/group_request_model.go +++ b/pkg/common/db/relation/group_request_model.go @@ -1,158 +1,85 @@ package relation -// -//func UpdateGroupRequest(groupRequest GroupRequest) error { -// if groupRequest.HandledTime.Unix() < 0 { -// groupRequest.HandledTime = utils.UnixSecondToTime(0) -// } -// return DB.DB.MysqlDB.DefaultGormDB().Table("group_requests").Where("group_id=? and user_id=?", groupRequest.GroupID, groupRequest.UserID).Updates(&groupRequest).Error +import ( + "Open_IM/pkg/common/db/table/relation" + "Open_IM/pkg/common/tracelog" + "Open_IM/pkg/utils" + "context" + "gorm.io/gorm" +) + +var _ relation.GroupRequestModelInterface = (*GroupRequestGorm)(nil) + +type GroupRequestGorm struct { + DB *gorm.DB +} + +func NewGroupRequest(db *gorm.DB) relation.GroupRequestModelInterface { + return &GroupRequestGorm{ + DB: db, + } +} + +func (g *GroupRequestGorm) Create(ctx context.Context, groupRequests []*relation.GroupRequestModel, tx ...any) (err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests) + }() + return utils.Wrap(getDBConn(g.DB, tx).Create(&groupRequests).Error, utils.GetSelfFuncName()) +} + +//func (g *GroupRequestGorm) Delete(ctx context.Context, groupRequests []*relation.GroupRequestModel, tx ...any) (err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests) +// }() +// return utils.Wrap(getDBConn(g.DB, tx).Delete(&groupRequests).Error, utils.GetSelfFuncName()) //} -// -//func InsertIntoGroupRequest(toInsertInfo GroupRequest) error { -// DelGroupRequestByGroupIDAndUserID(toInsertInfo.GroupID, toInsertInfo.UserID) -// if toInsertInfo.HandledTime.Unix() < 0 { -// toInsertInfo.HandledTime = utils.UnixSecondToTime(0) -// } -// u := DB.DB.MysqlDB.DefaultGormDB().Table("group_requests").Where("group_id=? and user_id=?", toInsertInfo.GroupID, toInsertInfo.UserID).Updates(&toInsertInfo) -// if u.RowsAffected != 0 { -// return nil -// } -// -// toInsertInfo.ReqTime = time.Now() -// if toInsertInfo.HandledTime.Unix() < 0 { -// toInsertInfo.HandledTime = utils.UnixSecondToTime(0) -// } -// -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_requests").Create(&toInsertInfo).Error -// if err != nil { -// return err -// } -// return nil + +//func (g *GroupRequestGorm) UpdateMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...any) (err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args) +// }() +// return utils.Wrap(getDBConn(g.DB, tx).Model(&relation.GroupRequestModel{}).Where("group_id = ? and user_id = ? ", groupID, userID).Updates(args).Error, utils.GetSelfFuncName()) //} -// -//func GetGroupRequestByGroupIDAndUserID(groupID, userID string) (*GroupRequest, error) { -// var groupRequest GroupRequest -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_requests").Where("user_id=? and group_id=?", userID, groupID).Take(&groupRequest).Error -// if err != nil { -// return nil, err -// } -// return &groupRequest, nil + +func (g *GroupRequestGorm) UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, tx ...any) (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 ...any) (err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests) +// }() +// return utils.Wrap(getDBConn(g.DB, tx).Updates(&groupRequests).Error, utils.GetSelfFuncName()) //} -// -//func DelGroupRequestByGroupIDAndUserID(groupID, userID string) error { -// return DB.DB.MysqlDB.DefaultGormDB().Table("group_requests").Where("group_id=? and user_id=?", groupID, userID).Delete(GroupRequest{}).Error -//} -// -//func GetGroupRequestByGroupID(groupID string) ([]GroupRequest, error) { -// var groupRequestList []GroupRequest -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_requests").Where("group_id=?", groupID).Find(&groupRequestList).Error -// if err != nil { -// return nil, err -// } -// return groupRequestList, nil -//} -// -//received -//func GetRecvGroupApplicationList(userID string) ([]GroupRequest, error) { -// var groupRequestList []GroupRequest -// memberList, err := FindGroupMember(userID) -// if err != nil { -// return nil, utils.Wrap(err, utils.GetSelfFuncName()) -// } -// for _, v := range memberList { -// if v.RoleLevel > constant.GroupOrdinaryUsers { -// list, err := GetGroupRequestByGroupID(v.GroupID) -// if err != nil { -// continue -// } -// groupRequestList = append(groupRequestList, list...) -// } -// } -// return groupRequestList, nil -//} -// -//func GetUserReqGroupByUserID(userID string) ([]GroupRequest, error) { -// var groupRequestList []GroupRequest -// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_requests").Where("user_id=?", userID).Find(&groupRequestList).Error -// return groupRequestList, err -//} -// -// -//func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.CommonResp, error) { -// -// ownerUser, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OwnerID) -// if err != nil { -// log.ErrorByKv("FindGroupMemberInfoByGroupIdAndUserId failed", pb.OperationID, "groupId", pb.GroupID, "ownerID", pb.OwnerID) -// return nil, err -// } -// if ownerUser.AdministratorLevel <= 0 { -// return nil, errors.New("insufficient permissions") -// } -// -// dbConn, err := DB.DB.MysqlDB.DefaultGormDB() -// if err != nil { -// return nil, err -// } -// var groupRequest GroupRequest -// err = dbConn.Raw("select * from `group_request` where handled_user = ? and group_id = ? and from_user_id = ? and to_user_id = ?", -// "", pb.GroupID, pb.FromUserID, pb.ToUserID).Scan(&groupRequest).Error -// if err != nil { -// log.ErrorByKv("find group_request info failed", pb.OperationID, "groupId", pb.GroupID, "fromUserId", pb.FromUserID, "toUserId", pb.OwnerID) -// return nil, err -// } -// -// if groupRequest.Flag != 0 { -// return nil, errors.New("application has already handle") -// } -// -// var saveFlag int -// if pb.HandleResult == 0 { -// saveFlag = -1 -// } else if pb.HandleResult == 1 { -// saveFlag = 1 -// } else { -// return nil, errors.New("parma HandleResult error") -// } -// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and from_user_id = ? and to_user_id = ?", -// saveFlag, pb.HandledMsg, pb.OwnerID, groupRequest.GroupID, groupRequest.FromUserID, groupRequest.ToUserID).Error -// if err != nil { -// log.ErrorByKv("update group request failed", pb.OperationID, "groupID", pb.GroupID, "flag", saveFlag, "ownerId", pb.OwnerID, "fromUserId", pb.FromUserID, "toUserID", pb.ToUserID) -// return nil, err -// } -// -// if saveFlag == 1 { -// if groupRequest.ToUserID == "0" { -// err = InsertIntoGroupMember(pb.GroupID, pb.FromUserID, groupRequest.FromUserNickname, groupRequest.FromUserFaceUrl, 0) -// if err != nil { -// log.ErrorByKv("InsertIntoGroupMember failed", pb.OperationID, "groupID", pb.GroupID, "fromUserId", pb.FromUserID) -// return nil, err -// } -// } else { -// err = InsertIntoGroupMember(pb.GroupID, pb.ToUserID, groupRequest.ToUserNickname, groupRequest.ToUserFaceUrl, 0) -// if err != nil { -// log.ErrorByKv("InsertIntoGroupMember failed", pb.OperationID, "groupID", pb.GroupID, "fromUserId", pb.FromUserID) -// return nil, err -// } -// } -// } -// -// return &group.GroupApplicationResponseResp{}, nil -//} -// -//func FindGroupBeInvitedRequestInfoByUidAndGroupID(groupId, uid string) (*GroupRequest, error) { -// dbConn, err := DB.DB.MysqlDB.DefaultGormDB() -// if err != nil { -// return nil, err -// } -// var beInvitedRequestUserInfo GroupRequest -// err = dbConn.Table("group_request").Where("to_user_id=? and group_id=?", uid, groupId).Find(&beInvitedRequestUserInfo).Error -// if err != nil { -// return nil, err -// } -// return &beInvitedRequestUserInfo, nil -// -//} -// -//func InsertGroupRequest(groupId, fromUser, fromUserNickName, fromUserFaceUrl, toUser, requestMsg, handledMsg string, handleStatus int) error { -// return nil + +//func (g *GroupRequestGorm) Find(ctx context.Context, groupRequests []*relation.GroupRequestModel, tx ...any) (resultGroupRequests []*relation.GroupRequestModel, err error) { +// defer func() { +// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests, "resultGroupRequests", resultGroupRequests) +// }() +// var where [][]interface{} +// for _, groupMember := range groupRequests { +// where = append(where, []interface{}{groupMember.GroupID, groupMember.UserID}) +// } +// return resultGroupRequests, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&resultGroupRequests).Error, utils.GetSelfFuncName()) //} + +func (g *GroupRequestGorm) Take(ctx context.Context, groupID string, userID string, tx ...any) (groupRequest *relation.GroupRequestModel, err error) { + groupRequest = &relation.GroupRequestModel{} + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupRequest", *groupRequest) + }() + 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 ...any) (total uint32, groups []*relation.GroupRequestModel, err error) { + defer func() { + tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups) + }() + return gormSearch[relation.GroupRequestModel](getDBConn(g.DB, tx).Where("user_id = ?", userID), nil, "", pageNumber, showNumber) +} diff --git a/pkg/common/db/relation/group_request_model_k.go b/pkg/common/db/relation/group_request_model_k.go deleted file mode 100644 index 46c0f335e..000000000 --- a/pkg/common/db/relation/group_request_model_k.go +++ /dev/null @@ -1,83 +0,0 @@ -package relation - -import ( - "Open_IM/pkg/common/db/table/relation" - "Open_IM/pkg/common/tracelog" - "Open_IM/pkg/utils" - "context" - "gorm.io/gorm" -) - -type GroupRequestGorm struct { - DB *gorm.DB -} - -func NewGroupRequest(db *gorm.DB) *GroupRequestGorm { - return &GroupRequestGorm{ - DB: db, - } -} - -func (g *GroupRequestGorm) Create(ctx context.Context, groupRequests []*relation.GroupRequestModel, tx ...*gorm.DB) (err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests) - }() - return utils.Wrap(getDBConn(g.DB, tx).Create(&groupRequests).Error, utils.GetSelfFuncName()) -} - -func (g *GroupRequestGorm) Delete(ctx context.Context, groupRequests []*relation.GroupRequestModel, tx ...*gorm.DB) (err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests) - }() - return utils.Wrap(getDBConn(g.DB, tx).Delete(&groupRequests).Error, utils.GetSelfFuncName()) -} - -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).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) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests) - }() - return utils.Wrap(getDBConn(g.DB, tx).Updates(&groupRequests).Error, utils.GetSelfFuncName()) -} - -func (g *GroupRequestGorm) Find(ctx context.Context, groupRequests []*relation.GroupRequestModel, tx ...*gorm.DB) (resultGroupRequests []*relation.GroupRequestModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupRequests", groupRequests, "resultGroupRequests", resultGroupRequests) - }() - var where [][]interface{} - for _, groupMember := range groupRequests { - where = append(where, []interface{}{groupMember.GroupID, groupMember.UserID}) - } - return resultGroupRequests, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&resultGroupRequests).Error, utils.GetSelfFuncName()) -} - -func (g *GroupRequestGorm) Take(ctx context.Context, groupID string, userID string, tx ...*gorm.DB) (groupRequest *relation.GroupRequestModel, err error) { - groupRequest = &relation.GroupRequestModel{} - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupRequest", *groupRequest) - }() - return groupRequest, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ? ", groupID, userID).Take(groupRequest).Error, utils.GetSelfFuncName()) -} - -func (g *GroupRequestGorm) Page(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groups []*relation.GroupRequestModel, err error) { - defer func() { - tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups) - }() - return gormSearch[relation.GroupRequestModel](getDBConn(g.DB, tx).Where("user_id = ?", userID), nil, "", pageNumber, showNumber) -} diff --git a/pkg/common/db/relation/init_mysql.go b/pkg/common/db/relation/init_mysql.go index 1bc637760..6d6ec61ee 100644 --- a/pkg/common/db/relation/init_mysql.go +++ b/pkg/common/db/relation/init_mysql.go @@ -87,9 +87,11 @@ func (w Writer) Printf(format string, args ...interface{}) { fmt.Printf(format, args...) } -func getDBConn(db *gorm.DB, tx []*gorm.DB) *gorm.DB { +func getDBConn(db *gorm.DB, tx []any) *gorm.DB { if len(tx) > 0 { - return tx[0] + if txDb, ok := tx[0].(*gorm.DB); ok { + return txDb + } } return db } diff --git a/pkg/common/db/relation/utils.go b/pkg/common/db/relation/utils.go index 83e5e7bd2..8e3c62bfc 100644 --- a/pkg/common/db/relation/utils.go +++ b/pkg/common/db/relation/utils.go @@ -5,7 +5,7 @@ import ( "gorm.io/gorm" ) -func gormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (int32, []*E, error) { +func gormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (uint32, []*E, error) { var count int64 if err := db.Model(new(E)).Count(&count).Error; err != nil { return 0, nil, utils.Wrap(err, "") @@ -14,10 +14,10 @@ func gormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (int32, []*E, er if err := db.Limit(int(showNumber)).Offset(int(pageNumber * showNumber)).Find(&es).Error; err != nil { return 0, nil, utils.Wrap(err, "") } - return int32(count), es, nil + return uint32(count), es, nil } -func gormSearch[E any](db *gorm.DB, fields []string, value string, pageNumber, showNumber int32) (int32, []*E, error) { +func gormSearch[E any](db *gorm.DB, fields []string, value string, pageNumber, showNumber int32) (uint32, []*E, error) { if len(fields) > 0 && value != "" { value = "%" + value + "%" if len(fields) == 1 { diff --git a/pkg/common/db/table/relation/group.go b/pkg/common/db/table/relation/group.go index 1306eded4..b95e814da 100644 --- a/pkg/common/db/table/relation/group.go +++ b/pkg/common/db/table/relation/group.go @@ -1,6 +1,9 @@ package relation -import "time" +import ( + "context" + "time" +) const ( GroupModelTableName = "groups" @@ -29,4 +32,11 @@ func (GroupModel) TableName() string { } type GroupModelInterface interface { + Create(ctx context.Context, groups []*GroupModel, tx ...any) (err error) + //Delete(ctx context.Context, groupIDs []string, tx ...any) (err error) + UpdateMap(ctx context.Context, groupID string, args map[string]interface{}, tx ...any) (err error) + UpdateStatus(ctx context.Context, groupID string, status int32, tx ...any) (err error) + Find(ctx context.Context, groupIDs []string, tx ...any) (groups []*GroupModel, err error) + Take(ctx context.Context, groupID string, tx ...any) (group *GroupModel, err error) + Search(ctx context.Context, keyword string, pageNumber, showNumber int32, tx ...any) (total uint32, groups []*GroupModel, err error) } diff --git a/pkg/common/db/table/relation/group_member.go b/pkg/common/db/table/relation/group_member.go index 5d22690c2..a83dd76c5 100644 --- a/pkg/common/db/table/relation/group_member.go +++ b/pkg/common/db/table/relation/group_member.go @@ -1,6 +1,9 @@ package relation -import "time" +import ( + "context" + "time" +) const ( GroupMemberModelTableName = "group_members" @@ -25,4 +28,17 @@ func (GroupMemberModel) TableName() string { } type GroupMemberModelInterface interface { + Create(ctx context.Context, groupMemberList []*GroupMemberModel, tx ...any) (err error) + Delete(ctx context.Context, groupID string, userIDs []string, tx ...any) (err error) + DeleteGroup(ctx context.Context, groupIDs []string, tx ...any) (err error) + //UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...any) (err error) + Update(ctx context.Context, groupID string, userID string, data map[string]any, tx ...any) (err error) + UpdateRoleLevel(ctx context.Context, groupID string, userID string, roleLevel int32, tx ...any) (rowsAffected int64, err error) + Find(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, tx ...any) (groupList []*GroupMemberModel, err error) + //FindGroupUser(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, tx ...any) (groupList []*GroupMemberModel, err error) + Take(ctx context.Context, groupID string, userID string, tx ...any) (groupMember *GroupMemberModel, err error) + TakeOwner(ctx context.Context, groupID string, tx ...any) (groupMember *GroupMemberModel, err error) + SearchMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32, tx ...any) (total uint32, groupList []*GroupMemberModel, err error) + MapGroupMemberNum(ctx context.Context, groupIDs []string, tx ...any) (count map[string]uint32, err error) + FindJoinUserID(ctx context.Context, groupIDs []string, tx ...any) (groupUsers map[string][]string, err error) } diff --git a/pkg/common/db/table/relation/group_request.go b/pkg/common/db/table/relation/group_request.go index e2de48f34..1c9d112c4 100644 --- a/pkg/common/db/table/relation/group_request.go +++ b/pkg/common/db/table/relation/group_request.go @@ -1,6 +1,9 @@ package relation -import "time" +import ( + "context" + "time" +) const ( GroupRequestModelTableName = "group_requests" @@ -25,4 +28,12 @@ func (GroupRequestModel) TableName() string { } type GroupRequestModelInterface interface { + Create(ctx context.Context, groupRequests []*GroupRequestModel, tx ...any) (err error) + //Delete(ctx context.Context, groupRequests []*GroupRequestModel, tx ...any) (err error) + //UpdateMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...any) (err error) + UpdateHandler(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, tx ...any) (err error) + //Update(ctx context.Context, groupRequests []*GroupRequestModel, tx ...any) (err error) + //Find(ctx context.Context, groupRequests []*GroupRequestModel, tx ...any) (resultGroupRequests []*GroupRequestModel, err error) + Take(ctx context.Context, groupID string, userID string, tx ...any) (groupRequest *GroupRequestModel, err error) + Page(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...any) (total uint32, groups []*GroupRequestModel, err error) } diff --git a/pkg/common/db/table/unrelation/super_group.go b/pkg/common/db/table/unrelation/super_group.go index 3b03e62cf..0493afc4e 100644 --- a/pkg/common/db/table/unrelation/super_group.go +++ b/pkg/common/db/table/unrelation/super_group.go @@ -28,11 +28,22 @@ func (UserToSuperGroupModel) TableName() string { } type SuperGroupModelInterface interface { - // tx is your transaction object - CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string, tx ...interface{}) error - GetSuperGroup(ctx context.Context, groupID string) (SuperGroupModel, error) - AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...interface{}) error - RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...interface{}) error - GetSuperGroupByUserID(ctx context.Context, userID string) (*UserToSuperGroupModel, error) - DeleteSuperGroup(ctx context.Context, groupID string, tx ...interface{}) error + CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string, tx ...any) error + FindSuperGroup(ctx context.Context, groupIDs []string, tx ...any) (groups []*SuperGroupModel, err error) + AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...any) error + RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...any) error + GetSuperGroupByUserID(ctx context.Context, userID string, tx ...any) (*UserToSuperGroupModel, error) + DeleteSuperGroup(ctx context.Context, groupID string, tx ...any) error + RemoveGroupFromUser(ctx context.Context, groupID string, userIDs []string, tx ...any) error } + +//type SuperGroupModelInterface interface { +// // tx is your transaction object +// CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string, tx ...interface{}) error +// FindSuperGroup(ctx context.Context, groupIDs []string, tx ...interface{}) ([]*SuperGroupModel, error) +// //GetSuperGroup(ctx context.Context, groupID string) (SuperGroupModel, error) +// AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...interface{}) error +// RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...interface{}) error +// GetSuperGroupByUserID(ctx context.Context, userID string, tx ...interface{}) (*UserToSuperGroupModel, error) +// DeleteSuperGroup(ctx context.Context, groupID string, tx ...interface{}) error +//} diff --git a/pkg/common/db/unrelation/super_group.go b/pkg/common/db/unrelation/super_group.go index e3a57d624..5943990a2 100644 --- a/pkg/common/db/unrelation/super_group.go +++ b/pkg/common/db/unrelation/super_group.go @@ -11,6 +11,13 @@ import ( "go.mongodb.org/mongo-driver/mongo/readconcern" ) +var _ unrelation.SuperGroupModelInterface = (*SuperGroupMongoDriver)(nil) + +func NewSuperGroupMongoDriver(mgoClient *mongo.Client) *SuperGroupMongoDriver { + mgoDB := mgoClient.Database(config.Config.Mongo.DBDatabase) + return &SuperGroupMongoDriver{MgoDB: mgoDB, MgoClient: mgoClient, superGroupCollection: mgoDB.Collection(unrelation.CSuperGroup), userToSuperGroupCollection: mgoDB.Collection(unrelation.CUserToSuperGroup)} +} + type SuperGroupMongoDriver struct { MgoClient *mongo.Client MgoDB *mongo.Database @@ -18,44 +25,178 @@ type SuperGroupMongoDriver struct { userToSuperGroupCollection *mongo.Collection } -func NewSuperGroupMongoDriver(mgoClient *mongo.Client) *SuperGroupMongoDriver { - mgoDB := mgoClient.Database(config.Config.Mongo.DBDatabase) - return &SuperGroupMongoDriver{MgoDB: mgoDB, MgoClient: mgoClient, superGroupCollection: mgoDB.Collection(unrelation.CSuperGroup), userToSuperGroupCollection: mgoDB.Collection(unrelation.CUserToSuperGroup)} -} +// func (s *SuperGroupMongoDriver) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string, tx ...interface{}) error { +// superGroup := unrelation.SuperGroupModel{ +// GroupID: groupID, +// MemberIDs: initMemberIDs, +// } +// coll := getTxCtx(s.superGroupCollection, tx) +// _, err := coll.InsertOne(ctx, superGroup) +// if err != nil { +// return err +// } +// opts := &options.UpdateOptions{ +// Upsert: utils.ToPtr(true), +// } +// for _, userID := range initMemberIDs { +// _, err = coll.UpdateOne(ctx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts) +// if err != nil { +// return err +// } +// } +// return nil +// } +// +// func (s *SuperGroupMongoDriver) FindSuperGroup(ctx context.Context, groupIDs []string, tx ...interface{}) (groups []*unrelation.SuperGroupModel, err error) { +// cursor, err := s.superGroupCollection.Find(ctx, bson.M{"group_id": bson.M{ +// "$in": groupIDs, +// }}) +// if err != nil { +// return nil, utils.Wrap(err, "") +// } +// defer cursor.Close(ctx) +// if err := cursor.All(ctx, &groups); err != nil { +// return nil, utils.Wrap(err, "") +// } +// return groups, nil +// } +// +// func (s *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...interface{}) error { +// opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) +// return s.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { +// _, err := s.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDs}}}) +// if err != nil { +// _ = sCtx.AbortTransaction(ctx) +// return err +// } +// upsert := true +// opts := &options.UpdateOptions{ +// Upsert: &upsert, +// } +// for _, userID := range userIDs { +// _, err = s.userToSuperGroupCollection.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts) +// if err != nil { +// _ = sCtx.AbortTransaction(ctx) +// return utils.Wrap(err, "transaction failed") +// } +// } +// return sCtx.CommitTransaction(ctx) +// }) +// } +// +// func (s *SuperGroupMongoDriver) RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...interface{}) error { +// opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) +// return s.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { +// _, err := s.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDs}}}) +// if err != nil { +// _ = sCtx.AbortTransaction(ctx) +// return err +// } +// err = s.RemoveGroupFromUser(sCtx, groupID, userIDs) +// if err != nil { +// _ = sCtx.AbortTransaction(ctx) +// return err +// } +// return sCtx.CommitTransaction(ctx) +// }) +// } +// +// func (s *SuperGroupMongoDriver) GetSuperGroupByUserID(ctx context.Context, userID string, tx ...interface{}) (*unrelation.UserToSuperGroupModel, error) { +// //TODO implement me +// panic("implement me") +// } +// +// func (s *SuperGroupMongoDriver) DeleteSuperGroup(ctx context.Context, groupID string, tx ...interface{}) error { +// //TODO implement me +// panic("implement me") +// } -func (db *SuperGroupMongoDriver) CreateSuperGroup(sCtx mongo.SessionContext, groupID string, initMemberIDs []string) error { - superGroup := unrelation.SuperGroupModel{ - GroupID: groupID, - MemberIDs: initMemberIDs, - } - _, err := db.superGroupCollection.InsertOne(sCtx, superGroup) +func (s *SuperGroupMongoDriver) Transaction(ctx context.Context, fn func(s unrelation.SuperGroupModelInterface, tx any) error) error { + sess, err := s.MgoClient.StartSession() if err != nil { return err } - upsert := true - opts := &options.UpdateOptions{ - Upsert: &upsert, + txCtx := mongo.NewSessionContext(ctx, sess) + defer sess.EndSession(txCtx) + if err := fn(s, txCtx); err != nil { + _ = sess.AbortTransaction(txCtx) + return err + } + return utils.Wrap(sess.CommitTransaction(txCtx), "") +} + +func (s *SuperGroupMongoDriver) getTxCtx(ctx context.Context, tx []any) context.Context { + if len(tx) > 0 { + if ctx, ok := tx[0].(mongo.SessionContext); ok { + return ctx + } + } + return ctx +} + +//func (s *SuperGroupMongoDriver) Transaction(ctx context.Context, fn func(ctx mongo.SessionContext) error) error { +// sess, err := s.MgoClient.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), "") +//} + +func (s *SuperGroupMongoDriver) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string, tx ...any) error { + ctx = s.getTxCtx(ctx, tx) + _, err := s.superGroupCollection.InsertOne(ctx, &unrelation.SuperGroupModel{ + GroupID: groupID, + MemberIDs: initMemberIDs, + }) + if err != nil { + return err } for _, userID := range initMemberIDs { - _, err = db.userToSuperGroupCollection.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts) + _, err = s.userToSuperGroupCollection.UpdateOne(ctx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, &options.UpdateOptions{ + Upsert: utils.ToPtr(true), + }) if err != nil { return err } } return nil - } -func (db *SuperGroupMongoDriver) GetSuperGroup(ctx context.Context, groupID string) (*unrelation.SuperGroupModel, error) { - superGroup := unrelation.SuperGroupModel{} - err := db.superGroupCollection.FindOne(ctx, bson.M{"group_id": groupID}).Decode(&superGroup) - return &superGroup, err +func (s *SuperGroupMongoDriver) TakeSuperGroup(ctx context.Context, groupID string, tx ...any) (group *unrelation.SuperGroupModel, err error) { + ctx = s.getTxCtx(ctx, tx) + if err := s.superGroupCollection.FindOne(ctx, bson.M{"group_id": groupID}).Decode(&group); err != nil { + return nil, utils.Wrap(err, "") + } + return group, nil } -func (db *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error { +func (s *SuperGroupMongoDriver) FindSuperGroup(ctx context.Context, groupIDs []string, tx ...any) (groups []*unrelation.SuperGroupModel, err error) { + ctx = s.getTxCtx(ctx, tx) + cursor, err := s.superGroupCollection.Find(ctx, bson.M{"group_id": bson.M{ + "$in": groupIDs, + }}) + if err != nil { + return nil, utils.Wrap(err, "") + } + defer cursor.Close(ctx) + if err := cursor.All(ctx, &groups); err != nil { + return nil, utils.Wrap(err, "") + } + return groups, nil +} + +func (s *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...any) error { + ctx = s.getTxCtx(ctx, tx) opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) - return db.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { - _, err := db.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDs}}}) + return s.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { + _, err := s.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$addToSet": bson.M{"member_id_list": bson.M{"$each": userIDs}}}) if err != nil { _ = sCtx.AbortTransaction(ctx) return err @@ -65,7 +206,7 @@ func (db *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupI Upsert: &upsert, } for _, userID := range userIDs { - _, err = db.userToSuperGroupCollection.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts) + _, err = s.userToSuperGroupCollection.UpdateOne(sCtx, bson.M{"user_id": userID}, bson.M{"$addToSet": bson.M{"group_id_list": groupID}}, opts) if err != nil { _ = sCtx.AbortTransaction(ctx) return utils.Wrap(err, "transaction failed") @@ -75,15 +216,16 @@ func (db *SuperGroupMongoDriver) AddUserToSuperGroup(ctx context.Context, groupI }) } -func (db *SuperGroupMongoDriver) RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string) error { +func (s *SuperGroupMongoDriver) RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string, tx ...any) error { + ctx = s.getTxCtx(ctx, tx) opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) - return db.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { - _, err := db.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDs}}}) + return s.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { + _, err := s.superGroupCollection.UpdateOne(sCtx, bson.M{"group_id": groupID}, bson.M{"$pull": bson.M{"member_id_list": bson.M{"$in": userIDs}}}) if err != nil { _ = sCtx.AbortTransaction(ctx) return err } - err = db.RemoveGroupFromUser(sCtx, groupID, userIDs) + err = s.RemoveGroupFromUser(sCtx, groupID, userIDs) if err != nil { _ = sCtx.AbortTransaction(ctx) return err @@ -92,40 +234,45 @@ func (db *SuperGroupMongoDriver) RemoverUserFromSuperGroup(ctx context.Context, }) } -func (db *SuperGroupMongoDriver) GetSuperGroupByUserID(ctx context.Context, userID string) (*unrelation.UserToSuperGroupModel, error) { +func (s *SuperGroupMongoDriver) GetSuperGroupByUserID(ctx context.Context, userID string, tx ...any) (*unrelation.UserToSuperGroupModel, error) { + ctx = s.getTxCtx(ctx, tx) var user unrelation.UserToSuperGroupModel - err := db.userToSuperGroupCollection.FindOne(ctx, bson.M{"user_id": userID}).Decode(&user) + err := s.userToSuperGroupCollection.FindOne(ctx, bson.M{"user_id": userID}).Decode(&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 (s *SuperGroupMongoDriver) DeleteSuperGroup(ctx context.Context, groupID string, tx ...any) error { + ctx = s.getTxCtx(ctx, tx) + group, err := s.TakeSuperGroup(ctx, groupID, tx...) + if err != nil { + return err + } + if _, err := s.superGroupCollection.DeleteOne(ctx, bson.M{"group_id": groupID}); err != nil { + return utils.Wrap(err, "") + } + return s.RemoveGroupFromUser(ctx, groupID, group.MemberIDs) } -func (db *SuperGroupMongoDriver) MapGroupMemberCount(ctx context.Context, groupIDs []string) (map[string]uint32, error) { - //TODO implement me - panic("implement me") -} +//func (s *SuperGroupMongoDriver) DeleteSuperGroup(ctx context.Context, groupID string, tx ...any) error { +// ctx = s.getTxCtx(ctx, tx) +// opts := options.Session().SetDefaultReadConcern(readconcern.Majority()) +// return s.MgoDB.Client().UseSessionWithOptions(ctx, opts, func(sCtx mongo.SessionContext) error { +// superGroup := &unrelation.SuperGroupModel{} +// _, err := s.superGroupCollection.DeleteOne(sCtx, bson.M{"group_id": groupID}) +// if err != nil { +// _ = sCtx.AbortTransaction(ctx) +// return err +// } +// if err = s.RemoveGroupFromUser(sCtx, groupID, superGroup.MemberIDs); err != nil { +// _ = sCtx.AbortTransaction(ctx) +// return err +// } +// return sCtx.CommitTransaction(ctx) +// }) +//} -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 { - superGroup := &unrelation.SuperGroupModel{} - _, err := db.superGroupCollection.DeleteOne(sCtx, bson.M{"group_id": groupID}) - if err != nil { - _ = sCtx.AbortTransaction(ctx) - return err - } - if err = db.RemoveGroupFromUser(sCtx, groupID, superGroup.MemberIDs); err != nil { - _ = sCtx.AbortTransaction(ctx) - return err - } - return sCtx.CommitTransaction(ctx) - }) -} - -func (db *SuperGroupMongoDriver) RemoveGroupFromUser(sCtx context.Context, groupID string, userIDs []string) error { - _, err := db.userToSuperGroupCollection.UpdateOne(sCtx, bson.M{"user_id": bson.M{"$in": userIDs}}, bson.M{"$pull": bson.M{"group_id_list": groupID}}) - return err +func (s *SuperGroupMongoDriver) RemoveGroupFromUser(ctx context.Context, groupID string, userIDs []string, tx ...any) error { + ctx = s.getTxCtx(ctx, tx) + _, err := s.userToSuperGroupCollection.UpdateOne(ctx, bson.M{"user_id": bson.M{"$in": userIDs}}, bson.M{"$pull": bson.M{"group_id_list": groupID}}) + return utils.Wrap(err, "") } diff --git a/pkg/proto/group/group.pb.go b/pkg/proto/group/group.pb.go index ad028a12a..a125f304d 100644 --- a/pkg/proto/group/group.pb.go +++ b/pkg/proto/group/group.pb.go @@ -39,7 +39,7 @@ func (m *CreateGroupReq) Reset() { *m = CreateGroupReq{} } func (m *CreateGroupReq) String() string { return proto.CompactTextString(m) } func (*CreateGroupReq) ProtoMessage() {} func (*CreateGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{0} + return fileDescriptor_group_97564bfcd2811fbb, []int{0} } func (m *CreateGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateGroupReq.Unmarshal(m, b) @@ -98,7 +98,7 @@ func (m *CreateGroupResp) Reset() { *m = CreateGroupResp{} } func (m *CreateGroupResp) String() string { return proto.CompactTextString(m) } func (*CreateGroupResp) ProtoMessage() {} func (*CreateGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{1} + return fileDescriptor_group_97564bfcd2811fbb, []int{1} } func (m *CreateGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CreateGroupResp.Unmarshal(m, b) @@ -136,7 +136,7 @@ func (m *GetGroupsInfoReq) Reset() { *m = GetGroupsInfoReq{} } func (m *GetGroupsInfoReq) String() string { return proto.CompactTextString(m) } func (*GetGroupsInfoReq) ProtoMessage() {} func (*GetGroupsInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{2} + return fileDescriptor_group_97564bfcd2811fbb, []int{2} } func (m *GetGroupsInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupsInfoReq.Unmarshal(m, b) @@ -174,7 +174,7 @@ func (m *GetGroupsInfoResp) Reset() { *m = GetGroupsInfoResp{} } func (m *GetGroupsInfoResp) String() string { return proto.CompactTextString(m) } func (*GetGroupsInfoResp) ProtoMessage() {} func (*GetGroupsInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{3} + return fileDescriptor_group_97564bfcd2811fbb, []int{3} } func (m *GetGroupsInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupsInfoResp.Unmarshal(m, b) @@ -212,7 +212,7 @@ func (m *SetGroupInfoReq) Reset() { *m = SetGroupInfoReq{} } func (m *SetGroupInfoReq) String() string { return proto.CompactTextString(m) } func (*SetGroupInfoReq) ProtoMessage() {} func (*SetGroupInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{4} + return fileDescriptor_group_97564bfcd2811fbb, []int{4} } func (m *SetGroupInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupInfoReq.Unmarshal(m, b) @@ -249,7 +249,7 @@ func (m *SetGroupInfoResp) Reset() { *m = SetGroupInfoResp{} } func (m *SetGroupInfoResp) String() string { return proto.CompactTextString(m) } func (*SetGroupInfoResp) ProtoMessage() {} func (*SetGroupInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{5} + return fileDescriptor_group_97564bfcd2811fbb, []int{5} } func (m *SetGroupInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupInfoResp.Unmarshal(m, b) @@ -281,7 +281,7 @@ func (m *GetGroupApplicationListReq) Reset() { *m = GetGroupApplicationL func (m *GetGroupApplicationListReq) String() string { return proto.CompactTextString(m) } func (*GetGroupApplicationListReq) ProtoMessage() {} func (*GetGroupApplicationListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{6} + return fileDescriptor_group_97564bfcd2811fbb, []int{6} } func (m *GetGroupApplicationListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupApplicationListReq.Unmarshal(m, b) @@ -316,7 +316,7 @@ func (m *GetGroupApplicationListReq) GetFromUserID() string { } type GetGroupApplicationListResp struct { - Total int32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` + Total uint32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` GroupRequests []*sdk_ws.GroupRequest `protobuf:"bytes,2,rep,name=groupRequests" json:"groupRequests,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -327,7 +327,7 @@ func (m *GetGroupApplicationListResp) Reset() { *m = GetGroupApplication func (m *GetGroupApplicationListResp) String() string { return proto.CompactTextString(m) } func (*GetGroupApplicationListResp) ProtoMessage() {} func (*GetGroupApplicationListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{7} + return fileDescriptor_group_97564bfcd2811fbb, []int{7} } func (m *GetGroupApplicationListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupApplicationListResp.Unmarshal(m, b) @@ -347,7 +347,7 @@ func (m *GetGroupApplicationListResp) XXX_DiscardUnknown() { var xxx_messageInfo_GetGroupApplicationListResp proto.InternalMessageInfo -func (m *GetGroupApplicationListResp) GetTotal() int32 { +func (m *GetGroupApplicationListResp) GetTotal() uint32 { if m != nil { return m.Total } @@ -362,8 +362,8 @@ func (m *GetGroupApplicationListResp) GetGroupRequests() []*sdk_ws.GroupRequest } type GetUserReqApplicationListReq struct { - UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` - Pagination *sdk_ws.RequestPagination `protobuf:"bytes,2,opt,name=pagination" json:"pagination,omitempty"` + Pagination *sdk_ws.RequestPagination `protobuf:"bytes,1,opt,name=pagination" json:"pagination,omitempty"` + UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -373,7 +373,7 @@ func (m *GetUserReqApplicationListReq) Reset() { *m = GetUserReqApplicat func (m *GetUserReqApplicationListReq) String() string { return proto.CompactTextString(m) } func (*GetUserReqApplicationListReq) ProtoMessage() {} func (*GetUserReqApplicationListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{8} + return fileDescriptor_group_97564bfcd2811fbb, []int{8} } func (m *GetUserReqApplicationListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetUserReqApplicationListReq.Unmarshal(m, b) @@ -393,13 +393,6 @@ func (m *GetUserReqApplicationListReq) XXX_DiscardUnknown() { var xxx_messageInfo_GetUserReqApplicationListReq proto.InternalMessageInfo -func (m *GetUserReqApplicationListReq) GetUserID() string { - if m != nil { - return m.UserID - } - return "" -} - func (m *GetUserReqApplicationListReq) GetPagination() *sdk_ws.RequestPagination { if m != nil { return m.Pagination @@ -407,8 +400,15 @@ func (m *GetUserReqApplicationListReq) GetPagination() *sdk_ws.RequestPagination return nil } +func (m *GetUserReqApplicationListReq) GetUserID() string { + if m != nil { + return m.UserID + } + return "" +} + type GetUserReqApplicationListResp struct { - Total int32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` + Total uint32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` GroupRequests []*sdk_ws.GroupRequest `protobuf:"bytes,2,rep,name=groupRequests" json:"groupRequests,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -419,7 +419,7 @@ func (m *GetUserReqApplicationListResp) Reset() { *m = GetUserReqApplica func (m *GetUserReqApplicationListResp) String() string { return proto.CompactTextString(m) } func (*GetUserReqApplicationListResp) ProtoMessage() {} func (*GetUserReqApplicationListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{9} + return fileDescriptor_group_97564bfcd2811fbb, []int{9} } func (m *GetUserReqApplicationListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetUserReqApplicationListResp.Unmarshal(m, b) @@ -439,7 +439,7 @@ func (m *GetUserReqApplicationListResp) XXX_DiscardUnknown() { var xxx_messageInfo_GetUserReqApplicationListResp proto.InternalMessageInfo -func (m *GetUserReqApplicationListResp) GetTotal() int32 { +func (m *GetUserReqApplicationListResp) GetTotal() uint32 { if m != nil { return m.Total } @@ -466,7 +466,7 @@ func (m *TransferGroupOwnerReq) Reset() { *m = TransferGroupOwnerReq{} } func (m *TransferGroupOwnerReq) String() string { return proto.CompactTextString(m) } func (*TransferGroupOwnerReq) ProtoMessage() {} func (*TransferGroupOwnerReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{10} + return fileDescriptor_group_97564bfcd2811fbb, []int{10} } func (m *TransferGroupOwnerReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_TransferGroupOwnerReq.Unmarshal(m, b) @@ -517,7 +517,7 @@ func (m *TransferGroupOwnerResp) Reset() { *m = TransferGroupOwnerResp{} func (m *TransferGroupOwnerResp) String() string { return proto.CompactTextString(m) } func (*TransferGroupOwnerResp) ProtoMessage() {} func (*TransferGroupOwnerResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{11} + return fileDescriptor_group_97564bfcd2811fbb, []int{11} } func (m *TransferGroupOwnerResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_TransferGroupOwnerResp.Unmarshal(m, b) @@ -551,7 +551,7 @@ func (m *JoinGroupReq) Reset() { *m = JoinGroupReq{} } func (m *JoinGroupReq) String() string { return proto.CompactTextString(m) } func (*JoinGroupReq) ProtoMessage() {} func (*JoinGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{12} + return fileDescriptor_group_97564bfcd2811fbb, []int{12} } func (m *JoinGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_JoinGroupReq.Unmarshal(m, b) @@ -609,7 +609,7 @@ func (m *JoinGroupResp) Reset() { *m = JoinGroupResp{} } func (m *JoinGroupResp) String() string { return proto.CompactTextString(m) } func (*JoinGroupResp) ProtoMessage() {} func (*JoinGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{13} + return fileDescriptor_group_97564bfcd2811fbb, []int{13} } func (m *JoinGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_JoinGroupResp.Unmarshal(m, b) @@ -643,7 +643,7 @@ func (m *GroupApplicationResponseReq) Reset() { *m = GroupApplicationRes func (m *GroupApplicationResponseReq) String() string { return proto.CompactTextString(m) } func (*GroupApplicationResponseReq) ProtoMessage() {} func (*GroupApplicationResponseReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{14} + return fileDescriptor_group_97564bfcd2811fbb, []int{14} } func (m *GroupApplicationResponseReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupApplicationResponseReq.Unmarshal(m, b) @@ -701,7 +701,7 @@ func (m *GroupApplicationResponseResp) Reset() { *m = GroupApplicationRe func (m *GroupApplicationResponseResp) String() string { return proto.CompactTextString(m) } func (*GroupApplicationResponseResp) ProtoMessage() {} func (*GroupApplicationResponseResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{15} + return fileDescriptor_group_97564bfcd2811fbb, []int{15} } func (m *GroupApplicationResponseResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupApplicationResponseResp.Unmarshal(m, b) @@ -732,7 +732,7 @@ func (m *QuitGroupReq) Reset() { *m = QuitGroupReq{} } func (m *QuitGroupReq) String() string { return proto.CompactTextString(m) } func (*QuitGroupReq) ProtoMessage() {} func (*QuitGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{16} + return fileDescriptor_group_97564bfcd2811fbb, []int{16} } func (m *QuitGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_QuitGroupReq.Unmarshal(m, b) @@ -769,7 +769,7 @@ func (m *QuitGroupResp) Reset() { *m = QuitGroupResp{} } func (m *QuitGroupResp) String() string { return proto.CompactTextString(m) } func (*QuitGroupResp) ProtoMessage() {} func (*QuitGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{17} + return fileDescriptor_group_97564bfcd2811fbb, []int{17} } func (m *QuitGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_QuitGroupResp.Unmarshal(m, b) @@ -790,9 +790,9 @@ func (m *QuitGroupResp) XXX_DiscardUnknown() { var xxx_messageInfo_QuitGroupResp proto.InternalMessageInfo type GetGroupMemberListReq struct { - GroupID string `protobuf:"bytes,1,opt,name=groupID" json:"groupID,omitempty"` - Filter int32 `protobuf:"varint,2,opt,name=filter" json:"filter,omitempty"` - Pagination *sdk_ws.RequestPagination `protobuf:"bytes,4,opt,name=pagination" json:"pagination,omitempty"` + Pagination *sdk_ws.RequestPagination `protobuf:"bytes,1,opt,name=pagination" json:"pagination,omitempty"` + GroupID string `protobuf:"bytes,2,opt,name=groupID" json:"groupID,omitempty"` + Filter int32 `protobuf:"varint,3,opt,name=filter" json:"filter,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -802,7 +802,7 @@ func (m *GetGroupMemberListReq) Reset() { *m = GetGroupMemberListReq{} } func (m *GetGroupMemberListReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMemberListReq) ProtoMessage() {} func (*GetGroupMemberListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{18} + return fileDescriptor_group_97564bfcd2811fbb, []int{18} } func (m *GetGroupMemberListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMemberListReq.Unmarshal(m, b) @@ -822,6 +822,13 @@ func (m *GetGroupMemberListReq) XXX_DiscardUnknown() { var xxx_messageInfo_GetGroupMemberListReq proto.InternalMessageInfo +func (m *GetGroupMemberListReq) GetPagination() *sdk_ws.RequestPagination { + if m != nil { + return m.Pagination + } + return nil +} + func (m *GetGroupMemberListReq) GetGroupID() string { if m != nil { return m.GroupID @@ -836,15 +843,8 @@ func (m *GetGroupMemberListReq) GetFilter() int32 { return 0 } -func (m *GetGroupMemberListReq) GetPagination() *sdk_ws.RequestPagination { - if m != nil { - return m.Pagination - } - return nil -} - type GetGroupMemberListResp struct { - Total int32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` + Total uint32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` Members []*sdk_ws.GroupMemberFullInfo `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -855,7 +855,7 @@ func (m *GetGroupMemberListResp) Reset() { *m = GetGroupMemberListResp{} func (m *GetGroupMemberListResp) String() string { return proto.CompactTextString(m) } func (*GetGroupMemberListResp) ProtoMessage() {} func (*GetGroupMemberListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{19} + return fileDescriptor_group_97564bfcd2811fbb, []int{19} } func (m *GetGroupMemberListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMemberListResp.Unmarshal(m, b) @@ -875,7 +875,7 @@ func (m *GetGroupMemberListResp) XXX_DiscardUnknown() { var xxx_messageInfo_GetGroupMemberListResp proto.InternalMessageInfo -func (m *GetGroupMemberListResp) GetTotal() int32 { +func (m *GetGroupMemberListResp) GetTotal() uint32 { if m != nil { return m.Total } @@ -901,7 +901,7 @@ func (m *GetGroupMembersInfoReq) Reset() { *m = GetGroupMembersInfoReq{} func (m *GetGroupMembersInfoReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMembersInfoReq) ProtoMessage() {} func (*GetGroupMembersInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{20} + return fileDescriptor_group_97564bfcd2811fbb, []int{20} } func (m *GetGroupMembersInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMembersInfoReq.Unmarshal(m, b) @@ -946,7 +946,7 @@ func (m *GetGroupMembersInfoResp) Reset() { *m = GetGroupMembersInfoResp func (m *GetGroupMembersInfoResp) String() string { return proto.CompactTextString(m) } func (*GetGroupMembersInfoResp) ProtoMessage() {} func (*GetGroupMembersInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{21} + return fileDescriptor_group_97564bfcd2811fbb, []int{21} } func (m *GetGroupMembersInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMembersInfoResp.Unmarshal(m, b) @@ -986,7 +986,7 @@ func (m *KickGroupMemberReq) Reset() { *m = KickGroupMemberReq{} } func (m *KickGroupMemberReq) String() string { return proto.CompactTextString(m) } func (*KickGroupMemberReq) ProtoMessage() {} func (*KickGroupMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{22} + return fileDescriptor_group_97564bfcd2811fbb, []int{22} } func (m *KickGroupMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_KickGroupMemberReq.Unmarshal(m, b) @@ -1037,7 +1037,7 @@ func (m *KickGroupMemberResp) Reset() { *m = KickGroupMemberResp{} } func (m *KickGroupMemberResp) String() string { return proto.CompactTextString(m) } func (*KickGroupMemberResp) ProtoMessage() {} func (*KickGroupMemberResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{23} + return fileDescriptor_group_97564bfcd2811fbb, []int{23} } func (m *KickGroupMemberResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_KickGroupMemberResp.Unmarshal(m, b) @@ -1058,8 +1058,8 @@ func (m *KickGroupMemberResp) XXX_DiscardUnknown() { var xxx_messageInfo_KickGroupMemberResp proto.InternalMessageInfo type GetJoinedGroupListReq struct { - FromUserID string `protobuf:"bytes,1,opt,name=fromUserID" json:"fromUserID,omitempty"` - Pagination *sdk_ws.RequestPagination `protobuf:"bytes,2,opt,name=pagination" json:"pagination,omitempty"` + Pagination *sdk_ws.RequestPagination `protobuf:"bytes,1,opt,name=pagination" json:"pagination,omitempty"` + FromUserID string `protobuf:"bytes,2,opt,name=fromUserID" json:"fromUserID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1069,7 +1069,7 @@ func (m *GetJoinedGroupListReq) Reset() { *m = GetJoinedGroupListReq{} } func (m *GetJoinedGroupListReq) String() string { return proto.CompactTextString(m) } func (*GetJoinedGroupListReq) ProtoMessage() {} func (*GetJoinedGroupListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{24} + return fileDescriptor_group_97564bfcd2811fbb, []int{24} } func (m *GetJoinedGroupListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJoinedGroupListReq.Unmarshal(m, b) @@ -1089,13 +1089,6 @@ func (m *GetJoinedGroupListReq) XXX_DiscardUnknown() { var xxx_messageInfo_GetJoinedGroupListReq proto.InternalMessageInfo -func (m *GetJoinedGroupListReq) GetFromUserID() string { - if m != nil { - return m.FromUserID - } - return "" -} - func (m *GetJoinedGroupListReq) GetPagination() *sdk_ws.RequestPagination { if m != nil { return m.Pagination @@ -1103,8 +1096,15 @@ func (m *GetJoinedGroupListReq) GetPagination() *sdk_ws.RequestPagination { return nil } +func (m *GetJoinedGroupListReq) GetFromUserID() string { + if m != nil { + return m.FromUserID + } + return "" +} + type GetJoinedGroupListResp struct { - Total int32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` + Total uint32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` Groups []*sdk_ws.GroupInfo `protobuf:"bytes,2,rep,name=groups" json:"groups,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -1115,7 +1115,7 @@ func (m *GetJoinedGroupListResp) Reset() { *m = GetJoinedGroupListResp{} func (m *GetJoinedGroupListResp) String() string { return proto.CompactTextString(m) } func (*GetJoinedGroupListResp) ProtoMessage() {} func (*GetJoinedGroupListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{25} + return fileDescriptor_group_97564bfcd2811fbb, []int{25} } func (m *GetJoinedGroupListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJoinedGroupListResp.Unmarshal(m, b) @@ -1135,7 +1135,7 @@ func (m *GetJoinedGroupListResp) XXX_DiscardUnknown() { var xxx_messageInfo_GetJoinedGroupListResp proto.InternalMessageInfo -func (m *GetJoinedGroupListResp) GetTotal() int32 { +func (m *GetJoinedGroupListResp) GetTotal() uint32 { if m != nil { return m.Total } @@ -1162,7 +1162,7 @@ func (m *InviteUserToGroupReq) Reset() { *m = InviteUserToGroupReq{} } func (m *InviteUserToGroupReq) String() string { return proto.CompactTextString(m) } func (*InviteUserToGroupReq) ProtoMessage() {} func (*InviteUserToGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{26} + return fileDescriptor_group_97564bfcd2811fbb, []int{26} } func (m *InviteUserToGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_InviteUserToGroupReq.Unmarshal(m, b) @@ -1213,7 +1213,7 @@ func (m *InviteUserToGroupResp) Reset() { *m = InviteUserToGroupResp{} } func (m *InviteUserToGroupResp) String() string { return proto.CompactTextString(m) } func (*InviteUserToGroupResp) ProtoMessage() {} func (*InviteUserToGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{27} + return fileDescriptor_group_97564bfcd2811fbb, []int{27} } func (m *InviteUserToGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_InviteUserToGroupResp.Unmarshal(m, b) @@ -1234,8 +1234,8 @@ func (m *InviteUserToGroupResp) XXX_DiscardUnknown() { var xxx_messageInfo_InviteUserToGroupResp proto.InternalMessageInfo type GetGroupAllMemberReq struct { - GroupID string `protobuf:"bytes,1,opt,name=groupID" json:"groupID,omitempty"` - Pagination *sdk_ws.RequestPagination `protobuf:"bytes,2,opt,name=pagination" json:"pagination,omitempty"` + Pagination *sdk_ws.RequestPagination `protobuf:"bytes,1,opt,name=pagination" json:"pagination,omitempty"` + GroupID string `protobuf:"bytes,2,opt,name=groupID" json:"groupID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1245,7 +1245,7 @@ func (m *GetGroupAllMemberReq) Reset() { *m = GetGroupAllMemberReq{} } func (m *GetGroupAllMemberReq) String() string { return proto.CompactTextString(m) } func (*GetGroupAllMemberReq) ProtoMessage() {} func (*GetGroupAllMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{28} + return fileDescriptor_group_97564bfcd2811fbb, []int{28} } func (m *GetGroupAllMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupAllMemberReq.Unmarshal(m, b) @@ -1265,13 +1265,6 @@ func (m *GetGroupAllMemberReq) XXX_DiscardUnknown() { var xxx_messageInfo_GetGroupAllMemberReq proto.InternalMessageInfo -func (m *GetGroupAllMemberReq) GetGroupID() string { - if m != nil { - return m.GroupID - } - return "" -} - func (m *GetGroupAllMemberReq) GetPagination() *sdk_ws.RequestPagination { if m != nil { return m.Pagination @@ -1279,6 +1272,13 @@ func (m *GetGroupAllMemberReq) GetPagination() *sdk_ws.RequestPagination { return nil } +func (m *GetGroupAllMemberReq) GetGroupID() string { + if m != nil { + return m.GroupID + } + return "" +} + type GetGroupAllMemberResp struct { Members []*sdk_ws.GroupMemberFullInfo `protobuf:"bytes,1,rep,name=members" json:"members,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1290,7 +1290,7 @@ func (m *GetGroupAllMemberResp) Reset() { *m = GetGroupAllMemberResp{} } func (m *GetGroupAllMemberResp) String() string { return proto.CompactTextString(m) } func (*GetGroupAllMemberResp) ProtoMessage() {} func (*GetGroupAllMemberResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{29} + return fileDescriptor_group_97564bfcd2811fbb, []int{29} } func (m *GetGroupAllMemberResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupAllMemberResp.Unmarshal(m, b) @@ -1330,7 +1330,7 @@ func (m *CMSGroup) Reset() { *m = CMSGroup{} } func (m *CMSGroup) String() string { return proto.CompactTextString(m) } func (*CMSGroup) ProtoMessage() {} func (*CMSGroup) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{30} + return fileDescriptor_group_97564bfcd2811fbb, []int{30} } func (m *CMSGroup) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CMSGroup.Unmarshal(m, b) @@ -1384,7 +1384,7 @@ func (m *GetGroupsReq) Reset() { *m = GetGroupsReq{} } func (m *GetGroupsReq) String() string { return proto.CompactTextString(m) } func (*GetGroupsReq) ProtoMessage() {} func (*GetGroupsReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{31} + return fileDescriptor_group_97564bfcd2811fbb, []int{31} } func (m *GetGroupsReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupsReq.Unmarshal(m, b) @@ -1426,8 +1426,8 @@ func (m *GetGroupsReq) GetGroupID() string { } type GetGroupsResp struct { - Groups []*CMSGroup `protobuf:"bytes,1,rep,name=groups" json:"groups,omitempty"` - GroupNum int32 `protobuf:"varint,2,opt,name=GroupNum" json:"GroupNum,omitempty"` + Total uint32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` + Groups []*CMSGroup `protobuf:"bytes,2,rep,name=groups" json:"groups,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1437,7 +1437,7 @@ func (m *GetGroupsResp) Reset() { *m = GetGroupsResp{} } func (m *GetGroupsResp) String() string { return proto.CompactTextString(m) } func (*GetGroupsResp) ProtoMessage() {} func (*GetGroupsResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{32} + return fileDescriptor_group_97564bfcd2811fbb, []int{32} } func (m *GetGroupsResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupsResp.Unmarshal(m, b) @@ -1457,6 +1457,13 @@ func (m *GetGroupsResp) XXX_DiscardUnknown() { var xxx_messageInfo_GetGroupsResp proto.InternalMessageInfo +func (m *GetGroupsResp) GetTotal() uint32 { + if m != nil { + return m.Total + } + return 0 +} + func (m *GetGroupsResp) GetGroups() []*CMSGroup { if m != nil { return m.Groups @@ -1464,13 +1471,6 @@ func (m *GetGroupsResp) GetGroups() []*CMSGroup { return nil } -func (m *GetGroupsResp) GetGroupNum() int32 { - if m != nil { - return m.GroupNum - } - return 0 -} - type GetGroupMemberReq struct { GroupID string `protobuf:"bytes,1,opt,name=groupID" json:"groupID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1482,7 +1482,7 @@ func (m *GetGroupMemberReq) Reset() { *m = GetGroupMemberReq{} } func (m *GetGroupMemberReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMemberReq) ProtoMessage() {} func (*GetGroupMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{33} + return fileDescriptor_group_97564bfcd2811fbb, []int{33} } func (m *GetGroupMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMemberReq.Unmarshal(m, b) @@ -1510,9 +1510,9 @@ func (m *GetGroupMemberReq) GetGroupID() string { } type GetGroupMembersCMSReq struct { - GroupID string `protobuf:"bytes,1,opt,name=groupID" json:"groupID,omitempty"` - UserName string `protobuf:"bytes,2,opt,name=userName" json:"userName,omitempty"` - Pagination *sdk_ws.RequestPagination `protobuf:"bytes,3,opt,name=pagination" json:"pagination,omitempty"` + Pagination *sdk_ws.RequestPagination `protobuf:"bytes,1,opt,name=pagination" json:"pagination,omitempty"` + GroupID string `protobuf:"bytes,2,opt,name=groupID" json:"groupID,omitempty"` + UserName string `protobuf:"bytes,3,opt,name=userName" json:"userName,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1522,7 +1522,7 @@ func (m *GetGroupMembersCMSReq) Reset() { *m = GetGroupMembersCMSReq{} } func (m *GetGroupMembersCMSReq) String() string { return proto.CompactTextString(m) } func (*GetGroupMembersCMSReq) ProtoMessage() {} func (*GetGroupMembersCMSReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{34} + return fileDescriptor_group_97564bfcd2811fbb, []int{34} } func (m *GetGroupMembersCMSReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMembersCMSReq.Unmarshal(m, b) @@ -1542,6 +1542,13 @@ func (m *GetGroupMembersCMSReq) XXX_DiscardUnknown() { var xxx_messageInfo_GetGroupMembersCMSReq proto.InternalMessageInfo +func (m *GetGroupMembersCMSReq) GetPagination() *sdk_ws.RequestPagination { + if m != nil { + return m.Pagination + } + return nil +} + func (m *GetGroupMembersCMSReq) GetGroupID() string { if m != nil { return m.GroupID @@ -1556,16 +1563,9 @@ func (m *GetGroupMembersCMSReq) GetUserName() string { return "" } -func (m *GetGroupMembersCMSReq) GetPagination() *sdk_ws.RequestPagination { - if m != nil { - return m.Pagination - } - return nil -} - type GetGroupMembersCMSResp struct { - Members []*sdk_ws.GroupMemberFullInfo `protobuf:"bytes,1,rep,name=members" json:"members,omitempty"` - MemberNums int32 `protobuf:"varint,2,opt,name=memberNums" json:"memberNums,omitempty"` + Total uint32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` + Members []*sdk_ws.GroupMemberFullInfo `protobuf:"bytes,2,rep,name=members" json:"members,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1575,7 +1575,7 @@ func (m *GetGroupMembersCMSResp) Reset() { *m = GetGroupMembersCMSResp{} func (m *GetGroupMembersCMSResp) String() string { return proto.CompactTextString(m) } func (*GetGroupMembersCMSResp) ProtoMessage() {} func (*GetGroupMembersCMSResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{35} + return fileDescriptor_group_97564bfcd2811fbb, []int{35} } func (m *GetGroupMembersCMSResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupMembersCMSResp.Unmarshal(m, b) @@ -1595,6 +1595,13 @@ func (m *GetGroupMembersCMSResp) XXX_DiscardUnknown() { var xxx_messageInfo_GetGroupMembersCMSResp proto.InternalMessageInfo +func (m *GetGroupMembersCMSResp) GetTotal() uint32 { + if m != nil { + return m.Total + } + return 0 +} + func (m *GetGroupMembersCMSResp) GetMembers() []*sdk_ws.GroupMemberFullInfo { if m != nil { return m.Members @@ -1602,13 +1609,6 @@ func (m *GetGroupMembersCMSResp) GetMembers() []*sdk_ws.GroupMemberFullInfo { return nil } -func (m *GetGroupMembersCMSResp) GetMemberNums() int32 { - if m != nil { - return m.MemberNums - } - return 0 -} - type DismissGroupReq struct { GroupID string `protobuf:"bytes,1,opt,name=groupID" json:"groupID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -1620,7 +1620,7 @@ func (m *DismissGroupReq) Reset() { *m = DismissGroupReq{} } func (m *DismissGroupReq) String() string { return proto.CompactTextString(m) } func (*DismissGroupReq) ProtoMessage() {} func (*DismissGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{36} + return fileDescriptor_group_97564bfcd2811fbb, []int{36} } func (m *DismissGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DismissGroupReq.Unmarshal(m, b) @@ -1657,7 +1657,7 @@ func (m *DismissGroupResp) Reset() { *m = DismissGroupResp{} } func (m *DismissGroupResp) String() string { return proto.CompactTextString(m) } func (*DismissGroupResp) ProtoMessage() {} func (*DismissGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{37} + return fileDescriptor_group_97564bfcd2811fbb, []int{37} } func (m *DismissGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_DismissGroupResp.Unmarshal(m, b) @@ -1690,7 +1690,7 @@ func (m *MuteGroupMemberReq) Reset() { *m = MuteGroupMemberReq{} } func (m *MuteGroupMemberReq) String() string { return proto.CompactTextString(m) } func (*MuteGroupMemberReq) ProtoMessage() {} func (*MuteGroupMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{38} + return fileDescriptor_group_97564bfcd2811fbb, []int{38} } func (m *MuteGroupMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MuteGroupMemberReq.Unmarshal(m, b) @@ -1741,7 +1741,7 @@ func (m *MuteGroupMemberResp) Reset() { *m = MuteGroupMemberResp{} } func (m *MuteGroupMemberResp) String() string { return proto.CompactTextString(m) } func (*MuteGroupMemberResp) ProtoMessage() {} func (*MuteGroupMemberResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{39} + return fileDescriptor_group_97564bfcd2811fbb, []int{39} } func (m *MuteGroupMemberResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MuteGroupMemberResp.Unmarshal(m, b) @@ -1773,7 +1773,7 @@ func (m *CancelMuteGroupMemberReq) Reset() { *m = CancelMuteGroupMemberR func (m *CancelMuteGroupMemberReq) String() string { return proto.CompactTextString(m) } func (*CancelMuteGroupMemberReq) ProtoMessage() {} func (*CancelMuteGroupMemberReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{40} + return fileDescriptor_group_97564bfcd2811fbb, []int{40} } func (m *CancelMuteGroupMemberReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CancelMuteGroupMemberReq.Unmarshal(m, b) @@ -1817,7 +1817,7 @@ func (m *CancelMuteGroupMemberResp) Reset() { *m = CancelMuteGroupMember func (m *CancelMuteGroupMemberResp) String() string { return proto.CompactTextString(m) } func (*CancelMuteGroupMemberResp) ProtoMessage() {} func (*CancelMuteGroupMemberResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{41} + return fileDescriptor_group_97564bfcd2811fbb, []int{41} } func (m *CancelMuteGroupMemberResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CancelMuteGroupMemberResp.Unmarshal(m, b) @@ -1848,7 +1848,7 @@ func (m *MuteGroupReq) Reset() { *m = MuteGroupReq{} } func (m *MuteGroupReq) String() string { return proto.CompactTextString(m) } func (*MuteGroupReq) ProtoMessage() {} func (*MuteGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{42} + return fileDescriptor_group_97564bfcd2811fbb, []int{42} } func (m *MuteGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MuteGroupReq.Unmarshal(m, b) @@ -1885,7 +1885,7 @@ func (m *MuteGroupResp) Reset() { *m = MuteGroupResp{} } func (m *MuteGroupResp) String() string { return proto.CompactTextString(m) } func (*MuteGroupResp) ProtoMessage() {} func (*MuteGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{43} + return fileDescriptor_group_97564bfcd2811fbb, []int{43} } func (m *MuteGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MuteGroupResp.Unmarshal(m, b) @@ -1916,7 +1916,7 @@ func (m *CancelMuteGroupReq) Reset() { *m = CancelMuteGroupReq{} } func (m *CancelMuteGroupReq) String() string { return proto.CompactTextString(m) } func (*CancelMuteGroupReq) ProtoMessage() {} func (*CancelMuteGroupReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{44} + return fileDescriptor_group_97564bfcd2811fbb, []int{44} } func (m *CancelMuteGroupReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CancelMuteGroupReq.Unmarshal(m, b) @@ -1953,7 +1953,7 @@ func (m *CancelMuteGroupResp) Reset() { *m = CancelMuteGroupResp{} } func (m *CancelMuteGroupResp) String() string { return proto.CompactTextString(m) } func (*CancelMuteGroupResp) ProtoMessage() {} func (*CancelMuteGroupResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{45} + return fileDescriptor_group_97564bfcd2811fbb, []int{45} } func (m *CancelMuteGroupResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_CancelMuteGroupResp.Unmarshal(m, b) @@ -1986,7 +1986,7 @@ func (m *SetGroupMemberNicknameReq) Reset() { *m = SetGroupMemberNicknam func (m *SetGroupMemberNicknameReq) String() string { return proto.CompactTextString(m) } func (*SetGroupMemberNicknameReq) ProtoMessage() {} func (*SetGroupMemberNicknameReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{46} + return fileDescriptor_group_97564bfcd2811fbb, []int{46} } func (m *SetGroupMemberNicknameReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupMemberNicknameReq.Unmarshal(m, b) @@ -2037,7 +2037,7 @@ func (m *SetGroupMemberNicknameResp) Reset() { *m = SetGroupMemberNickna func (m *SetGroupMemberNicknameResp) String() string { return proto.CompactTextString(m) } func (*SetGroupMemberNicknameResp) ProtoMessage() {} func (*SetGroupMemberNicknameResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{47} + return fileDescriptor_group_97564bfcd2811fbb, []int{47} } func (m *SetGroupMemberNicknameResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupMemberNicknameResp.Unmarshal(m, b) @@ -2058,18 +2058,17 @@ func (m *SetGroupMemberNicknameResp) XXX_DiscardUnknown() { var xxx_messageInfo_SetGroupMemberNicknameResp proto.InternalMessageInfo type GetJoinedSuperGroupListReq struct { - Pagination *sdk_ws.RequestPagination `protobuf:"bytes,1,opt,name=pagination" json:"pagination,omitempty"` - UserID string `protobuf:"bytes,2,opt,name=userID" json:"userID,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *GetJoinedSuperGroupListReq) Reset() { *m = GetJoinedSuperGroupListReq{} } func (m *GetJoinedSuperGroupListReq) String() string { return proto.CompactTextString(m) } func (*GetJoinedSuperGroupListReq) ProtoMessage() {} func (*GetJoinedSuperGroupListReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{48} + return fileDescriptor_group_97564bfcd2811fbb, []int{48} } func (m *GetJoinedSuperGroupListReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJoinedSuperGroupListReq.Unmarshal(m, b) @@ -2089,13 +2088,6 @@ func (m *GetJoinedSuperGroupListReq) XXX_DiscardUnknown() { var xxx_messageInfo_GetJoinedSuperGroupListReq proto.InternalMessageInfo -func (m *GetJoinedSuperGroupListReq) GetPagination() *sdk_ws.RequestPagination { - if m != nil { - return m.Pagination - } - return nil -} - func (m *GetJoinedSuperGroupListReq) GetUserID() string { if m != nil { return m.UserID @@ -2104,8 +2096,7 @@ func (m *GetJoinedSuperGroupListReq) GetUserID() string { } type GetJoinedSuperGroupListResp struct { - Total int32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"` - Groups []*sdk_ws.GroupInfo `protobuf:"bytes,2,rep,name=groups" json:"groups,omitempty"` + Groups []*sdk_ws.GroupInfo `protobuf:"bytes,1,rep,name=groups" json:"groups,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -2115,7 +2106,7 @@ func (m *GetJoinedSuperGroupListResp) Reset() { *m = GetJoinedSuperGroup func (m *GetJoinedSuperGroupListResp) String() string { return proto.CompactTextString(m) } func (*GetJoinedSuperGroupListResp) ProtoMessage() {} func (*GetJoinedSuperGroupListResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{49} + return fileDescriptor_group_97564bfcd2811fbb, []int{49} } func (m *GetJoinedSuperGroupListResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJoinedSuperGroupListResp.Unmarshal(m, b) @@ -2135,13 +2126,6 @@ func (m *GetJoinedSuperGroupListResp) XXX_DiscardUnknown() { var xxx_messageInfo_GetJoinedSuperGroupListResp proto.InternalMessageInfo -func (m *GetJoinedSuperGroupListResp) GetTotal() int32 { - if m != nil { - return m.Total - } - return 0 -} - func (m *GetJoinedSuperGroupListResp) GetGroups() []*sdk_ws.GroupInfo { if m != nil { return m.Groups @@ -2160,7 +2144,7 @@ func (m *GetSuperGroupsInfoReq) Reset() { *m = GetSuperGroupsInfoReq{} } func (m *GetSuperGroupsInfoReq) String() string { return proto.CompactTextString(m) } func (*GetSuperGroupsInfoReq) ProtoMessage() {} func (*GetSuperGroupsInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{50} + return fileDescriptor_group_97564bfcd2811fbb, []int{50} } func (m *GetSuperGroupsInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSuperGroupsInfoReq.Unmarshal(m, b) @@ -2198,7 +2182,7 @@ func (m *GetSuperGroupsInfoResp) Reset() { *m = GetSuperGroupsInfoResp{} func (m *GetSuperGroupsInfoResp) String() string { return proto.CompactTextString(m) } func (*GetSuperGroupsInfoResp) ProtoMessage() {} func (*GetSuperGroupsInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{51} + return fileDescriptor_group_97564bfcd2811fbb, []int{51} } func (m *GetSuperGroupsInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetSuperGroupsInfoResp.Unmarshal(m, b) @@ -2241,7 +2225,7 @@ func (m *SetGroupMemberInfoReq) Reset() { *m = SetGroupMemberInfoReq{} } func (m *SetGroupMemberInfoReq) String() string { return proto.CompactTextString(m) } func (*SetGroupMemberInfoReq) ProtoMessage() {} func (*SetGroupMemberInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{52} + return fileDescriptor_group_97564bfcd2811fbb, []int{52} } func (m *SetGroupMemberInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupMemberInfoReq.Unmarshal(m, b) @@ -2313,7 +2297,7 @@ func (m *SetGroupMemberInfoResp) Reset() { *m = SetGroupMemberInfoResp{} func (m *SetGroupMemberInfoResp) String() string { return proto.CompactTextString(m) } func (*SetGroupMemberInfoResp) ProtoMessage() {} func (*SetGroupMemberInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{53} + return fileDescriptor_group_97564bfcd2811fbb, []int{53} } func (m *SetGroupMemberInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SetGroupMemberInfoResp.Unmarshal(m, b) @@ -2344,7 +2328,7 @@ func (m *GetGroupAbstractInfoReq) Reset() { *m = GetGroupAbstractInfoReq func (m *GetGroupAbstractInfoReq) String() string { return proto.CompactTextString(m) } func (*GetGroupAbstractInfoReq) ProtoMessage() {} func (*GetGroupAbstractInfoReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{54} + return fileDescriptor_group_97564bfcd2811fbb, []int{54} } func (m *GetGroupAbstractInfoReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupAbstractInfoReq.Unmarshal(m, b) @@ -2373,7 +2357,7 @@ func (m *GetGroupAbstractInfoReq) GetGroupIDs() []string { type GroupAbstractInfo struct { GroupID string `protobuf:"bytes,1,opt,name=groupID" json:"groupID,omitempty"` - GroupMemberNumber int32 `protobuf:"varint,2,opt,name=groupMemberNumber" json:"groupMemberNumber,omitempty"` + GroupMemberNumber uint32 `protobuf:"varint,2,opt,name=groupMemberNumber" json:"groupMemberNumber,omitempty"` GroupMemberListHash uint64 `protobuf:"varint,3,opt,name=groupMemberListHash" json:"groupMemberListHash,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -2384,7 +2368,7 @@ func (m *GroupAbstractInfo) Reset() { *m = GroupAbstractInfo{} } func (m *GroupAbstractInfo) String() string { return proto.CompactTextString(m) } func (*GroupAbstractInfo) ProtoMessage() {} func (*GroupAbstractInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{55} + return fileDescriptor_group_97564bfcd2811fbb, []int{55} } func (m *GroupAbstractInfo) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GroupAbstractInfo.Unmarshal(m, b) @@ -2411,7 +2395,7 @@ func (m *GroupAbstractInfo) GetGroupID() string { return "" } -func (m *GroupAbstractInfo) GetGroupMemberNumber() int32 { +func (m *GroupAbstractInfo) GetGroupMemberNumber() uint32 { if m != nil { return m.GroupMemberNumber } @@ -2436,7 +2420,7 @@ func (m *GetGroupAbstractInfoResp) Reset() { *m = GetGroupAbstractInfoRe func (m *GetGroupAbstractInfoResp) String() string { return proto.CompactTextString(m) } func (*GetGroupAbstractInfoResp) ProtoMessage() {} func (*GetGroupAbstractInfoResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{56} + return fileDescriptor_group_97564bfcd2811fbb, []int{56} } func (m *GetGroupAbstractInfoResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetGroupAbstractInfoResp.Unmarshal(m, b) @@ -2475,7 +2459,7 @@ func (m *GetUserInGroupMembersReq) Reset() { *m = GetUserInGroupMembersR func (m *GetUserInGroupMembersReq) String() string { return proto.CompactTextString(m) } func (*GetUserInGroupMembersReq) ProtoMessage() {} func (*GetUserInGroupMembersReq) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{57} + return fileDescriptor_group_97564bfcd2811fbb, []int{57} } func (m *GetUserInGroupMembersReq) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetUserInGroupMembersReq.Unmarshal(m, b) @@ -2520,7 +2504,7 @@ func (m *GetUserInGroupMembersResp) Reset() { *m = GetUserInGroupMembers func (m *GetUserInGroupMembersResp) String() string { return proto.CompactTextString(m) } func (*GetUserInGroupMembersResp) ProtoMessage() {} func (*GetUserInGroupMembersResp) Descriptor() ([]byte, []int) { - return fileDescriptor_group_d88c7f5350508ce3, []int{58} + return fileDescriptor_group_97564bfcd2811fbb, []int{58} } func (m *GetUserInGroupMembersResp) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetUserInGroupMembersResp.Unmarshal(m, b) @@ -3158,7 +3142,7 @@ func _Group_GetGroupMemberList_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/group.group/FindGroupMemberAll", + FullMethod: "/group.group/GetGroupMemberList", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GroupServer).GetGroupMemberList(ctx, req.(*GetGroupMemberListReq)) @@ -3212,7 +3196,7 @@ func _Group_GetJoinedGroupList_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/group.group/FindJoinedGroup", + FullMethod: "/group.group/GetJoinedGroupList", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GroupServer).GetJoinedGroupList(ctx, req.(*GetJoinedGroupListReq)) @@ -3589,123 +3573,121 @@ var _Group_serviceDesc = grpc.ServiceDesc{ Metadata: "group/group.proto", } -func init() { proto.RegisterFile("group/group.proto", fileDescriptor_group_d88c7f5350508ce3) } +func init() { proto.RegisterFile("group/group.proto", fileDescriptor_group_97564bfcd2811fbb) } -var fileDescriptor_group_d88c7f5350508ce3 = []byte{ - // 1835 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0x5f, 0x53, 0xdc, 0xc8, - 0x11, 0x2f, 0x2d, 0x06, 0x9b, 0x36, 0x1c, 0x30, 0xb0, 0x20, 0x04, 0x06, 0x6e, 0x8e, 0xba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xb5, 0x4a, 0x1d, 0x18, - 0x45, 0x4b, 0x30, 0x19, 0x87, 0xb1, 0xe3, 0xf3, 0xf3, 0x27, 0xed, 0xf4, 0x03, 0xfd, 0x12, 0x66, - 0x5d, 0x11, 0xb0, 0xc9, 0xd1, 0xcc, 0xac, 0x71, 0x7b, 0x6f, 0x56, 0x59, 0x46, 0xf0, 0xd9, 0x79, - 0x29, 0xfc, 0x11, 0xd6, 0x0f, 0x48, 0x9c, 0x28, 0x62, 0x93, 0x2b, 0x8d, 0x05, 0x96, 0x61, 0xaa, - 0x97, 0xea, 0x6d, 0x70, 0xbd, 0xc5, 0x57, 0xc1, 0x32, 0xb5, 0xdb, 0x59, 0x06, 0x7f, 0x84, 0x07, - 0x03, 0x4e, 0xff, 0xae, 0xef, 0xfe, 0x27, 0x03, 0xea, 0xa7, 0x91, 0x13, 0xb0, 0x0b, 0x12, 0x71, - 0xbe, 0x93, 0x24, 0xc1, 0x92, 0x5b, 0x9b, 0x70, 0x57, 0x84, 0xba, 0xb8, 0x76, 0xf6, 0x89, 0xbe, - 0x84, 0xcf, 0x42, 0xbf, 0x73, 0xa2, 0x24, 0x67, 0xea, 0xcf, 0x02, 0x35, 0xe1, 0x0b, 0xc8, 0x8d, - 0xca, 0x37, 0x91, 0xf2, 0xe5, 0xa9, 0xd8, 0x84, 0x65, 0x9d, 0x0a, 0x8c, 0xe2, 0xbf, 0x19, 0x30, - 0xf3, 0xab, 0xd0, 0x0b, 0x64, 0x59, 0xaa, 0x56, 0x6a, 0x03, 0x20, 0x22, 0x57, 0x4d, 0xc2, 0x98, - 0xe3, 0x92, 0x2c, 0xc0, 0xfa, 0x94, 0x64, 0xfd, 0x5d, 0xe8, 0x05, 0xad, 0xb0, 0x17, 0xb5, 0x09, - 0x57, 0x64, 0xd2, 0x56, 0x28, 0x68, 0x1b, 0x66, 0xbd, 0xe0, 0xda, 0x8b, 0x0b, 0x05, 0x27, 0x4f, - 0xc4, 0x73, 0x30, 0xab, 0xe8, 0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x95, 0x23, 0x30, 0x6b, 0x7b, 0x38, 0x13, 0xa3, 0xe8, 0x05, 0xa0, 0xb8, 0x34, - 0xc8, 0x41, 0xeb, 0x42, 0x56, 0x3b, 0x66, 0xb2, 0x1e, 0x0c, 0x58, 0x65, 0x14, 0xb5, 0xc1, 0x74, - 0x2b, 0x26, 0x18, 0x08, 0xe7, 0x52, 0x4a, 0x3b, 0x7f, 0xb1, 0xbe, 0x18, 0xca, 0x93, 0xea, 0xed, - 0x96, 0x26, 0x07, 0x52, 0x6f, 0xed, 0x94, 0x43, 0xea, 0x5d, 0x31, 0x72, 0x38, 0x85, 0x45, 0xb7, - 0xdc, 0xcc, 0x23, 0xbd, 0x94, 0x8c, 0xb2, 0x8d, 0x41, 0xcb, 0xbc, 0xc0, 0xcc, 0x5d, 0xe6, 0xfb, - 0x6a, 0xb4, 0x2a, 0x44, 0xca, 0xdd, 0xbd, 0x65, 0x55, 0x2d, 0xc9, 0x2b, 0x17, 0x7a, 0x61, 0xf5, - 0xca, 0xe5, 0x2e, 0x5d, 0xbd, 0xb2, 0xae, 0x89, 0x3e, 0x86, 0x05, 0xaf, 0xd8, 0x86, 0xa2, 0x35, - 0x21, 0xa3, 0x6b, 0x89, 0xad, 0xf5, 0xea, 0xc5, 0x34, 0xa9, 0x65, 0x72, 0xca, 0xa4, 0x56, 0xdb, - 0x2a, 0x99, 0xd4, 0xf9, 0xee, 0xa6, 0xe4, 0xcd, 0x04, 0xd3, 0x57, 0x78, 0x53, 0xf4, 0x20, 0x15, - 0xde, 0x94, 0xcd, 0xc0, 0xb7, 0x30, 0xd3, 0x51, 0xd0, 0xb7, 0xcc, 0xf1, 0x02, 0x7e, 0x97, 0x39, - 0x5e, 0x84, 0xea, 0x89, 0xe3, 0xba, 0x79, 0x4c, 0x2b, 0x1d, 0x57, 0x46, 0xce, 0xd2, 0x71, 0x1a, - 0x18, 0x8c, 0x5e, 0x43, 0xbd, 0xad, 0xc3, 0xc8, 0x68, 0x33, 0xab, 0xa9, 0x15, 0x78, 0xdc, 0xda, - 0x1a, 0xcc, 0x90, 0x5a, 0x5c, 0x6a, 0x29, 0x2d, 0xae, 0x62, 0x66, 0x69, 0xf1, 0x1c, 0x30, 0x4e, - 0x6e, 0x57, 0xd0, 0x49, 0xde, 0xae, 0x8c, 0xbb, 0xe5, 0xed, 0x34, 0x10, 0x5b, 0xd4, 0x42, 0x1d, - 0xba, 0x54, 0x6b, 0x61, 0x05, 0xf2, 0x55, 0x6b, 0x61, 0x25, 0x40, 0x4d, 0xa3, 0xa3, 0x80, 0x0f, - 0xd5, 0xe8, 0x28, 0xe3, 0x4d, 0x35, 0x3a, 0x74, 0xc0, 0xf2, 0x0d, 0x2c, 0x33, 0x2d, 0x58, 0x47, - 0x5b, 0x85, 0x9a, 0x5f, 0x6a, 0x1b, 0xac, 0xcf, 0x87, 0x70, 0xa4, 0x1a, 0xb3, 0x12, 0xa4, 0x92, - 0x1a, 0x6b, 0x31, 0xa9, 0xd4, 0x58, 0x8f, 0xc5, 0xd0, 0x6f, 0x61, 0xc9, 0xd5, 0x80, 0x18, 0x54, - 0xac, 0x3f, 0x05, 0xa0, 0x66, 0x6d, 0x0e, 0x5c, 0x4f, 0xa3, 0x53, 0x8b, 0x33, 0x64, 0x74, 0x56, - 0xa1, 0x1a, 0x19, 0x9d, 0x95, 0x30, 0xe5, 0xe9, 0xe6, 0xeb, 0x07, 0x27, 0x94, 0x04, 0x67, 0x87, - 0x4d, 0xe5, 0x1f, 0x9a, 0x5c, 0xe8, 0xe7, 0xfc, 0xf7, 0x7c, 0x8a, 0x93, 0x1e, 0xff, 0x2f, 0x00, - 0x00, 0xff, 0xff, 0xe8, 0xd2, 0xc8, 0xfe, 0x43, 0x1d, 0x00, 0x00, +var fileDescriptor_group_97564bfcd2811fbb = []byte{ + // 1795 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x59, 0xdd, 0x53,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 0x1e, 0x4f, 0x81, 0xd7, 0xe8, 0x74, 0x19, 0x9b, 0xe4, 0xe9, 0xf2, 0xd8, 0x58, 0x9e, + 0xae, 0x00, 0x06, 0x8b, 0xbb, 0xb0, 0x08, 0x47, 0xaa, 0x77, 0x61, 0x09, 0x3a, 0x55, 0xef, 0xc2, + 0x52, 0x28, 0x1a, 0x67, 0x47, 0x06, 0x1f, 0xaa, 0xd9, 0x91, 0xc7, 0x9b, 0x6a, 0x76, 0x14, 0x01, + 0xcb, 0xd7, 0x30, 0xcb, 0x0a, 0x01, 0x35, 0x5a, 0xc9, 0xdc, 0xf9, 0x39, 0x68, 0x6f, 0x5c, 0x1f, + 0xc0, 0x11, 0x5b, 0xcc, 0x72, 0x90, 0x4a, 0x5a, 0x5c, 0x88, 0x49, 0xa5, 0xc5, 0xc5, 0x58, 0x0c, + 0xfd, 0x0f, 0x66, 0xec, 0x02, 0x10, 0x83, 0xb2, 0xf7, 0x4f, 0x06, 0xa8, 0x19, 0xcb, 0x7d, 0xd7, + 0xe3, 0xec, 0x2c, 0xc4, 0x19, 0x32, 0x3b, 0xcb, 0x50, 0x8d, 0xcc, 0xce, 0x52, 0x98, 0xf2, 0x78, + 0xf9, 0xd5, 0xb5, 0x3d, 0x4a, 0xbc, 0xfd, 0xed, 0x86, 0xf2, 0x27, 0x23, 0x17, 0xfa, 0x07, 0xff, + 0x3d, 0x18, 0xe1, 0xa4, 0xbb, 0xbf, 0x05, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x23, 0x51, 0x2e, 0xd7, + 0x1c, 0x00, 0x00, } diff --git a/pkg/proto/group/group.proto b/pkg/proto/group/group.proto index e463419a6..75da6054d 100644 --- a/pkg/proto/group/group.proto +++ b/pkg/proto/group/group.proto @@ -37,17 +37,17 @@ message GetGroupApplicationListReq { string fromUserID = 2; //owner or admin } message GetGroupApplicationListResp { - int32 total = 1; + uint32 total = 1; repeated server_api_params.GroupRequest groupRequests = 2; } message GetUserReqApplicationListReq{ - string userID = 1; - server_api_params.RequestPagination pagination = 2; + server_api_params.RequestPagination pagination = 1; + string userID = 2; } message GetUserReqApplicationListResp{ - int32 total = 1; + uint32 total = 1; repeated server_api_params.GroupRequest groupRequests = 2; } @@ -90,15 +90,14 @@ message QuitGroupResp{ } - message GetGroupMemberListReq { - string groupID = 1; - int32 filter = 2; - server_api_params.RequestPagination pagination = 4; + server_api_params.RequestPagination pagination = 1; + string groupID = 2; + int32 filter = 3; } message GetGroupMemberListResp { - int32 total = 1; + uint32 total = 1; repeated server_api_params.GroupMemberFullInfo members = 2; } @@ -124,11 +123,11 @@ message KickGroupMemberResp { message GetJoinedGroupListReq { - string fromUserID = 1; - server_api_params.RequestPagination pagination = 2; + server_api_params.RequestPagination pagination = 1; + string fromUserID = 2; } message GetJoinedGroupListResp{ - int32 total = 1; + uint32 total = 1; repeated server_api_params.GroupInfo groups = 2; } @@ -144,17 +143,17 @@ message InviteUserToGroupResp { message GetGroupAllMemberReq { - string groupID = 1; - server_api_params.RequestPagination pagination = 2; + server_api_params.RequestPagination pagination = 1; + string groupID = 2; } message GetGroupAllMemberResp { repeated server_api_params.GroupMemberFullInfo members = 1; } message CMSGroup { - server_api_params.GroupInfo groupInfo = 1; - string groupOwnerUserName = 2; - string groupOwnerUserID = 3; + server_api_params.GroupInfo groupInfo = 1; + string groupOwnerUserName = 2; + string groupOwnerUserID = 3; } @@ -165,23 +164,23 @@ message GetGroupsReq { } message GetGroupsResp { - repeated CMSGroup groups = 1; - int32 GroupNum = 2; + uint32 total = 1; + repeated CMSGroup groups = 2; } message GetGroupMemberReq { - string groupID = 1; + string groupID = 1; } message GetGroupMembersCMSReq { - string groupID = 1; - string userName = 2; - server_api_params.RequestPagination pagination = 3; + server_api_params.RequestPagination pagination = 1; + string groupID = 2; + string userName = 3; } message GetGroupMembersCMSResp { - repeated server_api_params.GroupMemberFullInfo members = 1; - int32 memberNums = 2; + uint32 total = 1; + repeated server_api_params.GroupMemberFullInfo members = 2; } message DismissGroupReq{ @@ -240,13 +239,11 @@ message SetGroupMemberNicknameResp{ } message GetJoinedSuperGroupListReq { - server_api_params.RequestPagination pagination = 1; - string userID = 2; + string userID = 1; } message GetJoinedSuperGroupListResp { - int32 total = 1; - repeated server_api_params.GroupInfo groups = 2; + repeated server_api_params.GroupInfo groups = 1; } message GetSuperGroupsInfoReq { @@ -271,12 +268,12 @@ message SetGroupMemberInfoResp{ } message GetGroupAbstractInfoReq{ - repeated string groupIDs = 1; + repeated string groupIDs = 1; } message GroupAbstractInfo{ string groupID = 1; - int32 groupMemberNumber = 2; + uint32 groupMemberNumber = 2; uint64 groupMemberListHash = 3; } diff --git a/pkg/utils/utils_v2.go b/pkg/utils/utils_v2.go index 76d3946f8..c01103bfa 100644 --- a/pkg/utils/utils_v2.go +++ b/pkg/utils/utils_v2.go @@ -322,6 +322,10 @@ func If[T any](isa bool, a, b T) T { return b } +func ToPtr[T any](t T) *T { + return &t +} + // Equal 比较切片是否相对(包括元素顺序) func Equal[E comparable](a []E, b []E) bool { if len(a) != len(b) {