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
831d6451
Commit
831d6451
authored
Sep 28, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复Attributes重复不能创建会话
parent
e299ec07
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
15 deletions
+52
-15
common/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
+10
-0
common/src/main/java/com/wecloud/im/service/ImConversationService.java
+10
-0
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+13
-15
common/src/main/resources/mapper/ImConversationMapper.xml
+19
-0
No files found.
common/src/main/java/com/wecloud/im/mapper/ImConversationMapper.java
View file @
831d6451
...
@@ -65,6 +65,16 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
...
@@ -65,6 +65,16 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
*/
*/
Integer
getRepetitionConversation
(
@Param
(
"clientId1"
)
Long
clientId1
,
@Param
(
"clientId2"
)
Long
clientId2
);
Integer
getRepetitionConversation
(
@Param
(
"clientId1"
)
Long
clientId1
,
@Param
(
"clientId2"
)
Long
clientId2
);
/**
* 判断重复会话中的Attributes是否一样
*
* @param clientId1
* @param clientId2
* @param attributes
* @return 大于等于1为有重复会话
*/
Long
getRepetitionConversationAttributes
(
@Param
(
"clientId1"
)
Long
clientId1
,
@Param
(
"clientId2"
)
Long
clientId2
,
@Param
(
"attributes"
)
String
attributes
);
/**
/**
* 查询已经存在的会话信息
* 查询已经存在的会话信息
...
...
common/src/main/java/com/wecloud/im/service/ImConversationService.java
View file @
831d6451
...
@@ -102,5 +102,15 @@ public interface ImConversationService extends BaseService<ImConversation> {
...
@@ -102,5 +102,15 @@ public interface ImConversationService extends BaseService<ImConversation> {
*/
*/
Integer
getRepetitionConversation
(
Long
clientId1
,
Long
clientId2
);
Integer
getRepetitionConversation
(
Long
clientId1
,
Long
clientId2
);
/**
* 判断重复会话中的Attributes是否一样
*
* @param clientId1
* @param clientId2
* @param attributes
* @return 大于等于1为有重复会话
*/
Long
getRepetitionConversationAttributes
(
Long
clientId1
,
Long
clientId2
,
String
attributes
);
}
}
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
831d6451
...
@@ -123,37 +123,30 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -123,37 +123,30 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
}
}
}
else
{
}
else
{
//创建重复会话时对比扩展字段
0不
1是
//创建重复会话时对比扩展字段 1是
if
(
imApplication
.
getContrastExtendedFieldStatus
()
==
1
)
{
if
(
imApplication
.
getContrastExtendedFieldStatus
()
==
1
)
{
// 被邀请client
// 被邀请client
ImClient
inviteClient
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
ImClient
inviteClient
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
createClient
.
getFkAppid
())
.
eq
(
ImClient:
:
getFkAppid
,
createClient
.
getFkAppid
())
.
eq
(
ImClient:
:
getClientId
,
imConversationCreate
.
getClientIds
().
get
(
0
)));
.
eq
(
ImClient:
:
getClientId
,
imConversationCreate
.
getClientIds
().
get
(
0
)));
// 是否存在重复会话
Integer
repetitionConversation
=
getRepetitionConversation
(
createClient
.
getId
(),
inviteClient
.
getId
());
if
(
repetitionConversation
!=
0
)
{
ImConversation
repetitionConversationInfo
=
imConversationMapper
.
getRepetitionConversationInfo
(
createClient
.
getId
(),
inviteClient
.
getId
());
log
.
info
(
"出现Conversation重复"
);
JsonMapper
jsonMapper
=
new
JsonMapper
();
JsonMapper
jsonMapper
=
new
JsonMapper
();
HashMap
dbAttributesMap
=
jsonMapper
.
readValue
(
repetitionConversationInfo
.
getAttributes
(),
HashMap
.
class
);
String
asString
=
jsonMapper
.
writeValueAsString
(
imConversationCreate
.
getAttributes
());
log
.
info
(
"RequestAttributes:"
+
asString
);
log
.
info
(
"DBAttributes:"
+
repetitionConversationInfo
.
getAttributes
());
log
.
info
(
"RequestAttributes:"
+
jsonMapper
.
writeValueAsString
(
imConversationCreate
.
getAttributes
()));
Long
repetitionConversation
=
getRepetitionConversationAttributes
(
createClient
.
getId
(),
inviteClient
.
getId
(),
asString
);
if
(
dbAttributesMap
.
equals
(
imConversationCreate
.
getAttributes
()))
{
// 存在重复会话
if
(
repetitionConversation
!=
null
)
{
log
.
info
(
"出现Attributes重复"
);
log
.
info
(
"出现Attributes重复"
);
ImConversationCreateVo
imConversationCreateVo
=
new
ImConversationCreateVo
();
ImConversationCreateVo
imConversationCreateVo
=
new
ImConversationCreateVo
();
imConversationCreateVo
.
setId
(
repetitionConversationInfo
.
getId
()
);
imConversationCreateVo
.
setId
(
repetitionConversation
);
// 为重复
// 为重复
return
ApiResult
.
ok
(
imConversationCreateVo
);
return
ApiResult
.
ok
(
imConversationCreateVo
);
}
}
}
}
}
}
}
// 会话id
// 会话id
...
@@ -289,4 +282,9 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
...
@@ -289,4 +282,9 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
return
imConversationMapper
.
getRepetitionConversation
(
clientId1
,
clientId2
);
return
imConversationMapper
.
getRepetitionConversation
(
clientId1
,
clientId2
);
}
}
@Override
public
Long
getRepetitionConversationAttributes
(
Long
clientId1
,
Long
clientId2
,
String
attributes
)
{
return
imConversationMapper
.
getRepetitionConversationAttributes
(
clientId1
,
clientId2
,
attributes
);
}
}
}
common/src/main/resources/mapper/ImConversationMapper.xml
View file @
831d6451
...
@@ -72,6 +72,25 @@
...
@@ -72,6 +72,25 @@
) AS r1
) AS r1
WHERE members_count = 2
WHERE members_count = 2
</select>
</select>
<select
id=
"getRepetitionConversationAttributes"
resultType=
"java.lang.Long"
>
SELECT *
FROM im_conversation
WHERE id IN (
SELECT im_conversation_members.fk_conversation_id
FROM im_conversation_members
INNER JOIN (SELECT *
FROM im_conversation_members
WHERE im_conversation_members.fk_client_id = #{clientId2}) AS im_conversation_members2
ON im_conversation_members.fk_conversation_id =
im_conversation_members2.fk_conversation_id
WHERE im_conversation_members.fk_client_id = #{clientId1}
)
AND attributes = CAST(#{attributes} AS json) LIMIT 1
</select>
<select
id=
"getRepetitionConversationInfo"
resultType=
"com.wecloud.im.entity.ImConversation"
>
<select
id=
"getRepetitionConversationInfo"
resultType=
"com.wecloud.im.entity.ImConversation"
>
SELECT im_conversation.*
SELECT im_conversation.*
FROM im_conversation_members
FROM im_conversation_members
...
...
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