Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
e2cf6616
Commit
e2cf6616
authored
May 17, 2022
by
罗长华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
离开/踢出群组下发消息
parent
ac443330
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
3 deletions
+35
-3
core/src/main/java/com/wecloud/im/controller/ImGroupController.java
+1
-1
core/src/main/java/com/wecloud/im/param/group/LeaveGroupParam.java
+10
-0
core/src/main/java/com/wecloud/im/service/ImGroupService.java
+1
-1
core/src/main/java/com/wecloud/im/service/impl/ImGroupServiceImpl.java
+23
-1
No files found.
core/src/main/java/com/wecloud/im/controller/ImGroupController.java
View file @
e2cf6616
...
...
@@ -85,7 +85,7 @@ public class ImGroupController {
public
ApiResult
<
Integer
>
leaveGroup
(
@RequestBody
LeaveGroupParam
param
)
{
log
.
info
(
"离开群组请求 参数: {}"
,
JSON
.
toJSONString
(
param
));
List
<
String
>
memberIds
=
Arrays
.
asList
(
param
.
getUserIds
().
split
(
","
));
return
ApiResult
.
ok
(
groupService
.
leaveGroup
(
param
.
getGroupId
(),
memberIds
));
return
ApiResult
.
ok
(
groupService
.
leaveGroup
(
param
.
get
OperatorUserId
(),
param
.
get
GroupId
(),
memberIds
));
}
/**
...
...
core/src/main/java/com/wecloud/im/param/group/LeaveGroupParam.java
View file @
e2cf6616
...
...
@@ -2,6 +2,8 @@ package com.wecloud.im.param.group;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
* 离开(踢出)群
* @Author luozh
...
...
@@ -12,12 +14,20 @@ import lombok.Data;
public
class
LeaveGroupParam
{
/**
* 操作人用户id
*/
@NotBlank
(
message
=
"operatorUserId 不能为空"
)
private
String
operatorUserId
;
/**
* 用户Id
*/
@NotBlank
(
message
=
"userIds 不能为空"
)
private
String
userIds
;
/**
* 群组id
*/
@NotBlank
(
message
=
"groupId 不能为空"
)
private
String
groupId
;
}
core/src/main/java/com/wecloud/im/service/ImGroupService.java
View file @
e2cf6616
...
...
@@ -51,7 +51,7 @@ public interface ImGroupService {
* @param memberClientIds
* @Return
*/
Integer
leaveGroup
(
String
groupId
,
List
<
String
>
memberClientIds
);
Integer
leaveGroup
(
String
operatorUserId
,
String
groupId
,
List
<
String
>
memberClientIds
);
/**
* 获取群成员列表
...
...
core/src/main/java/com/wecloud/im/service/impl/ImGroupServiceImpl.java
View file @
e2cf6616
...
...
@@ -246,8 +246,11 @@ public class ImGroupServiceImpl implements ImGroupService {
}
@Override
public
Integer
leaveGroup
(
String
groupId
,
List
<
String
>
memberClientIds
)
{
public
Integer
leaveGroup
(
String
operatorUserId
,
String
groupId
,
List
<
String
>
memberClientIds
)
{
Long
appId
=
SecurityUtils
.
getCurrentAppId
();
ImClient
operator
=
clientService
.
getCacheImClient
(
appId
,
operatorUserId
);
ImApplication
imApplication
=
applicationService
.
getCacheById
(
appId
);
// 查询会话
ImConversation
conversation
=
...
...
@@ -257,6 +260,11 @@ public class ImGroupServiceImpl implements ImGroupService {
throw
new
BusinessException
(
"群组不存在"
);
}
// 查询该会话所有成员
List
<
ImConversationMembers
>
membersList
=
conversationMembersService
.
list
(
new
QueryWrapper
<
ImConversationMembers
>().
lambda
().
eq
(
ImConversationMembers:
:
getFkAppid
,
imApplication
.
getId
()).
eq
(
ImConversationMembers:
:
getFkConversationId
,
conversation
.
getId
()));
// 查找在群组里的客户端
List
<
ImConversationMembers
>
existMemberList
=
conversationMembersService
.
list
(
Wrappers
.<
ImConversationMembers
>
lambdaQuery
()
...
...
@@ -269,6 +277,20 @@ public class ImGroupServiceImpl implements ImGroupService {
// 将群成员数量减
imConversationMapper
.
addMemberCount
(
imApplication
.
getId
(),
conversation
.
getId
(),
-
existMemberList
.
size
());
}
for
(
ImConversationMembers
members
:
existMemberList
)
{
// 操作的client ID
Map
<
String
,
Object
>
content
=
new
HashMap
<>();
content
.
put
(
"operator"
,
operator
.
getClientId
());
// 被操作的client ID
content
.
put
(
"passivityOperator"
,
members
.
getClientId
());
ImMessage
imMessage
=
MessageBuilder
.
buildEventMessage
(
MsgTypeEnum
.
REMOVE_CLIENT_CONVERSATION
,
imApplication
,
operator
,
conversation
,
JsonUtils
.
encodeJson
(
content
));
imMessageService
.
save
(
imMessage
);
// 发送给在群内的成员
conversationService
.
sendMsgToMembers
(
conversation
,
membersList
,
operator
,
imMessage
,
content
);
}
return
existMemberList
.
size
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment