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
f1d1382b
Commit
f1d1382b
authored
Sep 27, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
性能优化部分
parent
beb96394
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
144 deletions
+86
-144
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
+0
-4
core/src/main/java/com/wecloud/im/mq/MqSender.java
+2
-2
core/src/main/java/com/wecloud/im/service/ImApplicationService.java
+3
-60
core/src/main/java/com/wecloud/im/service/impl/ImApplicationServiceImpl.java
+28
-74
core/src/main/java/com/wecloud/im/service/impl/ImInboxServiceImpl.java
+0
-2
core/src/main/resources/mapper/ImInboxMapper.xml
+2
-1
docs/db/feature-cluster增量.sql
+4
-1
scheduled/src/main/java/io/geekidea/springbootplus/scheduled/InboxScheduled.java
+47
-0
No files found.
core/src/main/java/com/wecloud/im/action/NormalChatAction.java
View file @
f1d1382b
...
@@ -101,10 +101,6 @@ public class NormalChatAction {
...
@@ -101,10 +101,6 @@ public class NormalChatAction {
// 查询imApplication
// 查询imApplication
ImApplication
imApplication
=
imApplicationService
.
getCacheById
(
imClientSender
.
getFkAppid
());
ImApplication
imApplication
=
imApplicationService
.
getCacheById
(
imClientSender
.
getFkAppid
());
if
(
imApplication
==
null
)
{
log
.
warn
(
"根据appId: {} 查找不到 imApplication!"
,
imClientSender
.
getFkAppid
());
return
;
}
// 给所有人(在线+离线)遍历发送
// 给所有人(在线+离线)遍历发送
// 先查询该会话所有成员
// 先查询该会话所有成员
...
...
core/src/main/java/com/wecloud/im/mq/MqSender.java
View file @
f1d1382b
...
@@ -99,8 +99,8 @@ public class MqSender {
...
@@ -99,8 +99,8 @@ public class MqSender {
messageDTO
.
setSubTitle
(
pushVO
.
getSubTitle
());
messageDTO
.
setSubTitle
(
pushVO
.
getSubTitle
());
messageDTO
.
setData
(
pushVO
.
getData
());
messageDTO
.
setData
(
pushVO
.
getData
());
// 统计未读消息数量
// 统计未读消息数量
int
badge
=
imInboxService
.
countMyNotReadCount
(
imClientReceiver
.
getId
());
//
int badge = imInboxService.countMyNotReadCount(imClientReceiver.getId());
messageDTO
.
setBadge
(
badge
);
//
messageDTO.setBadge(badge);
ClientDTO
clientDTO
=
new
ClientDTO
();
ClientDTO
clientDTO
=
new
ClientDTO
();
clientDTO
.
setClientId
(
imClientReceiver
.
getClientId
());
clientDTO
.
setClientId
(
imClientReceiver
.
getClientId
());
List
<
ImClientDevice
>
clientDeviceList
=
imClientDeviceService
.
list
(
List
<
ImClientDevice
>
clientDeviceList
=
imClientDeviceService
.
list
(
...
...
core/src/main/java/com/wecloud/im/service/ImApplicationService.java
View file @
f1d1382b
package
com
.
wecloud
.
im
.
service
;
package
com
.
wecloud
.
im
.
service
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.param.ImApplicationPageParam
;
import
com.wecloud.im.param.ImApplicationQueryVo
;
import
io.geekidea.springbootplus.framework.common.service.BaseService
;
import
io.geekidea.springbootplus.framework.common.service.BaseService
;
import
io.geekidea.springbootplus.framework.
core.pagination.Paging
;
import
io.geekidea.springbootplus.framework.
shiro.signature.Application
;
/**
/**
* 第三方应用表 服务类
* 第三方应用表 服务类
...
@@ -23,22 +21,6 @@ public interface ImApplicationService extends BaseService<ImApplication> {
...
@@ -23,22 +21,6 @@ public interface ImApplicationService extends BaseService<ImApplication> {
*/
*/
ImApplication
getCacheById
(
Long
id
);
ImApplication
getCacheById
(
Long
id
);
/**
* 删除缓存
*
* @param id
*/
void
deleteCacheById
(
Long
id
);
/**
* 删除缓存
*
* @param appKey
*/
void
deleteCacheByAppKey
(
String
appKey
);
/**
/**
* 根据appKey查询application
* 根据appKey查询application
*
*
...
@@ -48,48 +30,9 @@ public interface ImApplicationService extends BaseService<ImApplication> {
...
@@ -48,48 +30,9 @@ public interface ImApplicationService extends BaseService<ImApplication> {
ImApplication
getCacheAppByAppKey
(
String
appKey
);
ImApplication
getCacheAppByAppKey
(
String
appKey
);
/**
/**
* 保存
* 本地构造
*
* @param imApplication
* @return
* @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获取查询对象
*
* @param id
* @return
* @throws Exception
*/
ImApplicationQueryVo
getImApplicationById
(
Long
id
)
throws
Exception
;
/**
* 获取分页对象
*
* @param imApplicationPageParam
* @return
* @return
* @throws Exception
*/
*/
Paging
<
ImApplicationQueryVo
>
getImApplicationPageList
(
ImApplicationPageParam
imApplicationPageParam
)
throws
Exception
;
ImApplication
getByLocal
()
;
}
}
core/src/main/java/com/wecloud/im/service/impl/ImApplicationServiceImpl.java
View file @
f1d1382b
package
com
.
wecloud
.
im
.
service
.
impl
;
package
com
.
wecloud
.
im
.
service
.
impl
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.mapper.ImApplicationMapper
;
import
com.wecloud.im.service.ImApplicationService
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl
;
import
io.geekidea.springbootplus.framework.core.pagination.PageInfo
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
import
io.geekidea.springbootplus.framework.shiro.signature.Application
;
import
io.geekidea.springbootplus.framework.shiro.signature.Application
;
import
io.geekidea.springbootplus.framework.shiro.signature.ApplicationService
;
import
io.geekidea.springbootplus.framework.shiro.signature.ApplicationService
;
import
lombok.extern.slf4j.Slf4j
;
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.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.OrderItem
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.mapper.ImApplicationMapper
;
import
com.wecloud.im.param.ImApplicationPageParam
;
import
com.wecloud.im.param.ImApplicationQueryVo
;
import
com.wecloud.im.service.ImApplicationService
;
/**
/**
* 第三方应用表 服务实现类
* @Author Future
*
* @Date 2022/9/27 13:45
* @author wei
* @Description 不在落库取,本地构造
* @since 2021-04-27
*/
*/
@Slf4j
@Slf4j
@Service
@Service
@CacheConfig
(
cacheNames
=
"appl"
)
public
class
ImApplicationServiceImpl
extends
BaseServiceImpl
<
ImApplicationMapper
,
ImApplication
>
implements
ImApplicationService
,
ApplicationService
{
public
class
ImApplicationServiceImpl
extends
BaseServiceImpl
<
ImApplicationMapper
,
ImApplication
>
implements
ImApplicationService
,
ApplicationService
{
@Autowired
private
ImApplicationMapper
imApplicationMapper
;
@Override
@Override
// @Cacheable(key = "'id_'+#p0")
public
ImApplication
getCacheById
(
Long
id
)
{
public
ImApplication
getCacheById
(
Long
id
)
{
return
super
.
getById
(
id
);
return
this
.
getByLocal
();
}
@Override
@CacheEvict
(
key
=
"'id_'+#p0"
)
public
void
deleteCacheById
(
Long
id
)
{
}
}
@Override
@Override
@CacheEvict
(
key
=
"'appKey_'+#p0"
)
public
void
deleteCacheByAppKey
(
String
appKey
)
{
}
@Override
@Cacheable
(
key
=
"'appKey_'+#p0"
)
public
ImApplication
getCacheAppByAppKey
(
String
appKey
)
{
public
ImApplication
getCacheAppByAppKey
(
String
appKey
)
{
ImApplication
imApplication
=
this
.
getOne
(
return
getByLocal
();
new
QueryWrapper
<
ImApplication
>().
lambda
()
}
.
eq
(
ImApplication:
:
getAppKey
,
appKey
)
);
@Override
public
ImApplication
getByLocal
()
{
ImApplication
imApplication
=
new
ImApplication
();
imApplication
.
setId
(
1L
);
imApplication
.
setAppKey
(
"QizKVHcILRWp6Td2"
);
imApplication
.
setAppSecret
(
"287d04828099fb7de871e9dda845fa8b6b2302faf2ab3737"
);
imApplication
.
setAppName
(
"遇乐圈"
);
imApplication
.
setIosPushChannel
(
1
);
imApplication
.
setAndroidPushChannel
(
1
);
imApplication
.
setUmengKey
(
"62b43a6d88ccdf4b7ea76bfd"
);
imApplication
.
setUmengSecret
(
"ekcdlz2jivhddwsva7i47pkhywk0tmrm"
);
imApplication
.
setIosUmengKey
(
"62b43ad388ccdf4b7ea76c2e"
);
imApplication
.
setIosUmengSecret
(
"1rokfrxpidqnm3nywm2wsrcmbfg0f1ln"
);
imApplication
.
setRepeatSessionStatus
(
0
);
imApplication
.
setContrastExtendedFieldStatus
(
0
);
imApplication
.
setOnlineStatusSubscribeUrl
(
"http://xiaohudou:8080/callback/clientOnlineStatusChange"
);
imApplication
.
setFullMessageSubscribeUrl
(
"http://xiaohudou:8080/message/sync"
);
return
imApplication
;
return
imApplication
;
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
boolean
saveImApplication
(
ImApplication
imApplication
)
throws
Exception
{
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);
// }
@Override
public
ImApplicationQueryVo
getImApplicationById
(
Long
id
)
throws
Exception
{
return
imApplicationMapper
.
getImApplicationById
(
id
);
}
@Override
public
Paging
<
ImApplicationQueryVo
>
getImApplicationPageList
(
ImApplicationPageParam
imApplicationPageParam
)
throws
Exception
{
Page
<
ImApplicationQueryVo
>
page
=
new
PageInfo
<>(
imApplicationPageParam
,
OrderItem
.
desc
(
getLambdaColumn
(
ImApplication:
:
getCreateTime
)));
IPage
<
ImApplicationQueryVo
>
iPage
=
imApplicationMapper
.
getImApplicationPageList
(
page
,
imApplicationPageParam
);
return
new
Paging
<
ImApplicationQueryVo
>(
iPage
);
}
@Override
@Override
public
Application
getApplication
(
String
appKey
)
{
public
Application
getApplication
(
String
appKey
)
{
return
get
CacheAppByAppKey
(
appKey
);
return
get
ByLocal
(
);
}
}
}
}
core/src/main/java/com/wecloud/im/service/impl/ImInboxServiceImpl.java
View file @
f1d1382b
...
@@ -132,8 +132,6 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
...
@@ -132,8 +132,6 @@ public class ImInboxServiceImpl extends BaseServiceImpl<ImInboxMapper, ImInbox>
*/
*/
@Override
@Override
public
Integer
countMyNotReadCount
(
Long
clientId
)
{
public
Integer
countMyNotReadCount
(
Long
clientId
)
{
return
imInboxMapper
.
countMyNotReadCount
(
clientId
);
return
imInboxMapper
.
countMyNotReadCount
(
clientId
);
}
}
...
...
core/src/main/resources/mapper/ImInboxMapper.xml
View file @
f1d1382b
...
@@ -45,8 +45,9 @@
...
@@ -45,8 +45,9 @@
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from im_Inbox
from im_Inbox
</select>
</select>
<select
id=
"countMyNotReadCount"
resultType=
"java.lang.Integer"
>
<select
id=
"countMyNotReadCount"
resultType=
"java.lang.Integer"
>
SELECT COUNT(
id
)
SELECT COUNT(
*
)
FROM im_inbox
FROM im_inbox
WHERE receiver = #{clientId}
WHERE receiver = #{clientId}
AND receiver_msg_status = 0
AND receiver_msg_status = 0
...
...
docs/db/feature-cluster增量.sql
View file @
f1d1382b
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
-- 在f
eature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
...
@@ -203,3 +203,6 @@ ALTER TABLE im_application
...
@@ -203,3 +203,6 @@ ALTER TABLE im_application
ALTER
TABLE
im_application
ALTER
TABLE
im_application
ADD
COLUMN
`ios_umeng_secret`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'友盟推送密钥'
;
ADD
COLUMN
`ios_umeng_secret`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'友盟推送密钥'
;
ALTER
TABLE
`im_inbox`
ADD
INDEX
`idx_create_time`
(
`create_time`
);
scheduled/src/main/java/io/geekidea/springbootplus/scheduled/InboxScheduled.java
0 → 100644
View file @
f1d1382b
package
io
.
geekidea
.
springbootplus
.
scheduled
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.wecloud.im.entity.ImInbox
;
import
com.wecloud.im.service.ImInboxService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
/**
* @Author Future
* @Date 2022/9/27 14:29
* @Description 离线消息
*/
@Slf4j
@Component
public
class
InboxScheduled
{
@Autowired
private
ImInboxService
imInboxService
;
/**
* 离线消息处理定时器
* 一个月之前的离线消息直接删除
* 一星期前的已读消息 删除
* 一天执行一次 凌晨3点执行
*/
@Scheduled
(
cron
=
"* */10 * * * ?"
)
public
void
callingTimeout
()
{
log
.
info
(
"离线消息处理定时器处理开始..."
);
// 30天之前数据, 直接删除
Date
allDeleteTime
=
DateUtils
.
addDays
(
new
Date
(),
-
30
);
imInboxService
.
remove
(
new
QueryWrapper
<
ImInbox
>().
lambda
()
.
lt
(
ImInbox:
:
getCreateTime
,
allDeleteTime
));
// 7天之前数据, 删除已读消息
Date
readTime
=
DateUtils
.
addDays
(
new
Date
(),
-
7
);
imInboxService
.
remove
(
new
QueryWrapper
<
ImInbox
>().
lambda
()
.
eq
(
ImInbox:
:
getReadMsgStatus
,
1
)
.
lt
(
ImInbox:
:
getCreateTime
,
readTime
));
}
}
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