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
484419c1
Commit
484419c1
authored
May 19, 2022
by
李晓钟
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/feature-cluster' into feature-cluster
parents
725f718b
828cb060
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
1 deletions
+76
-1
core/src/main/java/com/wecloud/im/action/MessageAction.java
+14
-0
core/src/main/java/com/wecloud/im/mapper/ImMessageMapper.java
+2
-0
core/src/main/java/com/wecloud/im/netty/core/WsReadHandler.java
+1
-1
core/src/main/java/com/wecloud/im/service/ImMessageService.java
+9
-0
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
+9
-0
core/src/main/java/com/wecloud/im/ws/manager/ChannelManager.java
+5
-0
core/src/main/resources/mapper/ImMessageMapper.xml
+36
-0
No files found.
core/src/main/java/com/wecloud/im/action/MessageAction.java
View file @
484419c1
...
@@ -100,6 +100,20 @@ public class MessageAction {
...
@@ -100,6 +100,20 @@ public class MessageAction {
}
}
/**
/**
* 查询某个会话历史消息分页列表
* @param request
* @param param
* @param reqId
* @return
*/
@ActionMapping
(
"/getHistoryMsgNew"
)
@ApiOperation
(
"查询某个会话历史消息分页列表-新"
)
public
WsResponse
<
Paging
<
OfflineMsgDto
>>
getHistoryMsgNew
(
ImHistoryMessagePageParam
data
)
{
log
.
info
(
"查询某个会话历史消息分页列表-新:{}"
,
JSON
.
toJSONString
(
data
));
return
WsResponse
.
ok
(
imMessageService
.
getHistoryMsgConversationIdNew
(
data
));
}
/**
* 查询某个消息已读client列表和未读client
* 查询某个消息已读client列表和未读client
* @param request
* @param request
* @param param
* @param param
...
...
core/src/main/java/com/wecloud/im/mapper/ImMessageMapper.java
View file @
484419c1
...
@@ -51,6 +51,8 @@ public interface ImMessageMapper extends BaseMapper<ImMessage> {
...
@@ -51,6 +51,8 @@ public interface ImMessageMapper extends BaseMapper<ImMessage> {
*/
*/
IPage
<
OfflineMsgDto
>
getHistoryMsgConversationId
(
@Param
(
"page"
)
Page
page
,
@Param
(
"param"
)
ImHistoryMessagePageParam
imHistoryMessagePageParam
);
IPage
<
OfflineMsgDto
>
getHistoryMsgConversationId
(
@Param
(
"page"
)
Page
page
,
@Param
(
"param"
)
ImHistoryMessagePageParam
imHistoryMessagePageParam
);
IPage
<
OfflineMsgDto
>
getHistoryMsgConversationIdNew
(
@Param
(
"page"
)
Page
page
,
@Param
(
"param"
)
ImHistoryMessagePageParam
imHistoryMessagePageParam
);
/**
/**
* 根据客户端id与会话id 查询离线消息
* 根据客户端id与会话id 查询离线消息
*
*
...
...
core/src/main/java/com/wecloud/im/netty/core/WsReadHandler.java
View file @
484419c1
...
@@ -145,7 +145,7 @@ public class WsReadHandler extends SimpleChannelInboundHandler<TextWebSocketFram
...
@@ -145,7 +145,7 @@ public class WsReadHandler extends SimpleChannelInboundHandler<TextWebSocketFram
Long
clientId
=
ctx
.
channel
().
attr
(
ChannelManager
.
CLIENT_ID
).
get
();
Long
clientId
=
ctx
.
channel
().
attr
(
ChannelManager
.
CLIENT_ID
).
get
();
Integer
platform
=
ctx
.
channel
().
attr
(
ChannelManager
.
PLATFORM
).
get
();
Integer
platform
=
ctx
.
channel
().
attr
(
ChannelManager
.
PLATFORM
).
get
();
log
.
info
(
"
CLIENT_ID:{}, handlerRemoved. channelId is {}"
,
clientId
,
ctx
.
channel
().
id
().
asLongText
());
log
.
info
(
"
appId: {} platform: {} CLIENT_ID:{}, handlerRemoved. channelId is {}"
,
appId
,
platform
,
clientId
,
ctx
.
channel
().
id
().
asLongText
());
// 关掉连接
// 关掉连接
channelManager
.
offline
(
clientId
,
platform
,
ctx
);
channelManager
.
offline
(
clientId
,
platform
,
ctx
);
...
...
core/src/main/java/com/wecloud/im/service/ImMessageService.java
View file @
484419c1
...
@@ -86,6 +86,15 @@ public interface ImMessageService extends BaseService<ImMessage> {
...
@@ -86,6 +86,15 @@ public interface ImMessageService extends BaseService<ImMessage> {
Paging
<
OfflineMsgDto
>
getHistoryMsgConversationId
(
ImHistoryMessagePageParam
param
);
Paging
<
OfflineMsgDto
>
getHistoryMsgConversationId
(
ImHistoryMessagePageParam
param
);
/**
/**
* 查询某个会话历史消息分页列表
*
* @param param
* @return
* @throws Exception
*/
Paging
<
OfflineMsgDto
>
getHistoryMsgConversationIdNew
(
ImHistoryMessagePageParam
param
);
/**
* 查询用户所有离线消息
* 查询用户所有离线消息
*
*
* @return
* @return
...
...
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
View file @
484419c1
...
@@ -488,6 +488,15 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
...
@@ -488,6 +488,15 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
return
new
Paging
<>(
iPage
);
return
new
Paging
<>(
iPage
);
}
}
@Override
public
Paging
<
OfflineMsgDto
>
getHistoryMsgConversationIdNew
(
ImHistoryMessagePageParam
param
)
{
Page
<
ImMessage
>
page
=
new
PageInfo
<>(
param
,
OrderItem
.
desc
(
getLambdaColumn
(
ImMessage:
:
getCreateTime
)));
ImClient
currentClient
=
imClientService
.
getCurrentClient
();
param
.
setCurrentFkClientId
(
currentClient
.
getId
());
IPage
<
OfflineMsgDto
>
iPage
=
imMessageMapper
.
getHistoryMsgConversationIdNew
(
page
,
param
);
return
new
Paging
<>(
iPage
);
}
/**
/**
...
...
core/src/main/java/com/wecloud/im/ws/manager/ChannelManager.java
View file @
484419c1
package
com
.
wecloud
.
im
.
ws
.
manager
;
package
com
.
wecloud
.
im
.
ws
.
manager
;
import
com.alibaba.fastjson.JSON
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.netty.channel.socket.nio.NioSocketChannel
;
import
io.netty.util.AttributeKey
;
import
io.netty.util.AttributeKey
;
...
@@ -60,6 +61,7 @@ public class ChannelManager {
...
@@ -60,6 +61,7 @@ public class ChannelManager {
*/
*/
public
void
online
(
Long
clientId
,
Integer
platform
,
NioSocketChannel
channel
)
{
public
void
online
(
Long
clientId
,
Integer
platform
,
NioSocketChannel
channel
)
{
String
longChannelId
=
channel
.
id
().
asLongText
();
String
longChannelId
=
channel
.
id
().
asLongText
();
log
.
info
(
"保存本地连接clientId {} platform {}"
,
clientId
,
platform
);
this
.
putSessionInfoMap
(
clientId
,
platform
,
channel
);
this
.
putSessionInfoMap
(
clientId
,
platform
,
channel
);
UserStateListener
.
triggerOnlineEvent
(
clientId
,
platform
,
longChannelId
);
UserStateListener
.
triggerOnlineEvent
(
clientId
,
platform
,
longChannelId
);
...
@@ -96,11 +98,14 @@ public class ChannelManager {
...
@@ -96,11 +98,14 @@ public class ChannelManager {
clientInfo
.
setDeviceId
(
""
);
clientInfo
.
setDeviceId
(
""
);
clientInfo
.
setNioSocketChannel
(
channel
);
clientInfo
.
setNioSocketChannel
(
channel
);
clientInfo
.
setToken
(
""
);
clientInfo
.
setToken
(
""
);
log
.
info
(
"本地存缓存key {}"
,
genKeyForSessionInfoMap
(
clientId
,
platform
));
ChannelManager
.
SESSION_INFO_MAP
.
put
(
genKeyForSessionInfoMap
(
clientId
,
platform
),
clientInfo
);
ChannelManager
.
SESSION_INFO_MAP
.
put
(
genKeyForSessionInfoMap
(
clientId
,
platform
),
clientInfo
);
}
}
private
void
delSessionInfoMap
(
Long
clientId
,
Integer
platform
)
{
private
void
delSessionInfoMap
(
Long
clientId
,
Integer
platform
)
{
log
.
info
(
"本地清缓存key {}"
,
genKeyForSessionInfoMap
(
clientId
,
platform
));
ChannelManager
.
SESSION_INFO_MAP
.
remove
(
genKeyForSessionInfoMap
(
clientId
,
platform
));
ChannelManager
.
SESSION_INFO_MAP
.
remove
(
genKeyForSessionInfoMap
(
clientId
,
platform
));
log
.
info
(
"删除map后,本地缓存结果 {}"
,
JSON
.
toJSONString
(
ChannelManager
.
SESSION_INFO_MAP
.
get
(
genKeyForSessionInfoMap
(
clientId
,
platform
))));
}
}
}
}
core/src/main/resources/mapper/ImMessageMapper.xml
View file @
484419c1
...
@@ -83,6 +83,42 @@
...
@@ -83,6 +83,42 @@
ORDER BY `im_message`.`create_time` DESC
ORDER BY `im_message`.`create_time` DESC
</select>
</select>
<select
id=
"getHistoryMsgConversationIdNew"
resultType=
"com.wecloud.im.vo.OfflineMsgDto"
>
SELECT im_message.id AS msgId,
im_message.create_time,
im_message.withdraw_time,
im_message.update_date,
`im_client`.client_id AS sender,
im_message.content,
im_message.withdraw,
im_message.`event`,
im_message.system_flag,
im_message.`at`,
im_message.send_status,
im_message.`msg_type` AS 'type',
im_message.fk_conversation_id as conversationId,
(SELECT COUNT(id) FROM im_inbox WHERE fk_msg_id = msgId AND read_msg_status = 0) AS not_read_count,
(SELECT COUNT(id)
FROM im_inbox
WHERE fk_msg_id = msgId
AND receiver_msg_status = 0) AS not_receiver_count
FROM `im_message`
INNER JOIN `im_client` ON `im_client`.id = `im_message`.sender
WHERE fk_conversation_id = #{param.conversationId} and im_message.is_delete = 1 and im_message.withdraw = 0
and (im_message.`event`=0 || (im_message.`event`=1 and sender != #{param.currentFkClientId} ))
<if
test=
"param.msgIdStart != null"
>
AND im_message.id > #{param.msgIdStart}
</if>
<if
test=
"param.msgIdEnd != null"
>
AND im_message.id
<![CDATA[ <= ]]>
#{param.msgIdEnd}
</if>
ORDER BY `im_message`.`create_time` DESC
</select>
<select
id=
"getReceivedLastMsgByConversationId"
resultType=
"com.wecloud.im.vo.OfflineMsgDto"
>
<select
id=
"getReceivedLastMsgByConversationId"
resultType=
"com.wecloud.im.vo.OfflineMsgDto"
>
SELECT im_message.id AS msgId,
SELECT im_message.id AS msgId,
...
...
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