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
d73ff806
Commit
d73ff806
authored
Sep 18, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加imClient的redis缓存;
添加apns的redis缓存;
parent
e822867b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
10 deletions
+31
-10
common/src/main/java/com/wecloud/im/controller/ImClientController.java
+1
-1
common/src/main/java/com/wecloud/im/service/ImClientService.java
+5
-1
common/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
+25
-8
No files found.
common/src/main/java/com/wecloud/im/controller/ImClientController.java
View file @
d73ff806
...
...
@@ -52,7 +52,7 @@ public class ImClientController extends BaseController {
@PostMapping
(
"/addDeviceInfo"
)
@ApiOperation
(
value
=
"添加或修改推送设备信息(每次请求都会覆盖之前的数据)"
)
public
ApiResult
<
Boolean
>
addDeviceInfo
(
@Validated
(
Add
.
class
)
@RequestBody
ImClientDeviceInfoAdd
imClientDevice
)
throws
Exception
{
boolean
flag
=
imClientService
.
add
DeviceInfo
(
imClientDevice
);
boolean
flag
=
imClientService
.
update
DeviceInfo
(
imClientDevice
);
return
ApiResult
.
result
(
flag
);
}
...
...
common/src/main/java/com/wecloud/im/service/ImClientService.java
View file @
d73ff806
...
...
@@ -30,7 +30,7 @@ public interface ImClientService extends BaseService<ImClient> {
* @param imClientDevice
* @return
*/
boolean
add
DeviceInfo
(
ImClientDeviceInfoAdd
imClientDevice
);
boolean
update
DeviceInfo
(
ImClientDeviceInfoAdd
imClientDevice
);
/**
* 修改
...
...
@@ -76,4 +76,8 @@ public interface ImClientService extends BaseService<ImClient> {
*/
ImClient
getCurentClient
();
ImClient
getCacheImClient
(
Long
applicationId
,
String
clientId
);
void
deleteCacheImClient
(
Long
applicationId
,
String
clientId
);
}
common/src/main/java/com/wecloud/im/service/impl/ImClientServiceImpl.java
View file @
d73ff806
...
...
@@ -20,6 +20,9 @@ import io.geekidea.springbootplus.framework.shiro.util.JwtUtil;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -31,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Slf4j
@Service
@CacheConfig
(
cacheNames
=
"client"
)
public
class
ImClientServiceImpl
extends
BaseServiceImpl
<
ImClientMapper
,
ImClient
>
implements
ImClientService
{
@Autowired
...
...
@@ -46,18 +50,22 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
add
DeviceInfo
(
ImClientDeviceInfoAdd
imClientDevice
)
{
public
boolean
update
DeviceInfo
(
ImClientDeviceInfoAdd
imClientDevice
)
{
ImClient
client
=
getCurentClient
();
ImClient
clientNew
=
new
ImClient
();
BeanUtils
.
copyProperties
(
imClientDevice
,
clientNew
);
clientNew
.
setId
(
client
.
getId
());
return
this
.
saveOrUpdate
(
clientNew
);
// 清楚缓存
deleteCacheImClient
(
client
.
getFkAppid
(),
client
.
getClientId
());
// 修改
return
this
.
updateImClient
(
clientNew
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
updateImClient
(
ImClient
imClient
)
throws
Exception
{
public
boolean
updateImClient
(
ImClient
imClient
)
{
return
super
.
updateById
(
imClient
);
}
...
...
@@ -76,7 +84,7 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
public
Paging
<
ImClientQueryVo
>
getImClientPageList
(
ImClientPageParam
imClientPageParam
)
throws
Exception
{
Page
<
ImClientQueryVo
>
page
=
new
PageInfo
<>(
imClientPageParam
,
OrderItem
.
desc
(
getLambdaColumn
(
ImClient:
:
getCreateTime
)));
IPage
<
ImClientQueryVo
>
iPage
=
imClientMapper
.
getImClientPageList
(
page
,
imClientPageParam
);
return
new
Paging
<
ImClientQueryVo
>(
iPage
);
return
new
Paging
<>(
iPage
);
}
@Override
...
...
@@ -84,13 +92,22 @@ public class ImClientServiceImpl extends BaseServiceImpl<ImClientMapper, ImClien
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getOneByAppKey
(
curentJwtToken
.
getAppKey
());
return
getCacheImClient
(
imApplication
.
getId
(),
curentJwtToken
.
getClientId
());
}
@Override
@Cacheable
(
key
=
"#p0+#p1"
)
public
ImClient
getCacheImClient
(
Long
applicationId
,
String
clientId
)
{
return
this
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
imApplication
.
getId
())
.
eq
(
ImClient:
:
getClientId
,
curentJwtToken
.
getClientId
()));
.
eq
(
ImClient:
:
getFkAppid
,
applicationId
)
.
eq
(
ImClient:
:
getClientId
,
clientId
));
}
@Override
@CacheEvict
(
key
=
"#p0+#p1"
)
public
void
deleteCacheImClient
(
Long
applicationId
,
String
clientId
)
{
}
}
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