|
@@ -14,6 +14,10 @@ import java.util.List;
|
|
*/
|
|
*/
|
|
@Mapper
|
|
@Mapper
|
|
public interface HistoryMapper {
|
|
public interface HistoryMapper {
|
|
|
|
+ /**
|
|
|
|
+ * 添加一条聊天记录
|
|
|
|
+ * @param history
|
|
|
|
+ */
|
|
@Select("insert into history (chat_id, u1_to_u2, message_type, message_body, send_time)\n" +
|
|
@Select("insert into history (chat_id, u1_to_u2, message_type, message_body, send_time)\n" +
|
|
"values (#{chatId}, #{u1ToU2}, #{messageType}, #{messageBody}, #{sendTime});")
|
|
"values (#{chatId}, #{u1ToU2}, #{messageType}, #{messageBody}, #{sendTime});")
|
|
void addHistory(History history);
|
|
void addHistory(History history);
|
|
@@ -21,6 +25,7 @@ public interface HistoryMapper {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取自己和所有人的最后一条"已读的"聊天记录,按时间倒序
|
|
* 获取自己和所有人的最后一条"已读的"聊天记录,按时间倒序
|
|
|
|
+ *
|
|
* @param unreadChatIds 未读的chatId
|
|
* @param unreadChatIds 未读的chatId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -37,7 +42,7 @@ public interface HistoryMapper {
|
|
" </foreach>\n" +
|
|
" </foreach>\n" +
|
|
" and ((u1 = 1 and show_to_u1 = true) or (u2 = 1 and show_to_u2 = true)))\n" +
|
|
" and ((u1 = 1 and show_to_u1 = true) or (u2 = 1 and show_to_u2 = true)))\n" +
|
|
" group by chat_id) as foo on foo.chat_id = history.chat_id and foo.max_time = history.send_time\n" +
|
|
" group by chat_id) as foo on foo.chat_id = history.chat_id and foo.max_time = history.send_time\n" +
|
|
- " inner join chat where history.chat_id = chat.id\n"+
|
|
|
|
|
|
+ " inner join chat where history.chat_id = chat.id\n" +
|
|
"order by send_time desc" +
|
|
"order by send_time desc" +
|
|
"</script>")
|
|
"</script>")
|
|
List<HistoryExample> getLastReadChat(@Param("unreadChatIds") List<Integer> unreadChatIds);
|
|
List<HistoryExample> getLastReadChat(@Param("unreadChatIds") List<Integer> unreadChatIds);
|
|
@@ -45,6 +50,7 @@ public interface HistoryMapper {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取自己和所有人的最后一条聊天记录,按时间倒序
|
|
* 获取自己和所有人的最后一条聊天记录,按时间倒序
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Select("select history.chat_id, history.message_type, history.message_body, history.send_time, chat.u1, chat.u2, chat.goods_id\n" +
|
|
@Select("select history.chat_id, history.message_type, history.message_body, history.send_time, chat.u1, chat.u2, chat.goods_id\n" +
|
|
@@ -54,14 +60,19 @@ public interface HistoryMapper {
|
|
" where chat_id in\n" +
|
|
" where chat_id in\n" +
|
|
" (select id from chat where ((u1 = 1 and show_to_u1 = true) or (u2 = 1 and show_to_u2 = true)))\n" +
|
|
" (select id from chat where ((u1 = 1 and show_to_u1 = true) or (u2 = 1 and show_to_u2 = true)))\n" +
|
|
" group by chat_id) as foo on foo.chat_id = history.chat_id and foo.max_time = history.send_time\n" +
|
|
" group by chat_id) as foo on foo.chat_id = history.chat_id and foo.max_time = history.send_time\n" +
|
|
- " inner join chat where history.chat_id = chat.id\n"+
|
|
|
|
|
|
+ " inner join chat where history.chat_id = chat.id\n" +
|
|
"order by send_time desc")
|
|
"order by send_time desc")
|
|
List<HistoryExample> getLastChat();
|
|
List<HistoryExample> getLastChat();
|
|
|
|
|
|
-// @Select("select message_type,hint,message_body,create_time\n" +
|
|
|
|
-// "from chat_history\n" +
|
|
|
|
-// "where chat_user_id = 1\n" +
|
|
|
|
-// "ORDER BY create_time DESC\n" +
|
|
|
|
-// "LIMIT 1")
|
|
|
|
-// History getMostRecentByChatId(@Param("chat_user_id")Integer chatUserId);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据chatId获取聊天记录
|
|
|
|
+ * @param chat_id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Select("select u1_to_u2, message_type, message_body, send_time\n" +
|
|
|
|
+ "from history\n" +
|
|
|
|
+ "where chat_id = #{chat_id}")
|
|
|
|
+ List<History> getChatHistory(@Param("chat_id") int chat_id);
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|