|
|
@ -476,13 +476,42 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGro
|
|
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbgroup.GetGroupMemberListReq) (*pbgroup.GetGroupMemberListResp, error) {
|
|
|
|
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbgroup.GetGroupMemberListReq) (*pbgroup.GetGroupMemberListResp, error) {
|
|
|
|
resp := &pbgroup.GetGroupMemberListResp{}
|
|
|
|
resp := &pbgroup.GetGroupMemberListResp{}
|
|
|
|
total, members, err := s.db.PageGetGroupMember(ctx, req.GroupID, req.Pagination)
|
|
|
|
var (
|
|
|
|
|
|
|
|
total int64
|
|
|
|
|
|
|
|
members []*relationtb.GroupMemberModel
|
|
|
|
|
|
|
|
err error
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
if req.Keyword == "" {
|
|
|
|
|
|
|
|
total, members, err = s.db.PageGetGroupMember(ctx, req.GroupID, req.Pagination)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
members, err = s.db.FindGroupMemberAll(ctx, req.GroupID)
|
|
|
|
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
|
|
|
if err := s.PopulateGroupMember(ctx, members...); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if req.Keyword != "" {
|
|
|
|
|
|
|
|
groupMembers := make([]*relationtb.GroupMemberModel, 0)
|
|
|
|
|
|
|
|
for _, member := range members {
|
|
|
|
|
|
|
|
if member.UserID == req.Keyword {
|
|
|
|
|
|
|
|
groupMembers = append(groupMembers, member)
|
|
|
|
|
|
|
|
total++
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if member.Nickname == req.Keyword {
|
|
|
|
|
|
|
|
groupMembers = append(groupMembers, member)
|
|
|
|
|
|
|
|
total++
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GMembers := utils.Paginate(groupMembers, int(req.Pagination.GetPageNumber()), int(req.Pagination.GetShowNumber()))
|
|
|
|
|
|
|
|
resp.Members = utils.Batch(convert.Db2PbGroupMember, GMembers)
|
|
|
|
|
|
|
|
resp.Total = uint32(total)
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
resp.Total = uint32(total)
|
|
|
|
resp.Total = uint32(total)
|
|
|
|
resp.Members = utils.Batch(convert.Db2PbGroupMember, members)
|
|
|
|
resp.Members = utils.Batch(convert.Db2PbGroupMember, members)
|
|
|
|
return resp, nil
|
|
|
|
return resp, nil
|
|
|
@ -1042,20 +1071,29 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbgroup.Trans
|
|
|
|
func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) (*pbgroup.GetGroupsResp, error) {
|
|
|
|
func (s *groupServer) GetGroups(ctx context.Context, req *pbgroup.GetGroupsReq) (*pbgroup.GetGroupsResp, error) {
|
|
|
|
resp := &pbgroup.GetGroupsResp{}
|
|
|
|
resp := &pbgroup.GetGroupsResp{}
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
groups []*relationtb.GroupModel
|
|
|
|
group []*relationtb.GroupModel
|
|
|
|
err error
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if req.GroupID != "" {
|
|
|
|
if req.GroupID != "" {
|
|
|
|
groups, err = s.db.FindGroup(ctx, []string{req.GroupID})
|
|
|
|
group, err = s.db.FindGroup(ctx, []string{req.GroupID})
|
|
|
|
resp.Total = uint32(len(groups))
|
|
|
|
resp.Total = uint32(len(group))
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var total int64
|
|
|
|
var total int64
|
|
|
|
total, groups, err = s.db.SearchGroup(ctx, req.GroupName, req.Pagination)
|
|
|
|
total, group, err = s.db.SearchGroup(ctx, req.GroupName, req.Pagination)
|
|
|
|
resp.Total = uint32(total)
|
|
|
|
resp.Total = uint32(total)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var groups []*relationtb.GroupModel
|
|
|
|
|
|
|
|
for _, v := range group {
|
|
|
|
|
|
|
|
if v.Status == constant.GroupStatusDismissed {
|
|
|
|
|
|
|
|
resp.Total--
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
groups = append(groups, v)
|
|
|
|
|
|
|
|
}
|
|
|
|
groupIDs := utils.Slice(groups, func(e *relationtb.GroupModel) string {
|
|
|
|
groupIDs := utils.Slice(groups, func(e *relationtb.GroupModel) string {
|
|
|
|
return e.GroupID
|
|
|
|
return e.GroupID
|
|
|
|
})
|
|
|
|
})
|
|
|
|