Commit b6efe36f by giaogiao

// 判断是否已经存在会话

        // 两个用户如果已经创建过会话,不能重复创建会话 返回已存在的会话id
        // size() == 1 为单聊的时候不允许重复创建
parent fa6458c9
...@@ -70,17 +70,17 @@ ...@@ -70,17 +70,17 @@
<!-- 公众号(包括订阅号和服务号):weixin-java-mp --> <!-- 公众号(包括订阅号和服务号):weixin-java-mp -->
<dependency> <!-- <dependency>-->
<groupId>com.github.binarywang</groupId> <!-- <groupId>com.github.binarywang</groupId>-->
<artifactId>weixin-java-mp</artifactId> <!-- <artifactId>weixin-java-mp</artifactId>-->
<version>4.0.0</version> <!-- <version>4.0.0</version>-->
</dependency> <!-- </dependency>-->
<dependency> <!-- <dependency>-->
<groupId>com.github.binarywang</groupId> <!-- <groupId>com.github.binarywang</groupId>-->
<artifactId>weixin-java-pay</artifactId> <!-- <artifactId>weixin-java-pay</artifactId>-->
<version>4.0.0</version> <!-- <version>4.0.0</version>-->
</dependency> <!-- </dependency>-->
<!-- fastbootWeixin的核心依赖 --> <!-- fastbootWeixin的核心依赖 -->
......
...@@ -64,4 +64,14 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> { ...@@ -64,4 +64,14 @@ public interface ImConversationMapper extends BaseMapper<ImConversation> {
* @return * @return
*/ */
Integer getRepetitionConversation(@Param("clientId1") Long clientId1, @Param("clientId2") Long clientId2); Integer getRepetitionConversation(@Param("clientId1") Long clientId1, @Param("clientId2") Long clientId2);
/**
* 查询已经存在的会话信息
*
* @param clientId1
* @param clientId2
* @return
*/
ImConversation getRepetitionConversationInfo(@Param("clientId1") Long clientId1, @Param("clientId2") Long clientId2);
} }
...@@ -90,15 +90,23 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -90,15 +90,23 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
// 判断是否已经存在会话 // 判断是否已经存在会话
// 两个用户如果已经创建过会话,不能重复创建会话 // 两个用户如果已经创建过会话,不能重复创建会话
// size() == 1 为单聊的时候不允许重复创建
if (imConversationCreate.getClientIds().size() == 1) { if (imConversationCreate.getClientIds().size() == 1) {
ImClient client2 = imClientService.getOne(new QueryWrapper<ImClient>().lambda() ImClient client2 = imClientService.getOne(new QueryWrapper<ImClient>().lambda()
.eq(ImClient::getFkAppid, client.getFkAppid()) .eq(ImClient::getFkAppid, client.getFkAppid())
.eq(ImClient::getClientId, imConversationCreate.getClientIds().get(0))); .eq(ImClient::getClientId, imConversationCreate.getClientIds().get(0)));
// 是否存在重复会话
Integer repetitionConversation = getRepetitionConversation(client.getId(), client2.getId()); Integer repetitionConversation = getRepetitionConversation(client.getId(), client2.getId());
if (repetitionConversation != 0) { if (repetitionConversation != 0) {
log.debug("repetitionConversation != 0"); log.debug("repetitionConversation != 0");
return ApiResult.result(ApiCode.REPETITION_CONVERSATION, null); // 返回已存在的会话id
ImConversation repetitionConversationInfo = imConversationMapper.getRepetitionConversationInfo(client.getId(), client2.getId());
ImConversationCreateVo imConversationCreateVo = new ImConversationCreateVo();
imConversationCreateVo.setId(repetitionConversationInfo.getId());
return ApiResult.result(ApiCode.REPETITION_CONVERSATION, imConversationCreateVo);
} }
} }
......
...@@ -71,5 +71,17 @@ ...@@ -71,5 +71,17 @@
) AS r1 ) AS r1
WHERE members_count = 2 WHERE members_count = 2
</select> </select>
<select id="getRepetitionConversationInfo" resultType="com.wecloud.im.entity.ImConversation">
SELECT im_conversation.*
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
INNER JOIN im_conversation ON im_conversation.id = im_conversation_members.fk_conversation_id
WHERE im_conversation_members.fk_client_id = #{clientId1}
</select>
</mapper> </mapper>
...@@ -257,39 +257,6 @@ mybatis-plus: ...@@ -257,39 +257,6 @@ mybatis-plus:
mapper-locations: classpath*:mapper/**/*Mapper.xml mapper-locations: classpath*:mapper/**/*Mapper.xml
################################ mybatis-plus end ################################## ################################ mybatis-plus end ##################################
wx:
# token: sDsdaSDADad
# # 测试号的appid,测试号管理界面有
# appid: wx7aac805012428dc5
# # 测试号的appsecret,测试号管理界面有
# appsecret:
# # =服务调用的url地址,用于微信web的oauth2授权回调等,若没有可为空。
# callback-url: wx7aac805012428dc5
#
mp:
useRedis: false
redisConfig:
host: 127.0.0.1
port: 6379
configs:
- appId: wxe4a696e431b0456b # 第一个公众号的appid
secret: 87dbca535a713cd505be2f928fa84c29 # 公众号的appsecret
token: 111 # 接口配置里的Token值
aesKey: 111 # 接口配置里的EncodingAESKey值
- appId: 2222 # 第二个公众号的appid,以下同上
secret: 1111
token: 111
aesKey: 111
pay:
appId: wxe4a696e431b0456b #微信公众号或者小程序等的appid
mchId: 1606818547 #微信支付商户号
mchKey: H0p6dhiXRr5FocmzZluNVqyG7QALISj1 #微信支付商户密钥
# subAppId: #服务商模式下的子商户公众账号ID
# subMchId: #服务商模式下的子商户号
keyPath: classpath:src/main/java/io/geekidea/springbootplus/config/properties/apiclient_cert.p12 # p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头)
############################### HikariCP 数据源配置 start ################################ ############################### HikariCP 数据源配置 start ################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment