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
b295848f
Commit
b295848f
authored
Oct 26, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
移除旧的设备token: client登陆的时候 判断数据库内是否已经存在这个设备token,如果存在就清空旧的
parent
2cc48e6b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
1 deletions
+44
-1
common/src/main/java/com/wecloud/im/mapper/ImClientMapper.java
+4
-0
common/src/main/java/com/wecloud/im/service/ImClientService.java
+9
-0
common/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
+25
-1
common/src/main/resources/mapper/ImClientMapper.xml
+6
-0
No files found.
common/src/main/java/com/wecloud/im/mapper/ImClientMapper.java
View file @
b295848f
...
...
@@ -37,4 +37,8 @@ public interface ImClientMapper extends BaseMapper<ImClient> {
*/
IPage
<
ImClientQueryVo
>
getImClientPageList
(
@Param
(
"page"
)
Page
page
,
@Param
(
"param"
)
ImClientPageParam
imClientPageParam
);
int
removeOldToken
(
@Param
(
"appId"
)
Long
appId
,
@Param
(
"deviceToken"
)
String
deviceToken
);
}
common/src/main/java/com/wecloud/im/service/ImClientService.java
View file @
b295848f
...
...
@@ -60,6 +60,15 @@ public interface ImClientService extends BaseService<ImClient> {
ImClientQueryVo
getImClientById
(
Long
id
)
throws
Exception
;
/**
* 移除旧的设备token
*
* @param appId
* @param deviceToken
* @return
*/
int
removeOldToken
(
Long
appId
,
String
deviceToken
);
/**
* 获取分页对象
*
* @param imClientPageParam
...
...
common/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
View file @
b295848f
...
...
@@ -51,12 +51,29 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
updateDeviceInfo
(
ImClientDeviceInfoAdd
imClientDevice
)
{
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getOneByAppKey
(
curentJwtToken
.
getAppKey
());
// 清除旧client的redis缓存
ImClient
imClient
=
this
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
imApplication
.
getId
())
.
eq
(
ImClient:
:
getDeviceToken
,
imClientDevice
.
getDeviceToken
()));
if
(
imClient
!=
null
)
{
deleteCacheImClient
(
imClient
.
getFkAppid
(),
imClient
.
getClientId
());
}
// client登陆的时候 判断数据库内是否已经存在这个设备token,如果存在就清空旧的
this
.
removeOldToken
(
imApplication
.
getId
(),
curentJwtToken
.
getToken
());
ImClient
client
=
getCurentClient
();
ImClient
clientNew
=
new
ImClient
();
BeanUtils
.
copyProperties
(
imClientDevice
,
clientNew
);
clientNew
.
setId
(
client
.
getId
());
// 清
楚
缓存
// 清
除新client的redis
缓存
deleteCacheImClient
(
client
.
getFkAppid
(),
client
.
getClientId
());
// 修改
...
...
@@ -75,6 +92,13 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
return
super
.
removeById
(
id
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
int
removeOldToken
(
Long
appId
,
String
deviceToken
)
{
return
imClientMapper
.
removeOldToken
(
appId
,
deviceToken
);
}
@Override
public
ImClientQueryVo
getImClientById
(
Long
id
)
throws
Exception
{
return
imClientMapper
.
getImClientById
(
id
);
...
...
common/src/main/resources/mapper/ImClientMapper.xml
View file @
b295848f
...
...
@@ -7,6 +7,12 @@
id
, create_time, update_time, fk_appid, attributes,device_type,valid
</sql>
<update
id=
"removeOldToken"
>
UPDATE im_client
SET device_token = NULL
WHERE device_token = #{deviceToken}
AND fk_appid = #{appId}
</update>
<select
id=
"getImClientById"
resultType=
"com.wecloud.im.param.ImClientQueryVo"
>
select
...
...
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