Commit 142894ae by Future

最近一条消息逻辑调整

parent 5bc4f004
...@@ -78,7 +78,7 @@ public interface ImMessageMapper extends BaseMapper<ImMessage> { ...@@ -78,7 +78,7 @@ public interface ImMessageMapper extends BaseMapper<ImMessage> {
* @param conversationId * @param conversationId
* @return * @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> { ...@@ -118,7 +118,7 @@ public interface ImMessageService extends BaseService<ImMessage> {
* @param conversationId * @param conversationId
* @return * @return
*/ */
OfflineMsgDto getLastMsgByConversationId(Long conversationId); OfflineMsgDto getLastMsgByConversationId(Long conversationId, Long currentFkClientId);
/** /**
* 查询会话接收的最后一条消息 * 查询会话接收的最后一条消息
......
...@@ -784,7 +784,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -784,7 +784,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
myconversationlistvo.setAttributes(attributess); myconversationlistvo.setAttributes(attributess);
// 查询会话的最后一条消息 // 查询会话的最后一条消息
OfflineMsgDto lastMsg = imMessageService.getLastMsgByConversationId(myconversationlistvo.getId()); OfflineMsgDto lastMsg = imMessageService.getLastMsgByConversationId(myconversationlistvo.getId(), currentClient.getId());
myconversationlistvo.setLastMsg(lastMsg); myconversationlistvo.setLastMsg(lastMsg);
if (myconversationlistvo.getBeAtCount() > 0) { if (myconversationlistvo.getBeAtCount() > 0) {
myconversationlistvo.setIsBeAt(Boolean.TRUE); myconversationlistvo.setIsBeAt(Boolean.TRUE);
...@@ -824,7 +824,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap ...@@ -824,7 +824,7 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
HashMap attributess = JsonUtils.json2Map(conversationVo.getAttribute()); HashMap attributess = JsonUtils.json2Map(conversationVo.getAttribute());
conversationVo.setAttributes(attributess); conversationVo.setAttributes(attributess);
// 查询会话的最后一条消息 // 查询会话的最后一条消息
OfflineMsgDto lastMsg = imMessageService.getLastMsgByConversationId(conversationVo.getId()); OfflineMsgDto lastMsg = imMessageService.getLastMsgByConversationId(conversationVo.getId(), client.getId());
conversationVo.setLastMsg(lastMsg); conversationVo.setLastMsg(lastMsg);
return conversationVo; return conversationVo;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -597,8 +597,8 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes ...@@ -597,8 +597,8 @@ public class ImMessageServiceImpl extends BaseServiceImpl<ImMessageMapper, ImMes
} }
@Override @Override
public OfflineMsgDto getLastMsgByConversationId(Long conversationId) { public OfflineMsgDto getLastMsgByConversationId(Long conversationId, Long currentFkClientId) {
return imMessageMapper.getLastMsgByConversationId(conversationId); return imMessageMapper.getLastMsgByConversationId(conversationId, currentFkClientId);
} }
@Override @Override
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
FROM `im_message` FROM `im_message`
INNER JOIN `im_client` ON `im_client`.id = `im_message`.sender 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 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"> <if test="param.msgIdStart != null">
AND im_message.id > #{param.msgIdStart} AND im_message.id > #{param.msgIdStart}
</if> </if>
...@@ -146,6 +146,7 @@ ...@@ -146,6 +146,7 @@
AND im_inbox.fk_conversation_id = #{conversationId} AND im_inbox.fk_conversation_id = #{conversationId}
ORDER BY create_time DESC LIMIT 1 ORDER BY create_time DESC LIMIT 1
</select> </select>
<select id="getLastMsgByConversationId" resultType="com.wecloud.im.vo.OfflineMsgDto"> <select id="getLastMsgByConversationId" resultType="com.wecloud.im.vo.OfflineMsgDto">
SELECT im_message.id AS msgId, SELECT im_message.id AS msgId,
im_message.create_time, im_message.create_time,
...@@ -162,6 +163,8 @@ ...@@ -162,6 +163,8 @@
FROM im_message FROM im_message
INNER JOIN im_client AS im_client ON im_client.id = im_message.sender INNER JOIN im_client AS im_client ON im_client.id = im_message.sender
WHERE im_message.fk_conversation_id = #{conversationId} 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 ORDER BY create_time DESC LIMIT 1
</select> </select>
......
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