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
0014c016
Commit
0014c016
authored
Sep 09, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复:创建重复会话时对比扩展字段
parent
78b7841a
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
192 additions
and
180 deletions
+192
-180
bootstrap/src/main/java/io/geekidea/springbootplus/SpringBootPlusApplication.java
+1
-59
bootstrap/src/main/java/io/geekidea/springbootplus/config/NacosConfig.java
+81
-0
bootstrap/src/test/java/io/geekidea/springbootplus/test/GetIpTest.java
+74
-74
common/pom.xml
+5
-5
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
+1
-2
common/src/main/java/com/wecloud/im/param/add/ImConversationCreate.java
+2
-2
common/src/main/java/com/wecloud/im/service/ImConversationService.java
+2
-1
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+25
-35
common/src/main/java/com/wecloud/im/ws/receive/ReadWsData.java
+1
-2
No files found.
bootstrap/src/main/java/io/geekidea/springbootplus/SpringBootPlusApplication.java
View file @
0014c016
...
...
@@ -16,59 +16,31 @@
package
io
.
geekidea
.
springbootplus
;
import
com.alibaba.cloud.nacos.NacosDiscoveryProperties
;
import
com.alibaba.cloud.nacos.NacosServiceManager
;
import
com.alibaba.cloud.nacos.discovery.NacosWatch
;
import
com.alibaba.nacos.api.naming.PreservedMetadataKeys
;
import
com.wecloud.im.register.GetIpUtils
;
import
io.geekidea.springbootplus.framework.util.PrintApplicationInfo
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.ServletComponentScan
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* spring-boot-plus 项目启动入口
*
* @author geekidea
* @since 2018-11-08
* 项目启动入口
*/
@EnableDiscoveryClient
@EnableAsync
@EnableScheduling
@EnableTransactionManagement
@EnableConfigurationProperties
@ServletComponentScan
@EnableCaching
//@ConfigurationPropertiesScan("com.wecloud.im")
@MapperScan
({
"io.geekidea.springbootplus.**.mapper"
,
"com.wecloud.**.mapper"
})
@SpringBootApplication
(
scanBasePackages
=
{
"io.geekidea.springbootplus"
,
"com.wecloud"
})
public
class
SpringBootPlusApplication
{
@Value
(
"${netty.port}"
)
private
String
nettyPort
;
@Resource
private
GetIpUtils
getIpUtils
;
public
static
void
main
(
String
[]
args
)
{
// 启动spring-boot-plus
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
SpringBootPlusApplication
.
class
,
args
);
...
...
@@ -78,35 +50,5 @@ public class SpringBootPlusApplication {
PrintApplicationInfo
.
printTip
(
context
);
}
@Bean
@ConditionalOnMissingBean
public
NacosDiscoveryProperties
nacosProperties
()
{
return
new
NacosDiscoveryProperties
();
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty
(
value
=
{
"spring.cloud.nacos.discovery.watch.enabled"
},
matchIfMissing
=
true
)
public
NacosWatch
nacosWatch
(
NacosServiceManager
nacosServiceManager
,
NacosDiscoveryProperties
nacosDiscoveryProperties
,
ObjectProvider
<
ThreadPoolTaskScheduler
>
taskScheduler
)
{
Map
<
String
,
String
>
metadataMap
=
nacosDiscoveryProperties
.
getMetadata
();
if
(
metadataMap
==
null
)
{
metadataMap
=
new
HashMap
<>();
}
String
key
=
"ip.netty.public"
;
metadataMap
.
put
(
"startup.time"
,
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
()));
String
value
=
getIpUtils
.
getPublicIp
()
+
":"
+
nettyPort
;
metadataMap
.
put
(
key
,
value
);
// 设置心跳的周期,单位为秒,这里将心跳间隔设置为3秒:
metadataMap
.
put
(
PreservedMetadataKeys
.
HEART_BEAT_INTERVAL
,
"3000"
);
// 设置心跳超时时间,单位为秒,这里将心跳超时时间设为6秒,
// 即服务端6秒收不到客户端心跳,会将该客户端注册的实例设为不健康:
metadataMap
.
put
(
PreservedMetadataKeys
.
HEART_BEAT_TIMEOUT
,
"6000"
);
// 设置实例删除的超时时间,单位为秒,这里将实例删除超时时间设为9秒,
// 即服务端9秒收不到客户端心跳,会将该客户端注册的实例删除:
metadataMap
.
put
(
PreservedMetadataKeys
.
IP_DELETE_TIMEOUT
,
"9000"
);
nacosDiscoveryProperties
.
setMetadata
(
metadataMap
);
return
new
NacosWatch
(
nacosServiceManager
,
nacosDiscoveryProperties
,
taskScheduler
);
}
}
bootstrap/src/main/java/io/geekidea/springbootplus/config/NacosConfig.java
0 → 100755
View file @
0014c016
///*
// * Copyright 2019-2029 geekidea(https://github.com/geekidea)
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package io.geekidea.springbootplus.config;
//
//import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
//import com.alibaba.cloud.nacos.NacosServiceManager;
//import com.alibaba.cloud.nacos.discovery.NacosWatch;
//import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
//import com.wecloud.im.register.GetIpUtils;
//import org.springframework.beans.factory.ObjectProvider;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
//
//import javax.annotation.Resource;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.Map;
//
//
//@Configuration
//@EnableDiscoveryClient
//public class NacosConfig {
// @Value("${netty.port}")
// private String nettyPort;
// @Resource
// private GetIpUtils getIpUtils;
//
// @Bean
// @ConditionalOnMissingBean
// public NacosDiscoveryProperties nacosProperties() {
// return new NacosDiscoveryProperties();
// }
//
// @Bean
// @ConditionalOnMissingBean
// @ConditionalOnProperty(value = {"spring.cloud.nacos.discovery.watch.enabled"}, matchIfMissing = true)
// public NacosWatch nacosWatch(NacosServiceManager nacosServiceManager, NacosDiscoveryProperties nacosDiscoveryProperties, ObjectProvider<ThreadPoolTaskScheduler> taskScheduler) {
// Map<String, String> metadataMap = nacosDiscoveryProperties.getMetadata();
// if (metadataMap == null) {
// metadataMap = new HashMap<>();
// }
// String key = "ip.netty.public";
// metadataMap.put("startup.time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
// String value = getIpUtils.getPublicIp() + ":" + nettyPort;
// metadataMap.put(key, value);
// // 设置心跳的周期,单位为秒,这里将心跳间隔设置为3秒:
// metadataMap.put(PreservedMetadataKeys.HEART_BEAT_INTERVAL, "3000");
// // 设置心跳超时时间,单位为秒,这里将心跳超时时间设为6秒,
// // 即服务端6秒收不到客户端心跳,会将该客户端注册的实例设为不健康:
// metadataMap.put(PreservedMetadataKeys.HEART_BEAT_TIMEOUT, "6000");
// // 设置实例删除的超时时间,单位为秒,这里将实例删除超时时间设为9秒,
// // 即服务端9秒收不到客户端心跳,会将该客户端注册的实例删除:
// metadataMap.put(PreservedMetadataKeys.IP_DELETE_TIMEOUT, "9000");
//
// nacosDiscoveryProperties.setMetadata(metadataMap);
// return new NacosWatch(nacosServiceManager, nacosDiscoveryProperties, taskScheduler);
// }
//
//
//}
\ No newline at end of file
bootstrap/src/test/java/io/geekidea/springbootplus/test/GetIpTest.java
View file @
0014c016
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
io
.
geekidea
.
springbootplus
.
test
;
import
com.alibaba.nacos.api.exception.NacosException
;
import
com.alibaba.nacos.api.naming.NamingFactory
;
import
com.alibaba.nacos.api.naming.NamingService
;
import
com.alibaba.nacos.api.naming.pojo.Instance
;
import
com.wecloud.im.register.GetIpUtils
;
import
io.geekidea.springbootplus.SpringBootPlusApplication
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.util.Map
;
/**
* get ip
**/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
SpringBootPlusApplication
.
class
)
public
class
GetIpTest
{
@Autowired
private
GetIpUtils
publicIpUtils
;
@Value
(
"${spring.cloud.nacos.discovery.server-addr}"
)
private
String
addr
;
@Test
public
void
test
()
throws
NacosException
{
// String s = publicIpUtils.getlanIp();
// String publicIp = publicIpUtils.getPublicIp();
// String s2 = publicIpUtils.getlanIp();
// String publicIp2 = publicIpUtils.getPublicIp();
// String serveAddr = System.getProperty("serveAddr");
NamingService
naming
=
NamingFactory
.
createNamingService
(
addr
);
Instance
wecloudIm
=
naming
.
selectOneHealthyInstance
(
"wecloud_im"
);
Map
<
String
,
String
>
metadata
=
wecloudIm
.
getMetadata
();
String
publicIp
=
metadata
.
get
(
"ip.netty.public"
);
System
.
out
.
println
(
wecloudIm
);
// naming.subscribe("ip.netty.public", event -> {
// if (event instanceof NamingEvent) {
// System.out.println(((NamingEvent) event).getServiceName());
// System.out.println(((NamingEvent) event).getInstances());
// }
// });
// while (true){
///*
// * Copyright 2019-2029 geekidea(https://github.com/geekidea)
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package io.geekidea.springbootplus.test;
//
//import com.alibaba.nacos.api.exception.NacosException;
//import com.alibaba.nacos.api.naming.NamingFactory;
//import com.alibaba.nacos.api.naming.NamingService;
//import com.alibaba.nacos.api.naming.pojo.Instance;
//import com.wecloud.im.register.GetIpUtils;
//import io.geekidea.springbootplus.SpringBootPlusApplication;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import java.util.Map;
//
///**
// * get ip
// **/
//@RunWith(SpringRunner.class)
//@SpringBootTest(classes = SpringBootPlusApplication.class)
//public class GetIpTest {
// @Autowired
// private GetIpUtils publicIpUtils;
//
// @Value("${spring.cloud.nacos.discovery.server-addr}")
// private String addr;
//
//
// @Test
// public void test() throws NacosException {
//
//// String s = publicIpUtils.getlanIp();
//// String publicIp = publicIpUtils.getPublicIp();
//// String s2 = publicIpUtils.getlanIp();
//// String publicIp2 = publicIpUtils.getPublicIp();
//
//// String serveAddr = System.getProperty("serveAddr");
// NamingService naming = NamingFactory.createNamingService(addr);
// Instance wecloudIm = naming.selectOneHealthyInstance("wecloud_im");
// Map<String, String> metadata = wecloudIm.getMetadata();
// String publicIp = metadata.get("ip.netty.public");
// System.out.println(wecloudIm);
//
//// naming.subscribe("ip.netty.public", event -> {
//// if (event instanceof NamingEvent) {
//// System.out.println(((NamingEvent) event).getServiceName());
//// System.out.println(((NamingEvent) event).getInstances());
//// }
//// });
//
//// while (true){
////
//// }
//
// }
}
}
//
//
//}
common/pom.xml
View file @
0014c016
...
...
@@ -21,11 +21,11 @@
<artifactId>
framework
</artifactId>
</dependency>
<
dependency
>
<groupId>
com.alibaba.cloud
</groupId
>
<artifactId>
spring-cloud-starter-alibaba-nacos-discovery
</artifactId
>
<version>
2.2.5.RELEASE
</version
>
<
/dependency
>
<
!-- <dependency>--
>
<!-- <groupId>com.alibaba.cloud</groupId>--
>
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>--
>
<!-- <version>2.2.5.RELEASE</version>--
>
<
!-- </dependency>--
>
<dependency>
<groupId>
com.google.firebase
</groupId>
...
...
common/src/main/java/com/wecloud/im/controller/ImConversationController.java
View file @
0014c016
...
...
@@ -39,8 +39,7 @@ public class ImConversationController extends BaseController {
@PostMapping
(
"/create"
)
@ApiOperation
(
value
=
"创建会话"
,
notes
=
"后台可配置:两个客户端如果已经创建过会话,是否重复创建会话"
)
public
ApiResult
<
ImConversationCreateVo
>
createImConversation
(
@RequestBody
ImConversationCreate
imConversationCreate
)
throws
Exception
{
ApiResult
<
ImConversationCreateVo
>
imConversation
=
imConversationService
.
createImConversation
(
imConversationCreate
);
return
imConversation
;
return
imConversationService
.
createImConversation
(
imConversationCreate
);
}
/**
...
...
common/src/main/java/com/wecloud/im/param/add/ImConversationCreate.java
View file @
0014c016
...
...
@@ -7,7 +7,7 @@ import lombok.Data;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.util.HashMap
;
import
java.util.
Linked
HashMap
;
import
java.util.List
;
/**
...
...
@@ -27,7 +27,7 @@ public class ImConversationCreate extends BaseEntity {
private
String
name
;
@ApiModelProperty
(
"json格式,可选 自定义属性,供开发者扩展使用。"
)
private
HashMap
attributes
;
private
Linked
HashMap
attributes
;
@ApiModelProperty
(
"可选 邀请加入会话的客户端,如创建单聊,则填入对方的clientId"
)
private
List
<
String
>
clientIds
;
...
...
common/src/main/java/com/wecloud/im/service/ImConversationService.java
View file @
0014c016
package
com
.
wecloud
.
im
.
service
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.wecloud.im.entity.ImConversation
;
import
com.wecloud.im.param.ImConversationPageParam
;
import
com.wecloud.im.param.ImConversationQueryVo
;
...
...
@@ -37,7 +38,7 @@ public interface ImConversationService extends BaseService<ImConversation> {
* @param imConversationCreate
* @return
*/
ApiResult
<
ImConversationCreateVo
>
createImConversation
(
ImConversationCreate
imConversationCreate
);
ApiResult
<
ImConversationCreateVo
>
createImConversation
(
ImConversationCreate
imConversationCreate
)
throws
JsonProcessingException
;
/**
* 修改
...
...
common/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
0014c016
...
...
@@ -40,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
/**
...
...
@@ -78,17 +79,17 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ApiResult
<
ImConversationCreateVo
>
createImConversation
(
ImConversationCreate
imConversationCreate
)
{
public
ApiResult
<
ImConversationCreateVo
>
createImConversation
(
ImConversationCreate
imConversationCreate
)
throws
JsonProcessingException
{
ImClient
client
=
imClientService
.
getCurentClient
();
ImClient
c
reateC
lient
=
imClientService
.
getCurentClient
();
// 成员不存在,不能创建会话
for
(
String
id
:
imConversationCreate
.
getClientIds
())
{
ImClient
client2
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
ImClient
imClient
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
select
(
ImClient:
:
getId
)
.
eq
(
ImClient:
:
getFkAppid
,
client
.
getFkAppid
())
.
eq
(
ImClient:
:
getFkAppid
,
c
reateC
lient
.
getFkAppid
())
.
eq
(
ImClient:
:
getClientId
,
id
));
if
(
client2
==
null
)
{
if
(
imClient
==
null
)
{
log
.
info
(
"成员不存在,不能创建会话 client2 == null"
);
return
ApiResult
.
result
(
ApiCode
.
CLIENT_NOT_FOUNT
,
null
);
}
...
...
@@ -99,23 +100,22 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
// 根据appKey查询application
ImApplication
imApplication
=
imApplicationService
.
getOneByAppKey
(
curentJwtToken
.
getAppKey
());
// 该应用 是否允许
重复创建会话
// 该应用 是否允许
创建重复会话 0不允许 1允许
if
(
imApplication
.
getRepeatSessionStatus
()
!=
null
&&
imApplication
.
getRepeatSessionStatus
()
==
0
)
{
// 判断是否已经存在会话
// 两个用户如果已经创建过会话,不能重复创建会话
// size() == 1 为单聊的时候不允许重复创建
// size() == 1 为单聊不允许重复创建 两个用户如果已经创建过会话,不能重复创建会话
if
(
imConversationCreate
.
getClientIds
().
size
()
==
1
)
{
ImClient
client2
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
client
.
getFkAppid
())
.
eq
(
ImClient:
:
getFkAppid
,
c
reateC
lient
.
getFkAppid
())
.
eq
(
ImClient:
:
getClientId
,
imConversationCreate
.
getClientIds
().
get
(
0
)));
// 是否存在重复会话
Integer
repetitionConversation
=
getRepetitionConversation
(
client
.
getId
(),
client2
.
getId
());
Integer
repetitionConversation
=
getRepetitionConversation
(
c
reateC
lient
.
getId
(),
client2
.
getId
());
if
(
repetitionConversation
!=
0
)
{
log
.
info
(
"repetitionConversation != 0"
);
// 返回已存在的会话id
ImConversation
repetitionConversationInfo
=
imConversationMapper
.
getRepetitionConversationInfo
(
client
.
getId
(),
client2
.
getId
());
ImConversation
repetitionConversationInfo
=
imConversationMapper
.
getRepetitionConversationInfo
(
c
reateC
lient
.
getId
(),
client2
.
getId
());
ImConversationCreateVo
imConversationCreateVo
=
new
ImConversationCreateVo
();
imConversationCreateVo
.
setId
(
repetitionConversationInfo
.
getId
());
...
...
@@ -127,25 +127,20 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
//创建重复会话时对比扩展字段 0不 1是
if
(
imApplication
.
getContrastExtendedFieldStatus
()
==
1
)
{
ImClient
client2
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
client
.
getFkAppid
())
// 被邀请client
ImClient
inviteClient
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
createClient
.
getFkAppid
())
.
eq
(
ImClient:
:
getClientId
,
imConversationCreate
.
getClientIds
().
get
(
0
)));
// 是否存在重复会话
Integer
repetitionConversation
=
getRepetitionConversation
(
c
lient
.
getId
(),
client2
.
getId
());
Integer
repetitionConversation
=
getRepetitionConversation
(
c
reateClient
.
getId
(),
inviteClient
.
getId
());
if
(
repetitionConversation
!=
0
)
{
ImConversation
repetitionConversationInfo
=
imConversationMapper
.
getRepetitionConversationInfo
(
c
lient
.
getId
(),
client2
.
getId
());
ImConversation
repetitionConversationInfo
=
imConversationMapper
.
getRepetitionConversationInfo
(
c
reateClient
.
getId
(),
inviteClient
.
getId
());
JsonMapper
jsonMapper
=
new
JsonMapper
();
LinkedHashMap
linkedHashMap
=
jsonMapper
.
readValue
(
repetitionConversationInfo
.
getAttributes
(),
LinkedHashMap
.
class
);
HashMap
hashMap
=
null
;
try
{
hashMap
=
jsonMapper
.
readValue
(
repetitionConversationInfo
.
getAttributes
(),
HashMap
.
class
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
if
(
imConversationCreate
.
getAttributes
().
equals
(
hashMap
))
{
if
(
linkedHashMap
.
equals
(
imConversationCreate
.
getAttributes
()))
{
log
.
info
(
imConversationCreate
.
getAttributes
()
+
",出现重复"
);
ImConversationCreateVo
imConversationCreateVo
=
new
ImConversationCreateVo
();
imConversationCreateVo
.
setId
(
repetitionConversationInfo
.
getId
());
...
...
@@ -160,34 +155,29 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
Long
imConversationId
=
SnowflakeUtil
.
getId
();
// 创建者
Long
creator
=
client
.
getId
();
Long
creator
=
c
reateC
lient
.
getId
();
// 创建会话
ImConversation
imConversation
=
new
ImConversation
();
imConversation
.
setId
(
imConversationId
);
imConversation
.
setCreateTime
(
new
Date
());
imConversation
.
setLastMessage
(
null
);
imConversation
.
setFkAppid
(
client
.
getFkAppid
());
imConversation
.
setFkAppid
(
c
reateC
lient
.
getFkAppid
());
imConversation
.
setCreator
(
creator
);
imConversation
.
setName
(
imConversationCreate
.
getName
());
imConversation
.
setSystem
(
false
);
JsonMapper
jsonMapper
=
new
JsonMapper
();
try
{
// 拓展数据
String
writeValueAsString
=
jsonMapper
.
writeValueAsString
(
imConversationCreate
.
getAttributes
());
imConversation
.
setAttributes
(
writeValueAsString
);
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
imConversationService
.
save
(
imConversation
);
// 将自己添加到会话
// 将
创建者
自己添加到会话
Long
imConversationMembersId
=
SnowflakeUtil
.
getId
();
ImConversationMembers
imConversationMembers
=
new
ImConversationMembers
();
imConversationMembers
.
setId
(
imConversationMembersId
);
imConversationMembers
.
setCreateTime
(
new
Date
());
imConversationMembers
.
setFkAppid
(
client
.
getFkAppid
());
imConversationMembers
.
setFkAppid
(
c
reateC
lient
.
getFkAppid
());
imConversationMembers
.
setFkConversationId
(
imConversationId
);
imConversationMembers
.
setFkClientId
(
creator
);
imConversationMembersService
.
save
(
imConversationMembers
);
...
...
@@ -195,13 +185,13 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
// 将他人添加到会话
for
(
String
id
:
imConversationCreate
.
getClientIds
())
{
ImClient
client2
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
.
eq
(
ImClient:
:
getFkAppid
,
client
.
getFkAppid
())
.
eq
(
ImClient:
:
getFkAppid
,
c
reateC
lient
.
getFkAppid
())
.
eq
(
ImClient:
:
getClientId
,
id
));
Long
imConversationMembersId2
=
SnowflakeUtil
.
getId
();
ImConversationMembers
imConversationMembers2
=
new
ImConversationMembers
();
imConversationMembers2
.
setId
(
imConversationMembersId2
);
imConversationMembers2
.
setCreateTime
(
new
Date
());
imConversationMembers2
.
setFkAppid
(
client
.
getFkAppid
());
imConversationMembers2
.
setFkAppid
(
c
reateC
lient
.
getFkAppid
());
imConversationMembers2
.
setFkConversationId
(
imConversationId
);
imConversationMembers2
.
setFkClientId
(
client2
.
getId
());
imConversationMembersService
.
save
(
imConversationMembers2
);
...
...
common/src/main/java/com/wecloud/im/ws/receive/ReadWsData.java
View file @
0014c016
...
...
@@ -28,8 +28,6 @@ public class ReadWsData {
@Resource
private
ReceiveStrategyContext
receiveStrategyContext
;
private
static
JsonMapper
jsonMapper
=
new
JsonMapper
();
@Resource
private
WriteDataService
writeDataService
;
...
...
@@ -51,6 +49,7 @@ public class ReadWsData {
}
// 解析json
JsonMapper
jsonMapper
=
new
JsonMapper
();
ReceiveModel
receiveModel
=
jsonMapper
.
readValue
(
data
,
ReceiveModel
.
class
);
if
(
null
==
receiveModel
||
null
==
receiveModel
.
getCmd
())
{
throw
new
BusinessException
(
"null == receiveModel || null == receiveModel.getCmd()"
);
...
...
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