MailComposeMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.jeeplus.modules.iim.mapper.MailComposeMapper">
  4. <sql id="mailComposeColumns">
  5. a.id AS "id",
  6. a.status AS "status",
  7. a.readstatus AS "readstatus",
  8. a.senderid AS "sender.id",
  9. a.receiverid AS "receiver.id",
  10. a.sendtime AS "sendtime",
  11. a.mailid AS "mail.id",
  12. receiver.name AS "receiver.name",
  13. receiver.login_name AS "receiver.loginName",
  14. mail.title AS "mail.title",
  15. mail.overview AS "mail.overview",
  16. mail.content AS "mail.content"
  17. </sql>
  18. <sql id="mailComposeJoins">
  19. LEFT JOIN iim_mail mail ON mail.id = a.mailid
  20. LEFT JOIN sys_user receiver ON receiver.id = a.receiverid
  21. </sql>
  22. <resultMap type="MailCompose" id="MailMap" autoMapping="true">
  23. <association property="mail" javaType="Mail">
  24. <id property="id" column="mail.id"/>
  25. <result property="title" column="mail.title"/>
  26. <result property="overview" column="mail.overview"/>
  27. <result property="content" column="mail.content" typeHandler="com.jeeplus.core.mapper.ConvertBlobTypeHandler"/>
  28. </association>
  29. </resultMap>
  30. <select id="get" resultMap="MailMap">
  31. SELECT
  32. <include refid="mailComposeColumns"/>
  33. FROM iim_mail_compose a
  34. <include refid="mailComposeJoins"/>
  35. WHERE a.id = #{id}
  36. </select>
  37. <select id="findList" resultType="MailCompose">
  38. SELECT
  39. <include refid="mailComposeColumns"/>
  40. FROM iim_mail_compose a
  41. <include refid="mailComposeJoins"/>
  42. <where>
  43. <if test="status != null and status != ''">
  44. AND a.status = #{status}
  45. </if>
  46. <if test="mail != null and mail.title != null and mail.title != ''">
  47. AND ( mail.title like
  48. <if test="dbName == 'oracle'">'%'||#{mail.title}||'%'</if>
  49. <if test="dbName == 'mysql'">CONCAT('%', #{mail.title}, '%')</if>
  50. or
  51. mail.content like
  52. <if test="dbName == 'oracle'">'%'||#{mail.title}||'%'</if>
  53. <if test="dbName == 'mysql'">CONCAT('%', #{mail.title}, '%')</if>
  54. )
  55. </if>
  56. </where>
  57. <choose>
  58. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  59. ORDER BY ${page.orderBy}
  60. </when>
  61. <otherwise>
  62. </otherwise>
  63. </choose>
  64. </select>
  65. <select id="findAllList" resultType="MailCompose">
  66. SELECT
  67. <include refid="mailComposeColumns"/>
  68. FROM iim_mail_compose a
  69. <include refid="mailComposeJoins"/>
  70. <where>
  71. </where>
  72. <choose>
  73. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  74. ORDER BY ${page.orderBy}
  75. </when>
  76. <otherwise>
  77. </otherwise>
  78. </choose>
  79. </select>
  80. <select id="getCount" resultType="java.lang.Integer">
  81. SELECT count(*)
  82. FROM iim_mail_compose a
  83. <include refid="mailComposeJoins"/>
  84. <where>
  85. <if test="sender != null and sender.id != null and sender.id != ''">
  86. AND a.senderid = #{sender.id}
  87. </if>
  88. <if test="status !=null and status != ''">
  89. and a.status = #{status}
  90. </if>
  91. </where>
  92. </select>
  93. <insert id="insert">
  94. INSERT INTO iim_mail_compose(
  95. id,
  96. status,
  97. readstatus,
  98. senderid,
  99. receiverid,
  100. sendtime,
  101. mailid
  102. ) VALUES (
  103. #{id},
  104. #{status},
  105. #{readstatus},
  106. #{sender.id},
  107. #{receiver.id},
  108. #{sendtime},
  109. #{mail.id}
  110. )
  111. </insert>
  112. <update id="update">
  113. UPDATE iim_mail_compose SET
  114. status = #{status},
  115. readstatus = #{readstatus},
  116. senderid = #{sender.id},
  117. receiverid = #{receiver.id},
  118. sendtime = #{sendtime},
  119. mailid = #{mail.id}
  120. WHERE id = #{id}
  121. </update>
  122. <update id="delete">
  123. DELETE FROM iim_mail_compose
  124. <choose>
  125. <when test="id !=null and id != ''">
  126. WHERE id = #{id}
  127. </when>
  128. <otherwise>
  129. WHERE mailid = #{mail.id}
  130. </otherwise>
  131. </choose>
  132. </update>
  133. <!-- <update id="deleteByLogic">
  134. DELETE FROM iim_mail_compose
  135. <choose>
  136. <when test="id !=null and id != ''">
  137. WHERE id = #{id}
  138. </when>
  139. <otherwise>
  140. WHERE mailid = #{mail.id}
  141. </otherwise>
  142. </choose>
  143. </update>-->
  144. </mapper>