Commit 035431ed authored by liming's avatar liming

聊天记录已读未读状态更新

parent c970d5b0
......@@ -36,8 +36,8 @@ public class ChatController {
@ApiOperation(value = "查询聊天记录")
@PostMapping("history")
public ResponseEntity<Result<List<RespChatHistory>>> getChatHistory(@RequestBody ReqChatHistoryQueryParam param) {
return success(chatService.getChatHistory(param));
public ResponseEntity<Result<List<RespChatHistory>>> getChatHistory(@RequestBody ReqChatHistoryQueryParam param, @LoginSportUser SportUser loginUser) {
return success(chatService.getChatHistory(param, loginUser));
}
......
......@@ -10,6 +10,6 @@ public interface SportChatHistoryBusinessMapper {
List<RespChatHistory> getChatHistory(@Param("param") ReqChatHistoryQueryParam param);
void updateChartHistoryStatus(@Param("historyList") List<RespChatHistory> historyList);
void updateChartHistoryStatus(@Param("roomKey") String roomKey, @Param("sportUserId") Long sportUserId);
}
......@@ -35,14 +35,13 @@ public class ChatService {
return history.getId();
}
public List<RespChatHistory> getChatHistory(ReqChatHistoryQueryParam param) {
public List<RespChatHistory> getChatHistory(ReqChatHistoryQueryParam param, SportUser loginUser) {
if (param.getQuerySize() == null || param.getQuerySize() == 0) {
param.setQuerySize(20);
}
List<RespChatHistory> resultList = sportChatHistoryBusinessMapper.getChatHistory(param);
if (!resultList.isEmpty()) {
sportChatHistoryBusinessMapper.updateChartHistoryStatus(resultList);
}
//更新消息状态为已读
sportChatHistoryBusinessMapper.updateChartHistoryStatus(param.getRoomKey(), loginUser.getId());
Collections.reverse(resultList);
return resultList;
}
......
......@@ -16,9 +16,6 @@
<update id="updateChartHistoryStatus">
update sport_chat_history set status = 2
where id in
<foreach collection="historyList" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
where room_key = #{roomKey} and receiver_id = #{sportUserId} and status = 1
</update>
</mapper>
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