Commit 035431ed authored by liming's avatar liming

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

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