ImMessageMapper.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.ubitech.ttc.dao.ImMessageMapper">
  4. <!-- 开启二级缓存 -->
  5. <!--<cache type="org.mybatis.caches.ehcache.EhcacheCache">-->
  6. <!--<property name="timeToIdleSeconds" value="3600"/>-->
  7. <!--<property name="timeToLiveSeconds" value="3600"/>-->
  8. <!--<property name="maxEntriesLocalHeap" value="1000"/>-->
  9. <!--<property name="maxEntriesLocalDisk" value="10000000"/>-->
  10. <!--<property name="memoryStoreEvictionPolicy" value="LRU"/>-->
  11. <!--</cache>-->
  12. <select id="getUserMessage" resultType="cn.ubitech.ttc.model.im.IMMessageModel">
  13. SELECT i.*
  14. FROM (select *
  15. from im_message
  16. where userid = #{userid} and reciverid = #{reciverid} and type = #{type}
  17. and isactive = 1
  18. union select *
  19. from im_message
  20. where userid = #{reciverid} and reciverid = #{userid} and type = #{type} and isactive = 1) i
  21. <if test='snowflakeid != "0"'>
  22. where i.messageid &lt; #{snowflakeid}
  23. </if>
  24. ORDER by i.messagetime DESC
  25. </select>
  26. <select id="getUserMessageCount" resultType="java.lang.Integer">
  27. SELECT count(*)
  28. from (
  29. SELECT i.*
  30. FROM (select *
  31. from im_message
  32. where userid = #{userid} and reciverid = #{reciverid} and type = #{type}
  33. and isactive = 1
  34. union select *
  35. from im_message
  36. where
  37. userid = #{userid} and reciverid = #{reciverid} and type = #{type} and isactive = 1) i
  38. <if test='snowflakeid != "0"'>
  39. where i.messageid &lt; #{snowflakeid}
  40. </if>
  41. ) b
  42. </select>
  43. </mapper>