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
f850d119
Commit
f850d119
authored
Aug 04, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
灵活配置该应用 是否允许重复创建会话
parent
8ff4dadd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
+32
-18
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+32
-18
No files found.
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
f850d119
...
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.json.JsonMapper
;
import
com.wecloud.im.entity.ImApplication
;
import
com.wecloud.im.entity.ImClient
;
import
com.wecloud.im.entity.ImConversation
;
import
com.wecloud.im.entity.ImConversationMembers
;
...
...
@@ -28,6 +29,8 @@ 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
;
import
io.geekidea.springbootplus.framework.core.pagination.Paging
;
import
io.geekidea.springbootplus.framework.shiro.jwt.JwtToken
;
import
io.geekidea.springbootplus.framework.shiro.util.JwtUtil
;
import
io.geekidea.springbootplus.framework.shiro.util.SnowflakeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -91,25 +94,36 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
// 判断是否已经存在会话
// 两个用户如果已经创建过会话,不能重复创建会话
// size() == 1 为单聊的时候不允许重复创建
if
(
imConversationCreate
.
getClientIds
().
size
()
==
1
)
{
ImClient
client2
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
client
.
getFkAppid
())
.
eq
(
ImClient:
:
getClientId
,
imConversationCreate
.
getClientIds
().
get
(
0
)));
// 是否存在重复会话
Integer
repetitionConversation
=
getRepetitionConversation
(
client
.
getId
(),
client2
.
getId
());
if
(
repetitionConversation
!=
0
)
{
log
.
debug
(
"repetitionConversation != 0"
);
// 返回已存在的会话id
ImConversation
repetitionConversationInfo
=
imConversationMapper
.
getRepetitionConversationInfo
(
client
.
getId
(),
client2
.
getId
());
ImConversationCreateVo
imConversationCreateVo
=
new
ImConversationCreateVo
();
imConversationCreateVo
.
setId
(
repetitionConversationInfo
.
getId
());
// shiro线程中获取当前token
JwtToken
curentJwtToken
=
JwtUtil
.
getCurentJwtToken
();
// 根据appKey查询appid
ImApplication
imApplication
=
imApplicationService
.
getOne
(
new
QueryWrapper
<
ImApplication
>().
lambda
()
.
eq
(
ImApplication:
:
getAppKey
,
curentJwtToken
.
getAppKey
())
);
return
ApiResult
.
ok
(
imConversationCreateVo
);
// 该应用 是否允许重复创建会话
if
(
imApplication
.
getRepeatSessionStatus
()
==
0
)
{
// 判断是否已经存在会话
// 两个用户如果已经创建过会话,不能重复创建会话
// size() == 1 为单聊的时候不允许重复创建
if
(
imConversationCreate
.
getClientIds
().
size
()
==
1
)
{
ImClient
client2
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
client
.
getFkAppid
())
.
eq
(
ImClient:
:
getClientId
,
imConversationCreate
.
getClientIds
().
get
(
0
)));
// 是否存在重复会话
Integer
repetitionConversation
=
getRepetitionConversation
(
client
.
getId
(),
client2
.
getId
());
if
(
repetitionConversation
!=
0
)
{
log
.
debug
(
"repetitionConversation != 0"
);
// 返回已存在的会话id
ImConversation
repetitionConversationInfo
=
imConversationMapper
.
getRepetitionConversationInfo
(
client
.
getId
(),
client2
.
getId
());
ImConversationCreateVo
imConversationCreateVo
=
new
ImConversationCreateVo
();
imConversationCreateVo
.
setId
(
repetitionConversationInfo
.
getId
());
return
ApiResult
.
ok
(
imConversationCreateVo
);
}
}
}
...
...
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