Browse Source

update

master
DengBiao 1 year ago
parent
commit
d73001a111
3 changed files with 21 additions and 4 deletions
  1. +2
    -2
      internal/business/domain/user/repo/im_package_repo.go
  2. +5
    -1
      internal/logic/api/logic_ext.go
  3. +14
    -1
      internal/logic/app/group_app.go

+ 2
- 2
internal/business/domain/user/repo/im_package_repo.go View File

@@ -9,8 +9,8 @@ type imPackageRepo struct{}
var ImPackageRepo = new(imPackageRepo)

// Get 获取单个套餐包
func (*imPackageRepo) Get(masterId int64) (*model.ImPackage, error) {
imPackage, err := ImPackageDao.Get(masterId)
func (*imPackageRepo) Get(id int64) (*model.ImPackage, error) {
imPackage, err := ImPackageDao.Get(id)
if err != nil {
return nil, err
}


+ 5
- 1
internal/logic/api/logic_ext.go View File

@@ -250,8 +250,12 @@ func (s *LogicExtServer) AddGroupMembers(ctx context.Context, in *pb.AddGroupMem
if err != nil {
return nil, err
}
masterId, err := grpclib.GetCtxMasterId(ctx)
if err != nil {
return nil, err
}

userIds, err := app.GroupApp.AddMembers(ctx, userId, in.GroupId, in.UserIds)
userIds, err := app.GroupApp.AddMembers(ctx, userId, in.GroupId, in.UserIds, masterId)
return &pb.AddGroupMembersResp{UserIds: userIds}, err
}



+ 14
- 1
internal/logic/app/group_app.go View File

@@ -5,6 +5,7 @@ import (
"database/sql"
"errors"
"gim/internal/business/comm/utils"
repo2 "gim/internal/business/domain/user/repo"
"gim/internal/logic/domain/group/model"
"gim/internal/logic/domain/group/repo"
"gim/pkg/db"
@@ -129,11 +130,23 @@ func (*groupApp) Update(ctx context.Context, userId int64, update *pb.UpdateGrou
}

// 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)
if err != nil {
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)
if err != nil {
return nil, err


Loading…
Cancel
Save