Commit e739a814 by 罗长华

Merge remote-tracking branch 'origin/xiaohudou_20220427' into xiaohudou_20220427

parents 517108e0 142894ae
......@@ -48,6 +48,9 @@ public class ImMessage extends BaseEntity {
@ApiModelProperty("发送者客户端id")
private Long sender;
@ApiModelProperty("接收人,多人用英文逗号分隔-群内指定人员可见场景")
private String receivers;
/**
* 数据库字段类型为JSON格式
* 因mysql关系型数据库非MongoDB文档类型数据库,第三方应用拓展的自定义参数名和值需使用json格式落库
......
......@@ -78,7 +78,7 @@ public interface ImMessageMapper extends BaseMapper<ImMessage> {
* @param conversationId
* @return
*/
OfflineMsgDto getLastMsgByConversationId(@Param("conversationId") Long conversationId);
OfflineMsgDto getLastMsgByConversationId(@Param("conversationId") Long conversationId, @Param("currentFkClientId") Long currentFkClientId);
/**
* 获取一条消息已读人员和未读人员
......
......@@ -118,7 +118,7 @@ public interface ImMessageService extends BaseService<ImMessage> {
* @param conversationId
* @return
*/
OfflineMsgDto getLastMsgByConversationId(Long conversationId);
OfflineMsgDto getLastMsgByConversationId(Long conversationId, Long currentFkClientId);
/**
* 查询会话接收的最后一条消息
......
......@@ -784,7 +784,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
myconversationlistvo.setAttributes(attributess);
// 查询会话的最后一条消息
OfflineMsgDto lastMsg = imMessageService.getLastMsgByConversationId(myconversationlistvo.getId());
OfflineMsgDto lastMsg = imMessageService.getLastMsgByConversationId(myconversationlistvo.getId(), currentClient.getId());
myconversationlistvo.setLastMsg(lastMsg);
if (myconversationlistvo.getBeAtCount() > 0) {
myconversationlistvo.setIsBeAt(Boolean.TRUE);
......@@ -824,7 +824,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
HashMap attributess = JsonUtils.json2Map(conversationVo.getAttribute());
conversationVo.setAttributes(attributess);
// 查询会话的最后一条消息
OfflineMsgDto lastMsg = imMessageService.getLastMsgByConversationId(conversationVo.getId());
OfflineMsgDto lastMsg = imMessageService.getLastMsgByConversationId(conversationVo.getId(), client.getId());
conversationVo.setLastMsg(lastMsg);
return conversationVo;
} catch (Exception e) {
......
......@@ -597,8 +597,8 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
}
@Override
public OfflineMsgDto getLastMsgByConversationId(Long conversationId) {
return imMessageMapper.getLastMsgByConversationId(conversationId);
public OfflineMsgDto getLastMsgByConversationId(Long conversationId, Long currentFkClientId) {
return imMessageMapper.getLastMsgByConversationId(conversationId, currentFkClientId);
}
@Override
......@@ -671,7 +671,6 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
@Override
public Boolean groupStatusMessagePublish(GroupChatStatusMessageParam param) {
Long appId = SecurityUtils.getCurrentAppId();
ImApplication application = imApplicationService.getCacheById(appId);
// 获取发件人信息
String senderClientId = param.getFromUserId();
ImClient sender = imClientService.getCacheImClient(appId, senderClientId);
......@@ -711,6 +710,14 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
// 组装消息
ImMessage message = assembleImMessage(appId, sender, conversation.getId(), param.getMessageType(), true,
param.getContent());
if (isToUser && CollectionUtils.isNotEmpty(membersList)) {
// 指定群内成员发送 落库接收人 仅限少量接收人场景时落库
List<Long> memberFkClientIds = membersList.stream().map(m -> m.getFkClientId()).collect(Collectors.toList());
String receivers = StringUtils.join(memberFkClientIds, ",");
if (receivers.length() < 200) {
message.setReceivers(receivers);
}
}
// 持久化
this.save(message);
// 拼装发送消息体
......
......@@ -73,7 +73,7 @@
FROM `im_message`
INNER JOIN `im_client` ON `im_client`.id = `im_message`.sender
WHERE fk_conversation_id = #{param.conversationId} and im_message.is_delete = 1 and im_message.withdraw = 0
and (im_message.`event`=0 || (im_message.`event`=1 and sender != #{param.currentFkClientId} ))
and (im_message.`event`=0 || (im_message.`event`=1 and sender != #{param.currentFkClientId} and (receivers is null || (receivers !=null and FIND_IN_SET(#{param.currentFkClientId}, receivers))) ))
<if test="param.msgIdStart != null">
AND im_message.id > #{param.msgIdStart}
</if>
......@@ -107,7 +107,7 @@
FROM `im_message`
INNER JOIN `im_client` ON `im_client`.id = `im_message`.sender
WHERE fk_conversation_id = #{param.conversationId} and im_message.is_delete = 1 and im_message.withdraw = 0
and (im_message.`event`=0 || (im_message.`event`=1 and sender != #{param.currentFkClientId} ))
and (im_message.`event`=0 || (im_message.`event`=1 and sender != #{param.currentFkClientId} and (receivers is null || (receivers !=null and FIND_IN_SET(#{param.currentFkClientId}, receivers))) ))
<if test="param.msgIdStart != null">
AND im_message.id > #{param.msgIdStart}
</if>
......@@ -146,6 +146,7 @@
AND im_inbox.fk_conversation_id = #{conversationId}
ORDER BY create_time DESC LIMIT 1
</select>
<select id="getLastMsgByConversationId" resultType="com.wecloud.im.vo.OfflineMsgDto">
SELECT im_message.id AS msgId,
im_message.create_time,
......@@ -162,6 +163,8 @@
FROM im_message
INNER JOIN im_client AS im_client ON im_client.id = im_message.sender
WHERE im_message.fk_conversation_id = #{conversationId}
and (im_message.`event`=0 || (im_message.`event`=1 and sender != #{currentFkClientId} and (receivers is null || (receivers !=null and FIND_IN_SET(#{currentFkClientId}, receivers))) ))
ORDER BY create_time DESC LIMIT 1
</select>
......
-- 在feature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
-- 在feature-cluster 2021年12月22日之后,需要执行的的sql增量脚本
......@@ -160,6 +160,10 @@ ALTER TABLE im_conversation
ADD COLUMN head_portrait varchar(1000) DEFAULT NULL COMMENT '群头像';
ALTER TABLE im_message
ADD COLUMN receivers varchar(200) DEFAULT NULL COMMENT '接收人,多人用英文逗号分隔-群内指定人员可见场景';
DROP TABLE IF EXISTS `im_rtc_record`;
CREATE TABLE `im_rtc_record`
......
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