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
ec675e7c
Commit
ec675e7c
authored
Jan 21, 2022
by
hweeeeeei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化:根据id查询Application调用频率较高,增加redis缓存前缀缩写为"appl",方法名getById修改为getCacheById增加可读性
parent
4a21fdbb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
38 deletions
+78
-38
core/src/main/java/com/wecloud/im/friend/service/FriendEventSender.java
+2
-2
core/src/main/java/com/wecloud/im/service/ImApplicationService.java
+39
-15
core/src/main/java/com/wecloud/im/service/impl/ImApplicationServiceImpl.java
+29
-12
core/src/main/java/com/wecloud/im/service/impl/ImInboxServiceImpl.java
+2
-2
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
+1
-1
core/src/main/java/com/wecloud/im/ws/strategy/AbstractImCmdStrategy.java
+1
-2
core/src/main/java/com/wecloud/rtc/service/impl/RtcServiceImpl.java
+4
-4
No files found.
core/src/main/java/com/wecloud/im/friend/service/FriendEventSender.java
View file @
ec675e7c
...
...
@@ -57,7 +57,7 @@ public class FriendEventSender {
responseModel
.
setReqId
(
null
);
channelSender
.
sendMsg
(
responseModel
,
receiveClient
.
getId
());
ImApplication
app
=
imApplicationService
.
getById
(
receiveClient
.
getFkAppid
());
ImApplication
app
=
imApplicationService
.
get
Cache
ById
(
receiveClient
.
getFkAppid
());
PushVO
pushVO
=
new
PushVO
();
pushVO
.
setTitle
(
FRIEND_APPLY_TITLE
);
...
...
@@ -83,7 +83,7 @@ public class FriendEventSender {
responseModel
.
setReqId
(
null
);
channelSender
.
sendMsg
(
responseModel
,
receiveClient
.
getId
());
ImApplication
app
=
imApplicationService
.
getById
(
receiveClient
.
getFkAppid
());
ImApplication
app
=
imApplicationService
.
get
Cache
ById
(
receiveClient
.
getFkAppid
());
PushVO
pushVO
=
new
PushVO
();
pushVO
.
setTitle
(
FRIEND_APPROVE_TITLE
);
...
...
core/src/main/java/com/wecloud/im/service/ImApplicationService.java
View file @
ec675e7c
...
...
@@ -16,39 +16,63 @@ public interface ImApplicationService extends BaseService<ImApplication> {
/**
* 根据
appKey查询application
* 根据
id查询应用数据 redis缓存
*
* @param
appKey
* @param
id
* @return
*/
ImApplication
getCacheAppByAppKey
(
String
appKey
);
ImApplication
getCacheById
(
Long
id
);
/**
*
保
存
*
删除缓
存
*
* @param imApplication
* @return
* @throws Exception
* @param id
*/
boolean
saveImApplication
(
ImApplication
imApplication
)
throws
Exception
;
void
deleteCacheById
(
Long
id
)
;
/**
*
修改
*
删除缓存
*
* @param imApplication
* @param appKey
*/
void
deleteCacheByAppKey
(
String
appKey
);
/**
* 根据appKey查询application
*
* @param appKey
* @return
* @throws Exception
*/
boolean
updateImApplication
(
ImApplication
imApplication
)
throws
Exception
;
ImApplication
getCacheAppByAppKey
(
String
appKey
)
;
/**
*
删除
*
保存
*
* @param i
d
* @param i
mApplication
* @return
* @throws Exception
*/
boolean
deleteImApplication
(
Long
id
)
throws
Exception
;
boolean
saveImApplication
(
ImApplication
imApplication
)
throws
Exception
;
// /**
// * 修改
// *
// * @param imApplication
// * @return
// * @throws Exception
// */
// boolean updateImApplication(ImApplication imApplication) throws Exception;
//
// /**
// * 删除
// *
// * @param id
// * @return
// * @throws Exception
// */
// boolean deleteImApplication(Long id) throws Exception;
/**
* 根据ID获取查询对象
...
...
core/src/main/java/com/wecloud/im/service/impl/ImApplicationServiceImpl.java
View file @
ec675e7c
...
...
@@ -15,6 +15,7 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging;
import
lombok.extern.slf4j.Slf4j
;
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
;
...
...
@@ -27,7 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Slf4j
@Service
@CacheConfig
(
cacheNames
=
"appl
ic
"
)
@CacheConfig
(
cacheNames
=
"appl"
)
public
class
ImApplicationServiceImpl
extends
BaseServiceImpl
<
ImApplicationMapper
,
ImApplication
>
implements
ImApplicationService
{
@Autowired
...
...
@@ -35,6 +36,22 @@ public class ImApplicationServiceImpl extends BaseServiceImpl<ImApplicationMappe
@Override
@Cacheable
(
key
=
"#p0"
)
public
ImApplication
getCacheById
(
Long
id
)
{
return
super
.
getById
(
id
);
}
@Override
@CacheEvict
(
key
=
"#p0"
)
public
void
deleteCacheById
(
Long
id
)
{
}
@Override
@CacheEvict
(
key
=
"#p0"
)
public
void
deleteCacheByAppKey
(
String
appKey
)
{
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
ImApplication
getCacheAppByAppKey
(
String
appKey
)
{
ImApplication
imApplication
=
this
.
getOne
(
new
QueryWrapper
<
ImApplication
>().
lambda
()
...
...
@@ -49,17 +66,17 @@ public class ImApplicationServiceImpl extends BaseServiceImpl<ImApplicationMappe
return
super
.
save
(
imApplication
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
updateImApplication
(
ImApplication
imApplication
)
throws
Exception
{
return
super
.
updateById
(
imApplication
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
deleteImApplication
(
Long
id
)
throws
Exception
{
return
super
.
removeById
(
id
);
}
//
@Transactional(rollbackFor = Exception.class)
//
@Override
//
public boolean updateImApplication(ImApplication imApplication) throws Exception {
//
return super.updateById(imApplication);
//
}
//
//
@Transactional(rollbackFor = Exception.class)
//
@Override
//
public boolean deleteImApplication(Long id) throws Exception {
//
return super.removeById(id);
//
}
@Override
public
ImApplicationQueryVo
getImApplicationById
(
Long
id
)
throws
Exception
{
...
...
core/src/main/java/com/wecloud/im/service/impl/ImInboxServiceImpl.java
View file @
ec675e7c
...
...
@@ -98,7 +98,7 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
Long
aLong
=
imInboxMapper
.
updateImMsgReceivedByIds
(
curentClient
.
getId
(),
imMsgReceivedUpdate
.
getMsgIds
());
// 根据appKey查询appid
ImApplication
application
=
imApplicationService
.
getById
(
curentClient
.
getFkAppid
());
ImApplication
application
=
imApplicationService
.
get
Cache
ById
(
curentClient
.
getFkAppid
());
// 内容
HashMap
<
String
,
String
>
stringStringHashMap
=
new
HashMap
<>();
...
...
@@ -141,7 +141,7 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
Long
aLong
=
imInboxMapper
.
updateImMsgReadByIds
(
curentClient
.
getId
(),
imMsgReadStatusUpdate
.
getMsgIds
());
// 根据appKey查询appid
ImApplication
application
=
imApplicationService
.
getById
(
curentClient
.
getFkAppid
());
ImApplication
application
=
imApplicationService
.
get
Cache
ById
(
curentClient
.
getFkAppid
());
// 内容
HashMap
<
String
,
String
>
stringStringHashMap
=
new
HashMap
<>();
...
...
core/src/main/java/com/wecloud/im/service/impl/ImMessageServiceImpl.java
View file @
ec675e7c
...
...
@@ -162,7 +162,7 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
ImClient
imClientSender
=
imClientService
.
getCurentClient
();
// 查询imApplication
ImApplication
imApplication
=
imApplicationService
.
getById
(
imClientSender
.
getFkAppid
());
ImApplication
imApplication
=
imApplicationService
.
get
Cache
ById
(
imClientSender
.
getFkAppid
());
if
(
imApplication
==
null
)
{
log
.
info
(
"imApplication为空"
);
return
ApiResult
.
fail
();
...
...
core/src/main/java/com/wecloud/im/ws/strategy/AbstractImCmdStrategy.java
View file @
ec675e7c
...
...
@@ -15,7 +15,6 @@ import com.wecloud.utils.JsonUtils;
import
io.geekidea.springbootplus.framework.common.exception.BusinessException
;
import
io.netty.channel.ChannelHandlerContext
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.BooleanUtils
;
/**
* @Description 处理Cmd请求
...
...
@@ -87,7 +86,7 @@ public abstract class AbstractImCmdStrategy {
}
// 查询imApplication
ImApplication
imApplication
=
imApplicationService
.
getById
(
imClientSender
.
getFkAppid
());
ImApplication
imApplication
=
imApplicationService
.
get
Cache
ById
(
imClientSender
.
getFkAppid
());
if
(
imApplication
==
null
)
{
log
.
warn
(
"根据appId: {} 查找不到 imApplication!"
,
imClientSender
.
getFkAppid
());
return
;
...
...
core/src/main/java/com/wecloud/rtc/service/impl/RtcServiceImpl.java
View file @
ec675e7c
...
...
@@ -142,7 +142,7 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
public
ApiResult
<
Boolean
>
reject
(
RejectRtcChannelParam
rejectRtcChannelParam
)
{
ImClient
client
=
imClientService
.
getCurentClient
();
ImApplication
imApplication
=
imApplicationService
.
getById
(
client
.
getFkAppid
());
ImApplication
imApplication
=
imApplicationService
.
get
Cache
ById
(
client
.
getFkAppid
());
//获取频道内所有client
List
<
String
>
clientListByRtcChannelId
=
mangerRtcCacheService
.
getClientListByRtcChannelId
(
rejectRtcChannelParam
.
getChannelId
());
...
...
@@ -169,7 +169,7 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
ImClient
client
=
imClientService
.
getCurentClient
();
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getById
(
client
.
getFkAppid
());
ImApplication
imApplication
=
imApplicationService
.
get
Cache
ById
(
client
.
getFkAppid
());
this
.
leave
(
leaveRtcChannelParam
,
client
);
return
ApiResult
.
ok
(
true
);
...
...
@@ -209,7 +209,7 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
Long
rtcChannelId
=
SnowflakeUtil
.
getId
();
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getById
(
client
.
getFkAppid
());
ImApplication
imApplication
=
imApplicationService
.
get
Cache
ById
(
client
.
getFkAppid
());
// 判断发起方必须在线
boolean
onlineStatus
=
userStateCacheManager
.
isOnline
(
client
.
getId
());
...
...
@@ -250,7 +250,7 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
Long
rtcChannelId
=
SnowflakeUtil
.
getId
();
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getById
(
client
.
getFkAppid
());
ImApplication
imApplication
=
imApplicationService
.
get
Cache
ById
(
client
.
getFkAppid
());
// 判断发起方必须在线
boolean
onlineStatus
=
userStateCacheManager
.
isOnline
(
client
.
getId
());
...
...
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