mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
fix: fix GetGroupMembers by nickname
This commit is contained in:
parent
9161900159
commit
94ddb599e0
2
go.mod
2
go.mod
@ -157,4 +157,4 @@ require (
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/OpenIMSDK/protocol v0.0.40 => github.com/luhaoling/protocol v0.0.0-20231227065745-2da7af05f28f
|
||||
replace github.com/OpenIMSDK/protocol v0.0.40 => github.com/luhaoling/protocol v0.0.0-20231227092407-35eebd12dae4
|
||||
|
||||
4
go.sum
4
go.sum
@ -225,8 +225,8 @@ github.com/lestrrat-go/strftime v1.0.6 h1:CFGsDEt1pOpFNU+TJB0nhz9jl+K0hZSLE205Ah
|
||||
github.com/lestrrat-go/strftime v1.0.6/go.mod h1:f7jQKgV5nnJpYgdEasS+/y7EsTb8ykN2z68n3TtcTaw=
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w=
|
||||
github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w=
|
||||
github.com/luhaoling/protocol v0.0.0-20231227065745-2da7af05f28f h1:9za3P48p3EvmnkOC40fVdGo2s2kntpSzuP6GVs9eIZo=
|
||||
github.com/luhaoling/protocol v0.0.0-20231227065745-2da7af05f28f/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||
github.com/luhaoling/protocol v0.0.0-20231227092407-35eebd12dae4 h1:UaoHGQWYrsR/02h6UFrrP59mEzkhfzrYYO+nVKDVy+A=
|
||||
github.com/luhaoling/protocol v0.0.0-20231227092407-35eebd12dae4/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
|
||||
|
||||
@ -476,7 +476,16 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGro
|
||||
|
||||
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbgroup.GetGroupMemberListReq) (*pbgroup.GetGroupMemberListResp, error) {
|
||||
resp := &pbgroup.GetGroupMemberListResp{}
|
||||
total, members, err := s.db.PageGetGroupMember(ctx, req.GroupID, req.Pagination)
|
||||
var (
|
||||
total int64
|
||||
members []*relationtb.GroupMemberModel
|
||||
err error
|
||||
)
|
||||
if req.GroupNickname == "" {
|
||||
total, members, err = s.db.PageGetGroupMember(ctx, req.GroupID, req.Pagination)
|
||||
} else {
|
||||
total, members, err = s.db.FindGroupMemberByNickname(ctx, req.GroupID, req.GroupNickname, req.Pagination)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@ type GroupDatabase interface {
|
||||
FindGroupMemberUser(ctx context.Context, groupIDs []string, userID string) (groupMembers []*relationtb.GroupMemberModel, err error) // *
|
||||
FindGroupMemberRoleLevels(ctx context.Context, groupID string, roleLevels []int32) (groupMembers []*relationtb.GroupMemberModel, err error) // *
|
||||
FindGroupMemberAll(ctx context.Context, groupID string) (groupMembers []*relationtb.GroupMemberModel, err error) // *
|
||||
FindGroupMemberByNickname(ctx context.Context, groupID string, nickName string, pagination pagination.Pagination) (int64, []*relationtb.GroupMemberModel, error)
|
||||
FindGroupsOwner(ctx context.Context, groupIDs []string) ([]*relationtb.GroupMemberModel, error)
|
||||
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
|
||||
@ -119,6 +120,29 @@ func (g *groupDatabase) FindGroupMemberAll(ctx context.Context, groupID string)
|
||||
return g.cache.GetAllGroupMembersInfo(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *groupDatabase) FindGroupMemberByNickname(ctx context.Context, groupID string, Nickname string, pagination pagination.Pagination) (int64, []*relationtb.GroupMemberModel, error) {
|
||||
members, err := g.cache.GetAllGroupMembersInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
var total int64
|
||||
groupMembers := make([]*relationtb.GroupMemberModel, 0)
|
||||
for _, member := range members {
|
||||
if member.Nickname == Nickname {
|
||||
groupMembers = append(groupMembers, member)
|
||||
total++
|
||||
}
|
||||
}
|
||||
|
||||
GMembers := utils.Paginate(groupMembers, int(pagination.GetPageNumber()), int(pagination.GetShowNumber()))
|
||||
if len(GMembers) == 0 {
|
||||
return int64(len(groupMembers)), nil, nil
|
||||
}
|
||||
|
||||
return total, GMembers, nil
|
||||
}
|
||||
|
||||
func (g *groupDatabase) FindGroupsOwner(ctx context.Context, groupIDs []string) ([]*relationtb.GroupMemberModel, error) {
|
||||
return g.cache.GetGroupsOwner(ctx, groupIDs)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user