|
@@ -5,6 +5,7 @@ import ( |
|
|
"database/sql" |
|
|
"database/sql" |
|
|
"errors" |
|
|
"errors" |
|
|
"gim/internal/business/comm/utils" |
|
|
"gim/internal/business/comm/utils" |
|
|
|
|
|
repo2 "gim/internal/business/domain/user/repo" |
|
|
"gim/internal/logic/domain/group/model" |
|
|
"gim/internal/logic/domain/group/model" |
|
|
"gim/internal/logic/domain/group/repo" |
|
|
"gim/internal/logic/domain/group/repo" |
|
|
"gim/pkg/db" |
|
|
"gim/pkg/db" |
|
@@ -129,11 +130,23 @@ func (*groupApp) Update(ctx context.Context, userId int64, update *pb.UpdateGrou |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// AddMembers 添加群组成员 |
|
|
// AddMembers 添加群组成员 |
|
|
func (*groupApp) AddMembers(ctx context.Context, userId, groupId int64, userIds []int64) ([]int64, error) { |
|
|
|
|
|
|
|
|
func (*groupApp) AddMembers(ctx context.Context, userId, groupId int64, userIds []int64, masterId string) ([]int64, error) { |
|
|
group, err := repo.GroupRepo.Get(groupId) |
|
|
group, err := repo.GroupRepo.Get(groupId) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
master, err := repo2.MasterRepo.Get(utils.StrToInt64(masterId)) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
imPackage, err := repo2.ImPackageRepo.Get(master.PackageId) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
if imPackage.GroupNum <= int64(group.UserNum) { |
|
|
|
|
|
return nil, errors.New("群人员数量已满!") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
existIds, addedIds, err := group.AddMembers(ctx, userIds) |
|
|
existIds, addedIds, err := group.AddMembers(ctx, userIds) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|