Commit b6eafe5f authored by liming's avatar liming

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

parent afa6efa7
package com.antai.sport.http.server.constants;
public class ChartHistoryStatus {
public static final Integer UN_READ = 1;
public static final Integer READ = 2;
}
...@@ -10,4 +10,6 @@ public interface SportChatHistoryBusinessMapper { ...@@ -10,4 +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);
} }
package com.antai.sport.http.server.mobile.api.business.sport.social.service; package com.antai.sport.http.server.mobile.api.business.sport.social.service;
import com.antai.sport.http.server.constants.ChartHistoryStatus;
import com.antai.sport.http.server.mobile.api.business.sport.social.dto.ReqChatHistoryQueryParam; import com.antai.sport.http.server.mobile.api.business.sport.social.dto.ReqChatHistoryQueryParam;
import com.antai.sport.http.server.mobile.api.business.sport.social.dto.ReqChatMessage; import com.antai.sport.http.server.mobile.api.business.sport.social.dto.ReqChatMessage;
import com.antai.sport.http.server.mobile.api.business.sport.social.dto.RespChatHistory; import com.antai.sport.http.server.mobile.api.business.sport.social.dto.RespChatHistory;
...@@ -29,6 +30,7 @@ public class ChatService { ...@@ -29,6 +30,7 @@ public class ChatService {
history.setContent(message.getContent()); history.setContent(message.getContent());
history.setRoomKey(message.getRoomKey()); history.setRoomKey(message.getRoomKey());
history.setCtDate(LocalDateTime.now()); history.setCtDate(LocalDateTime.now());
history.setStatus(ChartHistoryStatus.UN_READ);
sportChatHistoryMapper.insert(history); sportChatHistoryMapper.insert(history);
return history.getId(); return history.getId();
} }
...@@ -38,6 +40,9 @@ public class ChatService { ...@@ -38,6 +40,9 @@ public class ChatService {
param.setQuerySize(20); param.setQuerySize(20);
} }
List<RespChatHistory> resultList = sportChatHistoryBusinessMapper.getChatHistory(param); List<RespChatHistory> resultList = sportChatHistoryBusinessMapper.getChatHistory(param);
if (!resultList.isEmpty()) {
sportChatHistoryBusinessMapper.updateChartHistoryStatus(resultList);
}
Collections.reverse(resultList); Collections.reverse(resultList);
return resultList; return resultList;
} }
......
...@@ -13,4 +13,12 @@ ...@@ -13,4 +13,12 @@
order by t1.id desc order by t1.id desc
limit #{param.querySize} limit #{param.querySize}
</select> </select>
<update id="updateChartHistoryStatus">
update sport_chat_history set status = 2
where id in
<foreach collection="historyList" item="item" open="(" separator="," close=")">
#{item.id}
</foreach>
</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