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
adfd5e2f
Commit
adfd5e2f
authored
May 31, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询会话的最后一条消息;获取加入的所有会话
parent
96cac575
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
136 additions
and
61 deletions
+136
-61
common/src/main/java/com/wecloud/im/constant/Constant.java
+0
-14
common/src/main/java/com/wecloud/im/entity/ImApplication.java
+11
-0
common/src/main/java/com/wecloud/im/entity/ImClient.java
+5
-6
common/src/main/java/com/wecloud/im/mapper/ImMessageMapper.java
+18
-0
common/src/main/java/com/wecloud/im/param/ImMsgReceivedUpdate.java
+1
-1
common/src/main/java/com/wecloud/im/service/ImConversationService.java
+6
-0
common/src/main/java/com/wecloud/im/service/ImMessageService.java
+19
-0
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+15
-0
common/src/main/java/com/wecloud/im/service/impl/ImInboxServiceImpl.java
+0
-1
common/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
+11
-0
common/src/main/java/com/wecloud/im/tillo/app_ws/strategy/concrete/ImConcreteReceiveStrategy.java
+1
-1
common/src/main/java/com/wecloud/im/tillo/netty/handler/NettyApiRequest.java
+1
-28
common/src/main/java/com/wecloud/im/vo/MyConversationListVo.java
+4
-0
common/src/main/java/com/wecloud/im/vo/OfflineMsgDto.java
+0
-4
common/src/main/resources/mapper/ImApplicationMapper.xml
+1
-1
common/src/main/resources/mapper/ImClientMapper.xml
+1
-1
common/src/main/resources/mapper/ImMessageMapper.xml
+39
-0
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/jwt/JwtFilter.java
+3
-1
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/service/impl/ShiroLoginServiceImpl.java
+0
-3
No files found.
common/src/main/java/com/wecloud/im/constant/Constant.java
deleted
100644 → 0
View file @
96cac575
package
com
.
wecloud
.
im
.
constant
;
/**
* @ClassName Constant
* @Descripteion 请写点注释吧!
* @Date 2020/10/13 14:08
* @Version 1.0
**/
public
class
Constant
{
/**
* 卓美亚商家ID
*/
public
static
final
Long
MC_ID
=
1L
;
}
common/src/main/java/com/wecloud/im/entity/ImApplication.java
View file @
adfd5e2f
...
...
@@ -45,4 +45,15 @@ public class ImApplication extends BaseEntity {
@ApiModelProperty
(
"app名称"
)
private
String
appName
;
@ApiModelProperty
(
"ios推送证书"
)
private
String
iosPush
;
@ApiModelProperty
(
"安卓推送证书"
)
private
String
androidPush
;
@ApiModelProperty
(
"友盟推送key"
)
private
String
umengKey
;
@ApiModelProperty
(
"友盟推送密钥"
)
private
String
umengSecret
;
}
common/src/main/java/com/wecloud/im/entity/ImClient.java
View file @
adfd5e2f
...
...
@@ -42,13 +42,12 @@ public class ImClient extends BaseEntity {
@ApiModelProperty
(
"可选 自定义属性,供开发者扩展使用。"
)
private
String
attributes
;
@ApiModelProperty
(
"ios推送证书"
)
private
String
iosPushFile
;
@ApiModelProperty
(
"安卓推送证书"
)
private
String
androidPushFile
;
@ApiModelProperty
(
"客户方提供的唯一id"
)
private
String
clientId
;
@ApiModelProperty
(
"设备不想收到推送提醒, 1想, 0不想"
)
private
Integer
valid
;
@ApiModelProperty
(
"设备类型1:ios; 2:android"
)
private
Integer
deviceType
;
}
common/src/main/java/com/wecloud/im/mapper/ImMessageMapper.java
View file @
adfd5e2f
...
...
@@ -57,4 +57,22 @@ public interface ImMessageMapper extends BaseMapper<ImMessage> {
* @return
*/
List
<
OfflineMsgDto
>
getOfflineListByClientAndConversation
(
@Param
(
"clientId"
)
Long
clientId
,
@Param
(
"conversationId"
)
Long
conversationId
);
/**
* 查询会话接收的的最后一条消息
*
* @param clientId
* @param conversationId
* @return
*/
OfflineMsgDto
getReceivedLastMsgByConversationId
(
@Param
(
"clientId"
)
Long
clientId
,
@Param
(
"conversationId"
)
Long
conversationId
);
/**
* 查询会话的最后一条消息
*
* @param conversationId
* @return
*/
OfflineMsgDto
getLastMsgByConversationId
(
@Param
(
"conversationId"
)
Long
conversationId
);
}
common/src/main/java/com/wecloud/im/param/ImMsgReceivedUpdate.java
View file @
adfd5e2f
...
...
@@ -22,7 +22,7 @@ import java.util.List;
public
class
ImMsgReceivedUpdate
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"
可选 邀请加入会话的客户端,如创建单聊,则填入对方的clientId
"
)
@ApiModelProperty
(
"
消息id数组,可以传入单个或多个, 如接收离线消息列表时可以批量修改 则传入多个
"
)
private
List
<
Long
>
msgIds
;
}
common/src/main/java/com/wecloud/im/service/ImConversationService.java
View file @
adfd5e2f
...
...
@@ -77,6 +77,12 @@ public interface ImConversationService extends BaseService<ImConversation> {
*/
List
<
MyConversationListVo
>
getMyImConversationListAndMsgCount
()
throws
Exception
;
/**
* 获取加入的所有会话
*
* @return
* @throws Exception
*/
List
<
ImConversation
>
getMyImConversationList
()
throws
Exception
;
...
...
common/src/main/java/com/wecloud/im/service/ImMessageService.java
View file @
adfd5e2f
...
...
@@ -93,4 +93,23 @@ public interface ImMessageService extends BaseService<ImMessage> {
List
<
OfflineMsgDto
>
getOfflineListByClientAndConversation
(
Long
clientId
,
Long
conversationId
);
/**
* 查询会话接收的最后一条消息
*
* @param clientId
* @param conversationId
* @return
*/
OfflineMsgDto
getReceivedLastMsgByConversationId
(
Long
clientId
,
Long
conversationId
);
/**
* 查询会话的最后一条消息
*
* @param conversationId
* @return
*/
OfflineMsgDto
getLastMsgByConversationId
(
Long
conversationId
);
}
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
adfd5e2f
...
...
@@ -18,8 +18,10 @@ import com.wecloud.im.service.ImApplicationService;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.service.ImConversationMembersService
;
import
com.wecloud.im.service.ImConversationService
;
import
com.wecloud.im.service.ImMessageService
;
import
com.wecloud.im.vo.ImConversationCreateVo
;
import
com.wecloud.im.vo.MyConversationListVo
;
import
com.wecloud.im.vo.OfflineMsgDto
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
io.geekidea.springbootplus.framework.core.pagination.PageInfo
;
...
...
@@ -62,6 +64,9 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
@Autowired
private
ImApplicationService
imApplicationService
;
@Autowired
private
ImMessageService
imMessageService
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
saveImConversation
(
ImConversation
imConversation
)
throws
Exception
{
...
...
@@ -74,6 +79,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
JwtToken
jwtToken
=
(
JwtToken
)
SecurityUtils
.
getSubject
().
getPrincipal
();
// 判断是否已经存在会话
// 两个用户如果已经创建过会话,不能重复创建会话
// 会话id
Long
imConversationId
=
SnowflakeUtil
.
getId
();
...
...
@@ -169,15 +175,24 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
ImClient
client
=
imClientService
.
getClient
();
// 查询用户加入的所有会话 与每个会话的未读条数 成员
List
<
MyConversationListVo
>
myImConversationListAndMsgCount
=
imConversationMapper
.
getMyImConversationListAndMsgCount
(
client
.
getId
());
JsonMapper
jsonMapper
=
new
JsonMapper
();
// 返回的
List
<
MyConversationListVo
>
myImConversationListAndMsgCountNew
=
new
ArrayList
<>();
// 转换json格式
for
(
MyConversationListVo
myconversationlistvo
:
myImConversationListAndMsgCount
)
{
HashMap
attributess
=
jsonMapper
.
readValue
(
myconversationlistvo
.
getAttribute
(),
HashMap
.
class
);
myconversationlistvo
.
setAttributes
(
attributess
);
// 查询会话的最后一条消息
OfflineMsgDto
lastMsg
=
imMessageService
.
getLastMsgByConversationId
(
myconversationlistvo
.
getId
());
myconversationlistvo
.
setLastMsg
(
lastMsg
);
myImConversationListAndMsgCountNew
.
add
(
myconversationlistvo
);
}
return
myImConversationListAndMsgCountNew
;
...
...
common/src/main/java/com/wecloud/im/service/impl/ImInboxServiceImpl.java
View file @
adfd5e2f
...
...
@@ -69,7 +69,6 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
public
ApiResult
<
Boolean
>
updateImMsgReceived
(
ImMsgReceivedUpdate
imMsgReceivedUpdate
)
{
ImClient
client
=
imClientService
.
getClient
();
Long
aLong
=
imInboxMapper
.
updateImMsgReceivedByIds
(
client
.
getId
(),
imMsgReceivedUpdate
.
getMsgIds
());
return
ApiResult
.
ok
();
...
...
common/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
View file @
adfd5e2f
...
...
@@ -131,4 +131,15 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
}
@Override
public
OfflineMsgDto
getReceivedLastMsgByConversationId
(
Long
clientId
,
Long
conversationId
)
{
return
imMessageMapper
.
getReceivedLastMsgByConversationId
(
clientId
,
conversationId
);
}
@Override
public
OfflineMsgDto
getLastMsgByConversationId
(
Long
conversationId
)
{
return
imMessageMapper
.
getLastMsgByConversationId
(
conversationId
);
}
}
common/src/main/java/com/wecloud/im/tillo/app_ws/strategy/concrete/ImConcreteReceiveStrategy.java
View file @
adfd5e2f
...
...
@@ -116,7 +116,7 @@ public class ImConcreteReceiveStrategy extends AbstractReceiveStrategy {
);
if
(
membersList
.
isEmpty
())
{
log
.
error
(
"membersList为空
"
);
log
.
error
(
"membersList为空
,toConversationId:"
+
toConversationId
);
return
;
}
...
...
common/src/main/java/com/wecloud/im/tillo/netty/handler/NettyApiRequest.java
View file @
adfd5e2f
...
...
@@ -3,8 +3,6 @@ package com.wecloud.im.tillo.netty.handler;
import
com.alibaba.fastjson.JSONObject
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
com.wecloud.im.service.ImApplicationService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.tillo.app_ws.WsHandler
;
import
com.wecloud.im.tillo.app_ws.model.WsConstants
;
import
com.wecloud.im.tillo.app_ws.service.MangerChannelService
;
...
...
@@ -21,7 +19,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authc.AuthenticationException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
...
...
@@ -44,18 +41,9 @@ public class NettyApiRequest {
@Resource
private
MangerChannelService
appUserChannelsService
;
@Autowired
private
StringRedisTemplate
redisTemplate
;
@Resource
private
WsHandler
appImHandler
;
@Autowired
private
ImClientService
imClientService
;
@Autowired
private
ImApplicationService
imApplicationService
;
/**
* http请求接收
*
...
...
@@ -103,21 +91,6 @@ public class NettyApiRequest {
String
appKey
=
(
String
)
jsonObject
.
get
(
"appKey"
);
String
clientId
=
(
String
)
jsonObject
.
get
(
CommonConstant
.
CLIENT_ID
);
// 验签token
// ImApplication imApplication = imApplicationService.getOne(new QueryWrapper<ImApplication>().lambda()
// .eq(ImApplication::getAppKey, appKey));
// if (!JwtUtil.verifyToken(token, imApplication.getAppSecret())) {
// log.debug("验签token不通过");
// }
//
// String redisKey = "client:" + appKey + ":" + clientId;
// String redisToken = redisTemplate.opsForValue().get(redisKey);
//
// // 判断token和redis是否一致
// if (!token.equals(redisToken)) {
// log.debug("token和redis不一致");
// }
if
(
StringUtils
.
isBlank
(
token
))
{
throw
new
AuthenticationException
(
"token不能为空"
);
}
...
...
@@ -129,7 +102,7 @@ public class NettyApiRequest {
JwtToken
jwtToken
=
shiroLoginService
.
getTJwtTokenForRedis
(
token
);
if
(
jwtToken
==
null
)
{
log
.
error
(
"jwtToken == null ,token和redis不一致
"
);
log
.
error
(
"jwtToken == null ,token和redis不一致
, clientId:"
+
clientId
+
",token:"
+
token
);
return
;
}
...
...
common/src/main/java/com/wecloud/im/vo/MyConversationListVo.java
View file @
adfd5e2f
...
...
@@ -52,4 +52,7 @@ public class MyConversationListVo implements Serializable {
@ApiModelProperty
(
"成员"
)
private
String
members
;
@ApiModelProperty
(
"会话最后一条消息"
)
private
OfflineMsgDto
lastMsg
;
}
\ No newline at end of file
common/src/main/java/com/wecloud/im/vo/OfflineMsgDto.java
View file @
adfd5e2f
...
...
@@ -25,9 +25,6 @@ public class OfflineMsgDto implements Serializable {
@ApiModelProperty
(
"撤回时间"
)
private
Date
withdrawTime
;
@ApiModelProperty
(
"修改时间"
)
private
Date
updateDate
;
@ApiModelProperty
(
"发送者客户端id"
)
private
String
sender
;
...
...
@@ -45,5 +42,4 @@ public class OfflineMsgDto implements Serializable {
@ApiModelProperty
(
"at他人,传入客户端id数组"
)
private
String
at
;
}
common/src/main/resources/mapper/ImApplicationMapper.xml
View file @
adfd5e2f
...
...
@@ -5,7 +5,7 @@
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id
, create_time, update_time, app_key, app_secret, app_name
, create_time, update_time, app_key, app_secret, app_name
, ios_push, android_push,umeng_key,umeng_secret
</sql>
<select
id=
"getImApplicationById"
resultType=
"com.wecloud.im.param.ImApplicationQueryVo"
>
...
...
common/src/main/resources/mapper/ImClientMapper.xml
View file @
adfd5e2f
...
...
@@ -5,7 +5,7 @@
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id
, create_time, update_time, fk_appid, attributes,
ios_push_file, android_push_file
, create_time, update_time, fk_appid, attributes,
device_type,valid
</sql>
<select
id=
"getImClientById"
resultType=
"com.wecloud.im.param.ImClientQueryVo"
>
...
...
common/src/main/resources/mapper/ImMessageMapper.xml
View file @
adfd5e2f
...
...
@@ -61,5 +61,44 @@
WHERE fk_conversation_id = #{param.conversationId}
ORDER BY `im_message`.`create_time` DESC
</select>
<select
id=
"getReceivedLastMsgByConversationId"
resultType=
"com.wecloud.im.vo.OfflineMsgDto"
>
SELECT im_message.id AS id,
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,
im_message.`at`,
im_message.send_status,
im_message.fk_conversation_id
FROM im_inbox
INNER JOIN im_message ON im_message.id = im_inbox.fk_msg_id
INNER JOIN im_client AS im_client ON im_client.id = im_message.sender
WHERE im_inbox.receiver = #{clientId}
AND im_inbox.fk_conversation_id = #{conversationId}
ORDER BY create_time DESC LIMIT 1
</select>
<select
id=
"getLastMsgByConversationId"
resultType=
"com.wecloud.im.vo.OfflineMsgDto"
>
SELECT im_message.id AS id,
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,
im_message.`at`,
im_message.send_status,
im_message.fk_conversation_id
FROM im_message
INNER JOIN im_client AS im_client ON im_client.id = im_message.sender
WHERE im_message.fk_conversation_id = #{conversationId}
ORDER BY create_time DESC LIMIT 1
</select>
</mapper>
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/jwt/JwtFilter.java
View file @
adfd5e2f
...
...
@@ -73,7 +73,9 @@ public class JwtFilter extends AuthenticatingFilter {
// 从redis 获取jwt数据
JwtToken
jwtToken
=
shiroLoginService
.
getTJwtTokenForRedis
(
token
);
if
(
jwtToken
==
null
)
{
throw
new
AuthenticationException
(
"Redis Token不存在,token:"
+
token
);
}
return
JwtToken
.
build
(
token
,
jwtToken
.
getSalt
(),
jwtToken
.
getExpireSecond
(),
jwtToken
.
getClientId
(),
jwtToken
.
getAppKey
());
}
...
...
framework/src/main/java/io/geekidea/springbootplus/framework/shiro/service/impl/ShiroLoginServiceImpl.java
View file @
adfd5e2f
...
...
@@ -137,9 +137,6 @@ public class ShiroLoginServiceImpl implements ShiroLoginService {
String
tokenMd5
=
DigestUtils
.
md5Hex
(
token
);
jwtTokenRedisVo
=
redisTemplate
.
opsForValue
().
get
(
String
.
format
(
CommonRedisKey
.
LOGIN_TOKEN
,
tokenMd5
));
// boolean redisExpired = sysLoginRedisService.exists(token); // 判断是否存在
if
(
jwtTokenRedisVo
==
null
)
{
throw
new
AuthenticationException
(
"Redis Token不存在,token:"
+
token
);
}
}
return
(
JwtToken
)
jwtTokenRedisVo
;
}
...
...
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