MailMapper.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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="com.fjhx.email.mapper.MailMapper">
  4. <resultMap id="getMailboxInfoListByUserIdResultMap"
  5. autoMapping="true"
  6. type="com.fjhx.email.entity.dto.MailboxInfo">
  7. <id column="id" property="id"/>
  8. <result column="type" property="type"/>
  9. <result column="skip" property="skip"/>
  10. <result column="mail_user" property="mailUser"/>
  11. <result column="mail_password" property="mailPassword"/>
  12. <result column="receive_host" property="receiveHost"/>
  13. <result column="receive_port" property="receivePort"/>
  14. <result column="receive_protocol" property="receiveProtocol"/>
  15. <collection property="mailFolderInfoList"
  16. autoMapping="true"
  17. ofType="com.fjhx.email.entity.dto.MailFolderInfo"
  18. javaType="java.util.List">
  19. <id column="folder_id" property="id"/>
  20. <result column="folder_name" property="name"/>
  21. <result column="skip" property="skip"/>
  22. <result column="last_uid" property="lastUid"/>
  23. <result column="last_received_date" property="lastReceivedDate"/>
  24. </collection>
  25. </resultMap>
  26. <select id="getMailboxInfoListByUserId" resultMap="getMailboxInfoListByUserIdResultMap">
  27. select
  28. type,
  29. skip,
  30. id,
  31. mail_user,
  32. mail_password,
  33. receive_host,
  34. receive_port,
  35. receive_protocol,
  36. folder_id,
  37. folder_name,
  38. last_uid,
  39. last_received_date
  40. from (
  41. (select 1 type,
  42. 0 skip,
  43. pm.id,
  44. pm.mail_user,
  45. pm.mail_password,
  46. pm.receive_host,
  47. pm.receive_port,
  48. pm.receive_protocol,
  49. pf.id folder_id,
  50. pf.name folder_name,
  51. pf.last_uid,
  52. pf.last_received_date
  53. from personal_mailbox pm
  54. inner join personal_folder pf on pm.id = pf.mailbox_id
  55. where pm.status = 1
  56. and pm.sync_status = 1
  57. and pm.type = #{mailType}
  58. and pm.del_flag = 0
  59. and pm.user_id in
  60. <foreach collection="userIdList" item="userId" open="(" separator="," close=")">
  61. #{userId}
  62. </foreach>
  63. and pf.sync_status = 1
  64. and pf.del_flag = 0
  65. )
  66. union all
  67. (select 2 type,
  68. 0 skip,
  69. em.id,
  70. CONCAT(em.mail_user_prefix,'@',ed.domain_name) mail_user,
  71. em.mail_password,
  72. ed.receive_host,
  73. ed.receive_port,
  74. ed.receive_protocol,
  75. ef.id folder_id,
  76. ef.name folder_name,
  77. ef.last_uid,
  78. ef.last_received_date
  79. from enterprise_domain ed
  80. inner join enterprise_mailbox em on ed.id = em.domain_id
  81. inner join enterprise_folder ef on em.id = ef.mailbox_id
  82. where ed.type = #{mailType}
  83. and ed.del_flag = 0
  84. and em.status = 1
  85. and em.sync_status = 1
  86. and em.del_flag = 0
  87. and em.user_id in
  88. <foreach collection="userIdList" item="userId" open="(" separator="," close=")">
  89. #{userId}
  90. </foreach>
  91. and ef.sync_status = 1
  92. and ef.del_flag = 0
  93. )
  94. ) t
  95. ORDER BY
  96. t.id ASC,
  97. t.folder_id DESC
  98. </select>
  99. </mapper>