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
4526cd88
Commit
4526cd88
authored
May 10, 2022
by
罗长华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增创建群 解散群 加入群 离开群 群成员列表接口
parent
6ab229e5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
358 additions
and
13 deletions
+358
-13
core/src/main/java/com/wecloud/im/controller/ImGroupController.java
+95
-0
core/src/main/java/com/wecloud/im/param/group/CreateGroupParam.java
+28
-0
core/src/main/java/com/wecloud/im/param/group/DismissGroupParam.java
+24
-0
core/src/main/java/com/wecloud/im/param/group/JoinGroupParam.java
+21
-0
core/src/main/java/com/wecloud/im/param/group/LeaveGroupParam.java
+23
-0
core/src/main/java/com/wecloud/im/param/group/ListGroupMembersParam.java
+21
-0
core/src/main/java/com/wecloud/im/sdk/enums/FriendSourceEnum.java
+8
-13
core/src/main/java/com/wecloud/im/service/ImGroupService.java
+62
-0
core/src/main/java/com/wecloud/im/service/impl/ImGroupServiceImpl.java
+76
-0
No files found.
core/src/main/java/com/wecloud/im/controller/ImGroupController.java
0 → 100644
View file @
4526cd88
package
com
.
wecloud
.
im
.
controller
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.List
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
com.wecloud.im.param.group.CreateGroupParam
;
import
com.wecloud.im.param.group.DismissGroupParam
;
import
com.wecloud.im.param.group.JoinGroupParam
;
import
com.wecloud.im.param.group.LeaveGroupParam
;
import
com.wecloud.im.param.group.ListGroupMembersParam
;
import
com.wecloud.im.service.ImGroupService
;
/**
* 群聊接口
* @Author luozh
* @Date 2022年05月10日 14:14
* @Version 1.0
*/
@AllArgsConstructor
@Slf4j
@RestController
@RequestMapping
(
"/group"
)
public
class
ImGroupController
{
private
final
ImGroupService
groupService
;
/**
* 创建群组
* @Author luozh
* @Date 2022年05月10日 02:16:19
* @Return
*/
@PostMapping
(
"/createGroup"
)
public
ApiResult
<
Long
>
createGroup
(
@RequestBody
CreateGroupParam
param
)
{
log
.
info
(
"创建群组请求 参数: {}"
,
JSON
.
toJSONString
(
param
));
return
null
;
}
/**
* 解散群组
* @Author luozh
* @Date 2022年05月10日 02:16:19
* @Return
*/
@PostMapping
(
"/dismissGroup"
)
public
ApiResult
<
Boolean
>
dismissGroup
(
@RequestBody
DismissGroupParam
param
)
{
log
.
info
(
"解散群组请求 参数: {}"
,
JSON
.
toJSONString
(
param
));
return
null
;
}
/**
* 加入群组
* @Author luozh
* @Date 2022年05月10日 02:16:19
* @Return
*/
@PostMapping
(
"/joinGroup"
)
public
ApiResult
<
Long
>
joinGroup
(
@RequestBody
JoinGroupParam
param
)
{
return
null
;
}
/**
* 离开群组
* @Author luozh
* @Date 2022年05月10日 02:16:19
* @Return
*/
@PostMapping
(
"/leaveGroup"
)
public
ApiResult
<
Long
>
leaveGroup
(
@RequestBody
LeaveGroupParam
param
)
{
log
.
info
(
"离开群组请求 参数: {}"
,
JSON
.
toJSONString
(
param
));
return
null
;
}
/**
*
* @Author luozh
* @Date 2022年05月10日 02:16:19
* @Return
* @return
*/
@PostMapping
(
"/listGroupMembers"
)
public
ApiResult
<
List
<
String
>>
listGroupMembers
(
@RequestBody
ListGroupMembersParam
param
)
{
log
.
info
(
"获取群组成员请求 参数: {}"
,
JSON
.
toJSONString
(
param
));
return
ApiResult
.
ok
(
groupService
.
listGroupMembers
(
param
.
getGroupId
()));
}
}
core/src/main/java/com/wecloud/im/param/group/CreateGroupParam.java
0 → 100644
View file @
4526cd88
package
com
.
wecloud
.
im
.
param
.
group
;
import
lombok.Data
;
/**
* 创建群
* @Author luozh
* @Date 2022年05月10日 09:37
* @Version 1.0
*/
@Data
public
class
CreateGroupParam
{
/**
* 群主id
*/
private
String
userId
;
/**
* 群名
*/
private
String
groupName
;
/**
* 群成员
*/
private
String
memberIds
;
}
core/src/main/java/com/wecloud/im/param/group/DismissGroupParam.java
0 → 100644
View file @
4526cd88
package
com
.
wecloud
.
im
.
param
.
group
;
import
lombok.Data
;
/**
* 解散群
* @Author luozh
* @Date 2022年05月10日 09:37
* @Version 1.0
*/
@Data
public
class
DismissGroupParam
{
/**
* 操作解散群的用户 ID,可以为任何用户 ID ,非群组创建者也可以解散群组
*/
private
String
userId
;
/**
* 要解散的群的群组 ID
*/
private
String
groupId
;
}
core/src/main/java/com/wecloud/im/param/group/JoinGroupParam.java
0 → 100644
View file @
4526cd88
package
com
.
wecloud
.
im
.
param
.
group
;
/**
* 加入群
* @Author luozh
* @Date 2022年05月10日 09:37
* @Version 1.0
*/
public
class
JoinGroupParam
{
/**
* 要加入群的用户 ID
*/
private
String
userIds
;
/**
* 要加入的群的群组 ID
*/
private
String
groupId
;
}
core/src/main/java/com/wecloud/im/param/group/LeaveGroupParam.java
0 → 100644
View file @
4526cd88
package
com
.
wecloud
.
im
.
param
.
group
;
import
lombok.Data
;
/**
* 离开(踢出)群
* @Author luozh
* @Date 2022年05月10日 09:37
* @Version 1.0
*/
@Data
public
class
LeaveGroupParam
{
/**
* 用户Id
*/
private
String
userIds
;
/**
* 群组id
*/
private
String
groupId
;
}
core/src/main/java/com/wecloud/im/param/group/ListGroupMembersParam.java
0 → 100644
View file @
4526cd88
package
com
.
wecloud
.
im
.
param
.
group
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
* 查询群组成员
* @Author luozh
* @Date 2022年05月10日 09:37
* @Version 1.0
*/
@Data
public
class
ListGroupMembersParam
{
/**
* 群id
*/
@NotBlank
(
message
=
"群id不能为空"
)
private
String
groupId
;
}
core/src/main/java/com/wecloud/im/sdk/enums/FriendSourceEnum.java
View file @
4526cd88
...
@@ -7,20 +7,15 @@ package com.wecloud.im.sdk.enums;
...
@@ -7,20 +7,15 @@ package com.wecloud.im.sdk.enums;
*/
*/
public
enum
FriendSourceEnum
{
public
enum
FriendSourceEnum
{
/**
// 名片
* 1 - 搜索
CARD
(
"CARD"
,
"名片"
),
*/
// 二维码
QR_CODE
(
"QR_CODE"
,
"二维码"
),
// SEARCH 搜索
SEARCH
(
"SEARCH"
,
"搜索"
),
SEARCH
(
"SEARCH"
,
"搜索"
),
// 群聊
/**
GROUP_CHAT
(
"GROUP_CHAT"
,
"群聊"
),
* 2 - 群聊
;
*/
GROUP
(
"GROUP"
,
"群聊"
),
/**
* 3 - 名片
*/
CARD
(
"CARD"
,
"名片"
);
FriendSourceEnum
(
String
code
,
String
desc
)
{
FriendSourceEnum
(
String
code
,
String
desc
)
{
this
.
code
=
code
;
this
.
code
=
code
;
...
...
core/src/main/java/com/wecloud/im/service/ImGroupService.java
0 → 100644
View file @
4526cd88
package
com
.
wecloud
.
im
.
service
;
import
java.util.List
;
/**
* 群服务
* @Author luozh
* @Date 2022年05月10日 15:17
* @Version 1.0
*/
public
interface
ImGroupService
{
/**
* 创建群组
* @Author luozh
* @Date 2022年05月10日 03:22:13
* @param groupOwnerUserId
* @param groupName
* @param memberIds
* @Return
*/
Long
createGroup
(
String
groupOwnerUserId
,
String
groupName
,
List
<
String
>
memberIds
);
/**
* 解散群组
* @Author luozh
* @Date 2022年05月10日 03:22:26
* @param userId
* @param groupId
* @Return
*/
Boolean
dismissGroup
(
String
userId
,
String
groupId
);
/**
* 加入群组
* @Author luozh
* @Date 2022年05月10日 03:22:35
* @param groupId
* @param userIds
* @Return
*/
Boolean
joinGroup
(
String
groupId
,
String
userIds
);
/**
* 离开群组
* @Author luozh
* @Date 2022年05月10日 03:22:44
* @param groupId
* @param userIds
* @Return
*/
Boolean
leaveGroup
(
String
groupId
,
String
userIds
);
/**
* 获取群成员列表
* @Author luozh
* @Date 2022年05月10日 03:23:09
* @param groupId
* @Return
*/
List
<
String
>
listGroupMembers
(
String
groupId
);
}
core/src/main/java/com/wecloud/im/service/impl/ImGroupServiceImpl.java
0 → 100644
View file @
4526cd88
package
com
.
wecloud
.
im
.
service
.
impl
;
import
io.geekidea.springbootplus.framework.common.exception.BusinessException
;
import
io.geekidea.springbootplus.framework.shiro.util.SecurityUtils
;
import
lombok.AllArgsConstructor
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.wecloud.im.entity.ImConversation
;
import
com.wecloud.im.entity.ImConversationMembers
;
import
com.wecloud.im.service.ImConversationMembersService
;
import
com.wecloud.im.service.ImConversationService
;
import
com.wecloud.im.service.ImGroupService
;
/**
* 群服务
* @Author luozh
* @Date 2022年05月10日 15:23
* @Version 1.0
*/
@AllArgsConstructor
@Service
public
class
ImGroupServiceImpl
implements
ImGroupService
{
/**
* 会话服务
*/
private
final
ImConversationService
conversationService
;
/**
* 会话成员服务
*/
private
final
ImConversationMembersService
conversationMembersService
;
@Override
public
Long
createGroup
(
String
groupOwnerUserId
,
String
groupName
,
List
<
String
>
memberIds
)
{
return
null
;
}
@Override
public
Boolean
dismissGroup
(
String
userId
,
String
groupId
)
{
return
null
;
}
@Override
public
Boolean
joinGroup
(
String
groupId
,
String
userIds
)
{
return
null
;
}
@Override
public
Boolean
leaveGroup
(
String
groupId
,
String
userIds
)
{
return
null
;
}
@Override
public
List
<
String
>
listGroupMembers
(
String
groupId
)
{
Long
appId
=
SecurityUtils
.
getCurrentAppId
();
// 获取会话
ImConversation
conversation
=
conversationService
.
getOne
(
Wrappers
.<
ImConversation
>
lambdaQuery
()
.
eq
(
ImConversation:
:
getFkAppid
,
appId
)
.
eq
(
ImConversation:
:
getId
,
groupId
));
if
(
conversation
==
null
)
{
throw
new
BusinessException
(
"群组不存在"
);
}
// 获取群成员
List
<
ImConversationMembers
>
membersList
=
conversationMembersService
.
list
(
Wrappers
.<
ImConversationMembers
>
lambdaQuery
().
eq
(
ImConversationMembers:
:
getFkConversationId
,
groupId
));
return
membersList
.
stream
().
map
(
ImConversationMembers:
:
getClientId
).
collect
(
Collectors
.
toList
());
}
}
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