first commit
This commit is contained in:
42
service/group/logic/group_disband.go
Normal file
42
service/group/logic/group_disband.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
"gitlab.33.cn/chat/dtalk/service/group/service"
|
||||
)
|
||||
|
||||
type GroupDisbandLogic struct {
|
||||
ctx context.Context
|
||||
svc *service.Service
|
||||
}
|
||||
|
||||
func NewGroupDisbandLogic(ctx context.Context, svc *service.Service) *GroupDisbandLogic {
|
||||
return &GroupDisbandLogic{
|
||||
ctx: ctx,
|
||||
svc: svc,
|
||||
}
|
||||
}
|
||||
|
||||
// GroupDisband 解散群
|
||||
func (l *GroupDisbandLogic) GroupDisband(req *pb.GroupDisbandReq) (*pb.GroupDisbandResp, error) {
|
||||
groupId := req.GroupId
|
||||
personId := req.PersonId
|
||||
|
||||
person, err := l.svc.GetPersonByMemberIdAndGroupId(l.ctx, personId, groupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 只有群主可以解散群
|
||||
if err = person.IsOwner(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = l.svc.GroupDisband(l.ctx, groupId, personId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pb.GroupDisbandResp{}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user