ChatDialogMapper.xml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="cn.reghao.tnb.content.app.im.db.mapper.ChatDialogMapper">
  4. <insert id="save" useGeneratedKeys="true" keyProperty="id">
  5. insert into chat_chat_dialog
  6. (`chat_id`,`chat_type`,`receiver_id`,`disturb`,`robot`,`top`,`display`,`user_id`,`unread_num`)
  7. values
  8. (#{chatId},#{chatType},#{receiverId},#{disturb},#{robot},#{top},#{display},#{userId},#{unreadNum})
  9. </insert>
  10. <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
  11. insert into chat_chat_dialog
  12. (`chat_id`,`chat_type`,`receiver_id`,`disturb`,`robot`,`top`,`display`,`user_id`,`unread_num`)
  13. values
  14. <foreach collection="list" item="item" index="index" separator=",">
  15. (#{item.chatId},#{item.chatType},#{item.receiverId},#{item.disturb},#{item.robot},#{item.top},#{item.display},#{item.userId},#{item.unreadNum})
  16. </foreach>
  17. </insert>
  18. <update id="updateSetDisturb">
  19. update chat_chat_dialog set update_time=now(),disturb=#{disturb}
  20. where id=#{dialogId} and user_id=#{userId}
  21. </update>
  22. <update id="updateSetTop">
  23. update chat_chat_dialog set update_time=now(),top=#{top}
  24. where id=#{dialogId} and user_id=#{userId}
  25. </update>
  26. <update id="updateSetDisplay">
  27. update chat_chat_dialog set update_time=now(),display=#{display}
  28. where id=#{dialogId} and user_id=#{userId}
  29. </update>
  30. <update id="updateSetClearUnread">
  31. update chat_chat_dialog set update_time=now(),unread_num=unread_num+1
  32. where receiver_id=#{receiverId} and user_id=#{userId}
  33. </update>
  34. <update id="updateSetIncreaseUnread">
  35. update chat_chat_dialog set update_time=now(),unread_num=0
  36. where receiver_id=#{receiverId} and user_id=#{userId}
  37. </update>
  38. <delete id="deleteGroupChatDialog">
  39. delete from chat_chat_dialog
  40. where receiver_id=#{groupId} and user_id in
  41. <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
  42. #{item}
  43. </foreach>
  44. </delete>
  45. <select id="findByReceiverAndUserId" resultType="cn.reghao.tnb.content.app.im.model.po.chat.ChatDialog">
  46. select * from chat_chat_dialog where receiver_id=#{receiverId} and user_id=#{userId}
  47. </select>
  48. <select id="findChatDialog" resultType="cn.reghao.tnb.content.app.im.model.po.chat.ChatDialog">
  49. select * from chat_chat_dialog
  50. where chat_type=#{chatType} and receiver_id=#{receiverId} and user_id=#{userId}
  51. </select>
  52. <select id="findChatDialogsByUserId" resultType="cn.reghao.tnb.content.app.im.model.po.chat.ChatDialog">
  53. select *
  54. from chat_chat_dialog
  55. where display is true and user_id=#{userId}
  56. </select>
  57. </mapper>