|
|
@ -1685,36 +1685,51 @@ func (g *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(requests) == 0 {
|
|
|
|
if len(requests) == 0 {
|
|
|
|
return &pbgroup.GetGroupUsersReqApplicationListResp{}, nil
|
|
|
|
return &pbgroup.GetGroupUsersReqApplicationListResp{}, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
groupIDs := datautil.Distinct(datautil.Slice(requests, func(e *model.GroupRequest) string {
|
|
|
|
groupIDs := datautil.Distinct(datautil.Slice(requests, func(e *model.GroupRequest) string {
|
|
|
|
return e.GroupID
|
|
|
|
return e.GroupID
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
groups, err := g.db.FindGroup(ctx, groupIDs)
|
|
|
|
groups, err := g.db.FindGroup(ctx, groupIDs)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
groupMap := datautil.SliceToMap(groups, func(e *model.Group) string {
|
|
|
|
groupMap := datautil.SliceToMap(groups, func(e *model.Group) string {
|
|
|
|
return e.GroupID
|
|
|
|
return e.GroupID
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if ids := datautil.Single(groupIDs, datautil.Keys(groupMap)); len(ids) > 0 {
|
|
|
|
if ids := datautil.Single(groupIDs, datautil.Keys(groupMap)); len(ids) > 0 {
|
|
|
|
return nil, servererrs.ErrGroupIDNotFound.WrapMsg(strings.Join(ids, ","))
|
|
|
|
return nil, servererrs.ErrGroupIDNotFound.WrapMsg(strings.Join(ids, ","))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userMap, err := g.user.GetPublicUserInfoMap(ctx, req.UserIDs)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
owners, err := g.db.FindGroupsOwner(ctx, groupIDs)
|
|
|
|
owners, err := g.db.FindGroupsOwner(ctx, groupIDs)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := g.PopulateGroupMember(ctx, owners...); err != nil {
|
|
|
|
if err := g.PopulateGroupMember(ctx, owners...); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ownerMap := datautil.SliceToMap(owners, func(e *model.GroupMember) string {
|
|
|
|
ownerMap := datautil.SliceToMap(owners, func(e *model.GroupMember) string {
|
|
|
|
return e.GroupID
|
|
|
|
return e.GroupID
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
groupMemberNum, err := g.db.MapGroupMemberNum(ctx, groupIDs)
|
|
|
|
groupMemberNum, err := g.db.MapGroupMemberNum(ctx, groupIDs)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return &pbgroup.GetGroupUsersReqApplicationListResp{
|
|
|
|
return &pbgroup.GetGroupUsersReqApplicationListResp{
|
|
|
|
Total: int64(len(requests)),
|
|
|
|
Total: int64(len(requests)),
|
|
|
|
GroupRequests: datautil.Slice(requests, func(e *model.GroupRequest) *sdkws.GroupRequest {
|
|
|
|
GroupRequests: datautil.Slice(requests, func(e *model.GroupRequest) *sdkws.GroupRequest {
|
|
|
@ -1722,7 +1737,69 @@ func (g *groupServer) GetGroupUsersReqApplicationList(ctx context.Context, req *
|
|
|
|
if owner, ok := ownerMap[e.GroupID]; ok {
|
|
|
|
if owner, ok := ownerMap[e.GroupID]; ok {
|
|
|
|
ownerUserID = owner.UserID
|
|
|
|
ownerUserID = owner.UserID
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return convert.Db2PbGroupRequest(e, nil, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerUserID, groupMemberNum[e.GroupID]))
|
|
|
|
|
|
|
|
|
|
|
|
var userInfo *sdkws.PublicUserInfo
|
|
|
|
|
|
|
|
if user, ok := userMap[e.UserID]; !ok {
|
|
|
|
|
|
|
|
userInfo = user
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return convert.Db2PbGroupRequest(e, userInfo, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerUserID, groupMemberNum[e.GroupID]))
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
}, nil
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (g *groupServer) GetSpecifiedUserGroupRequestInfo(ctx context.Context, req *pbgroup.GetSpecifiedUserGroupRequestInfoReq) (*pbgroup.GetSpecifiedUserGroupRequestInfoResp, error) {
|
|
|
|
|
|
|
|
opUserID := mcontext.GetOpUserID(ctx)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if req.UserID != opUserID {
|
|
|
|
|
|
|
|
req.UserID = mcontext.GetOpUserID(ctx)
|
|
|
|
|
|
|
|
memberIDs, err := g.db.GetGroupAdminLevelMemberIDs(ctx, req.GroupID)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !datautil.Contain(req.UserID, memberIDs...) {
|
|
|
|
|
|
|
|
return nil, errs.ErrNoPermission.WrapMsg("opUser no permission")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
requests, err := g.db.FindGroupRequests(ctx, req.GroupID, []string{req.UserID})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(requests) == 0 {
|
|
|
|
|
|
|
|
return &pbgroup.GetSpecifiedUserGroupRequestInfoResp{}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
groups, err := g.db.FindGroup(ctx, []string{req.GroupID})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userInfos, err := g.user.GetPublicUserInfos(ctx, []string{req.UserID})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
owners, err := g.db.FindGroupsOwner(ctx, []string{req.GroupID})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
groupMemberNum, err := g.db.MapGroupMemberNum(ctx, []string{req.GroupID})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resp := &pbgroup.GetSpecifiedUserGroupRequestInfoResp{
|
|
|
|
|
|
|
|
GroupRequests: make([]*sdkws.GroupRequest, 0, len(requests)),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, request := range requests {
|
|
|
|
|
|
|
|
resp.GroupRequests = append(resp.GroupRequests, convert.Db2PbGroupRequest(request, userInfos[0], convert.Db2PbGroupInfo(groups[0], owners[0].UserID, groupMemberNum[groups[0].GroupID])))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resp.Total = uint32(len(requests))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
|
|
|
|
}
|
|
|
|