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
90504097
Commit
90504097
authored
Oct 12, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会话列表
parent
3d865a7b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
11 deletions
+19
-11
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+2
-3
core/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
+1
-1
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+11
-5
core/src/main/resources/mapper/ImConversationMapper.xml
+5
-2
No files found.
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
90504097
...
@@ -103,7 +103,6 @@ public class NormalChatAction {
...
@@ -103,7 +103,6 @@ public class NormalChatAction {
}
}
// 查询发送者client
// 查询发送者client
ImClient
imClientSender
=
ehcacheService
.
getEhCacheClient
(
request
.
getSenderClientId
());
ImClient
imClientSender
=
ehcacheService
.
getEhCacheClient
(
request
.
getSenderClientId
());
log
.
info
(
"imClientSender {}"
,
JSON
.
toJSONString
(
imClientSender
));
if
(
imClientSender
==
null
)
{
if
(
imClientSender
==
null
)
{
log
.
warn
(
"根据senderClientId: {} 查找不到 imClientSender!"
,
request
.
getSenderClientId
());
log
.
warn
(
"根据senderClientId: {} 查找不到 imClientSender!"
,
request
.
getSenderClientId
());
return
;
return
;
...
@@ -128,8 +127,8 @@ public class NormalChatAction {
...
@@ -128,8 +127,8 @@ public class NormalChatAction {
}
}
Map
<
Long
,
ImConversationMembers
>
memberMap
=
membersList
.
stream
().
collect
(
Collectors
.
toMap
(
ImConversationMembers:
:
getFkClientId
,
member
->
member
));
Map
<
Long
,
ImConversationMembers
>
memberMap
=
membersList
.
stream
().
collect
(
Collectors
.
toMap
(
ImConversationMembers:
:
getFkClientId
,
member
->
member
));
// 判断为单聊
// 判断为单聊
只能用成员数量来判断,不可用枚举,还需考虑系统消息,临时消息等
if
(
ChatTypeEnum
.
SINGLE
.
getCode
().
equals
(
conversation
.
getChatType
())
||
ChatTypeEnum
.
TEMP
.
getCode
().
equals
(
conversation
.
getChatType
())
)
{
if
(
membersList
.
size
()
==
2
)
{
// 判断是否被拉黑逻辑
// 判断是否被拉黑逻辑
if
(
black
(
reqId
,
imClientSender
,
membersList
,
request
.
getSenderChannel
()))
{
if
(
black
(
reqId
,
imClientSender
,
membersList
,
request
.
getSenderChannel
()))
{
return
;
return
;
...
...
core/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
View file @
90504097
...
@@ -48,7 +48,7 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
...
@@ -48,7 +48,7 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
* @param currentClientId
* @param currentClientId
* @return
* @return
*/
*/
List
<
ConversationVo
>
getMyImConversationListAndMsgCount
(
@Param
(
"currentClientId"
)
Long
currentClientId
,
@Param
(
"conversationId
"
)
Long
conversationId
);
List
<
ConversationVo
>
getMyImConversationListAndMsgCount
(
@Param
(
"currentClientId"
)
Long
currentClientId
,
@Param
(
"conversationId
s"
)
List
<
Long
>
conversationIds
);
/**
/**
* 查询用户加入的所有会话
* 查询用户加入的所有会话
...
...
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
90504097
...
@@ -829,12 +829,16 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -829,12 +829,16 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
try
{
try
{
// 获取当前client
// 获取当前client
ImClient
currentClient
=
contextService
.
getImClientIfNotNullOrThrow
();
ImClient
currentClient
=
contextService
.
getImClientIfNotNullOrThrow
();
// 查询用户加入的所有会话 与每个会话的未读条数 成员
// 查询用户加入的有未读消息的会话列表
List
<
ConversationVo
>
myImConversationListAndMsgCount
=
imConversationMapper
.
getMyImConversationListAndMsgCount
(
currentClient
.
getId
(),
null
);
List
<
ConversationCountVo
>
conversationCountVos
=
inboxService
.
countNotRead
(
currentClient
.
getId
());
List
<
Long
>
conversationIds
=
conversationCountVos
.
stream
().
map
(
ConversationCountVo:
:
getConversationId
).
collect
(
Collectors
.
toList
());;
if
(
CollectionUtils
.
isEmpty
(
conversationIds
))
{
return
Lists
.
newArrayList
();
}
List
<
ConversationVo
>
myImConversationListAndMsgCount
=
imConversationMapper
.
getMyImConversationListAndMsgCount
(
currentClient
.
getId
(),
conversationIds
);
if
(
myImConversationListAndMsgCount
.
isEmpty
())
{
if
(
myImConversationListAndMsgCount
.
isEmpty
())
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
// 根据top进行排序
// 根据top进行排序
List
<
ConversationVo
>
topList
=
myImConversationListAndMsgCount
.
stream
().
filter
(
ConversationVo:
:
getTop
).
collect
(
Collectors
.
toList
());
List
<
ConversationVo
>
topList
=
myImConversationListAndMsgCount
.
stream
().
filter
(
ConversationVo:
:
getTop
).
collect
(
Collectors
.
toList
());
List
<
ConversationVo
>
normalList
=
List
<
ConversationVo
>
normalList
=
...
@@ -845,13 +849,15 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -845,13 +849,15 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
// 最后返回的
// 最后返回的
List
<
ConversationVo
>
conversationListToReturn
=
new
ArrayList
<>();
List
<
ConversationVo
>
conversationListToReturn
=
new
ArrayList
<>();
List
<
ConversationCountVo
>
conversationCountVos
=
inboxService
.
countNotRead
(
currentClient
.
getId
());
// 未读消息map
Map
<
Long
,
Integer
>
notReadMap
=
Maps
.
newHashMap
();
Map
<
Long
,
Integer
>
notReadMap
=
Maps
.
newHashMap
();
if
(
CollectionUtils
.
isNotEmpty
(
conversationCountVos
))
{
if
(
CollectionUtils
.
isNotEmpty
(
conversationCountVos
))
{
for
(
ConversationCountVo
conversationCountVo
:
conversationCountVos
)
{
for
(
ConversationCountVo
conversationCountVo
:
conversationCountVos
)
{
notReadMap
.
put
(
conversationCountVo
.
getConversationId
(),
conversationCountVo
.
getCount
());
notReadMap
.
put
(
conversationCountVo
.
getConversationId
(),
conversationCountVo
.
getCount
());
}
}
}
}
// 被@map
List
<
ConversationCountVo
>
beAtCountVos
=
inboxService
.
countBeAt
(
currentClient
);
List
<
ConversationCountVo
>
beAtCountVos
=
inboxService
.
countBeAt
(
currentClient
);
Map
<
Long
,
Integer
>
beAtCountMap
=
Maps
.
newHashMap
();
Map
<
Long
,
Integer
>
beAtCountMap
=
Maps
.
newHashMap
();
if
(
CollectionUtils
.
isNotEmpty
(
beAtCountVos
))
{
if
(
CollectionUtils
.
isNotEmpty
(
beAtCountVos
))
{
...
@@ -914,7 +920,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -914,7 +920,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
}
}
// 查询用户加入的所有会话 与每个会话的未读条数 成员
// 查询用户加入的所有会话 与每个会话的未读条数 成员
List
<
ConversationVo
>
conversationList
=
imConversationMapper
.
getMyImConversationListAndMsgCount
(
client
.
getId
(),
param
.
getId
(
));
List
<
ConversationVo
>
conversationList
=
imConversationMapper
.
getMyImConversationListAndMsgCount
(
client
.
getId
(),
Lists
.
newArrayList
(
param
.
getId
()
));
if
(
CollectionUtils
.
isEmpty
(
conversationList
))
{
if
(
CollectionUtils
.
isEmpty
(
conversationList
))
{
return
null
;
return
null
;
}
}
...
...
core/src/main/resources/mapper/ImConversationMapper.xml
View file @
90504097
...
@@ -53,8 +53,11 @@
...
@@ -53,8 +53,11 @@
INNER JOIN im_client ON im_client.id = imConversation.creator
INNER JOIN im_client ON im_client.id = imConversation.creator
WHERE imConversationMembers.fk_client_id = #{currentClientId}
WHERE imConversationMembers.fk_client_id = #{currentClientId}
AND imConversationMembers.display_status = 1
AND imConversationMembers.display_status = 1
<if
test=
"conversationId != null"
>
<if
test=
"conversationIds != null and conversationIds.size() > 0"
>
AND imConversation.id = #{conversationId}
AND imConversation.id in
<foreach
collection=
"conversationIds"
item=
"conversationId"
index=
"index"
open=
"("
close=
")"
separator=
","
>
#{conversationId}
</foreach>
</if>
</if>
GROUP BY imConversation.id) t
GROUP BY imConversation.id) t
order by t.update_time desc
order by t.update_time desc
...
...
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