SysNoticeMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.aidex.system.mapper.SysNoticeMapper">
  6. <sql id="sysNoticeColumns">
  7. a.id as "id",
  8. a.notice_title as "noticeTitle",
  9. a.notice_type as "noticeType",
  10. cast(a.notice_content as char) AS "noticeContent",
  11. cast(a.notice_content_html as char) AS "noticeContentHtml",
  12. a.status AS "status",
  13. a.create_by AS "createBy",
  14. a.create_time AS "createTime",
  15. a.update_by AS "updateBy",
  16. a.update_time AS "updateTime",
  17. a.update_ip AS "updateIp",
  18. a.remark AS "remark",
  19. a.version AS "version"
  20. </sql>
  21. <sql id="sysNoticeJoins">
  22. </sql>
  23. <sql id="sysNoticeOrderBy">
  24. order by a.create_time desc
  25. </sql>
  26. <select id="get" resultType="SysNotice">
  27. SELECT
  28. <include refid="sysNoticeColumns"/>
  29. FROM sys_notice a
  30. where id = #{id}
  31. </select>
  32. <select id="findList" resultType="SysNotice">
  33. SELECT
  34. <include refid="sysNoticeColumns"/>,
  35. su.name AS "createByName"
  36. FROM sys_notice a
  37. left join sys_user su
  38. on su.id = a.create_by
  39. <include refid="sysNoticeJoins"/>
  40. where a.del_flag = #{DEL_FLAG_NORMAL}
  41. <if test="noticeTitle != null and noticeTitle != ''">
  42. AND a.notice_title like concat('%', #{noticeTitle}, '%')
  43. </if>
  44. <if test="noticeType != null and noticeType != ''">
  45. AND a.notice_type = #{noticeType}
  46. </if>
  47. <if test="createBy != null and createBy != ''">
  48. AND su.name like concat('%', #{createBy}, '%')
  49. </if>
  50. <include refid="sysNoticeOrderBy"/>
  51. </select>
  52. <insert id="insert" parameterType="SysNotice">
  53. insert into sys_notice (
  54. id,
  55. notice_title,
  56. notice_type,
  57. notice_content,
  58. notice_content_html,
  59. status,
  60. remark,
  61. create_by,
  62. create_dept,
  63. create_time,
  64. update_by,
  65. update_time,
  66. update_ip,
  67. del_flag,
  68. version
  69. )values(
  70. #{id},
  71. #{noticeTitle},
  72. #{noticeType},
  73. #{noticeContent},
  74. #{noticeContentHtml},
  75. #{status},
  76. #{remark},
  77. #{createBy},
  78. #{createDept},
  79. #{createTime},
  80. #{updateBy},
  81. #{updateTime},
  82. #{updateIp},
  83. #{DEL_FLAG_NORMAL},
  84. 1
  85. )
  86. </insert>
  87. <update id="update" parameterType="SysNotice">
  88. update sys_notice
  89. <set>
  90. <if test="noticeTitle != null and noticeTitle != ''">
  91. notice_title = #{noticeTitle},
  92. </if>
  93. <if test="noticeType != null and noticeType != ''">
  94. notice_type = #{noticeType},
  95. </if>
  96. <if test="noticeContent != null">
  97. notice_content = #{noticeContent},
  98. </if>
  99. <if test="noticeContentHtml != null">
  100. notice_content_html = #{noticeContentHtml},
  101. </if>
  102. <if test="status != null and status != ''">
  103. status = #{status},
  104. </if>
  105. <if test="updateBy != null and updateBy != ''">
  106. update_by = #{updateBy},
  107. </if>
  108. <if test="updateTime != null">
  109. update_time = #{updateTime},
  110. </if>
  111. <if test="updateIp != null and updateIp != ''">
  112. update_ip = #{updateIp},
  113. </if>
  114. version = version + 1
  115. </set>
  116. where id = #{id}
  117. </update>
  118. <delete id="delete">
  119. UPDATE sys_notice SET
  120. del_flag = #{DEL_FLAG_DELETE}
  121. WHERE id = #{id}
  122. </delete>
  123. <update id="deleteNoticeByIds" parameterType="java.util.Map">
  124. UPDATE sys_notice SET
  125. del_flag = #{DEL_FLAG_DELETE}
  126. WHERE id in
  127. <foreach collection="noticeIds" item="ids" open="(" separator="," close=")">
  128. #{ids}
  129. </foreach>
  130. </update>
  131. <select id="getNoticeListByUserId" resultType="SysNotice">
  132. SELECT
  133. id,
  134. notice_title as 'noticeTitle'
  135. FROM
  136. `sys_notice` a
  137. WHERE
  138. NOT EXISTS (
  139. SELECT
  140. 1
  141. FROM
  142. sys_notice_user_read t
  143. WHERE
  144. a.id = t.notice_id
  145. AND t.user_id = #{userId}
  146. )
  147. AND a.del_flag = #{DEL_FLAG_NORMAL}
  148. <include refid="sysNoticeOrderBy"/>
  149. </select>
  150. <select id="findNoticeByUserList" resultType="SysNotice">
  151. SELECT
  152. <include refid="sysNoticeColumns"/>,
  153. su.name AS "createByName",
  154. r.is_read AS "isRead"
  155. FROM sys_notice a
  156. left join sys_user su
  157. on su.id = a.create_by
  158. LEFT JOIN sys_notice_user_read r ON a.id = r.notice_id and r.user_id = #{userId}
  159. where a.del_flag = #{DEL_FLAG_NORMAL} and (r.del_flag = #{DEL_FLAG_NORMAL} or r.id is null)
  160. <if test="noticeTitle != null and noticeTitle != ''">
  161. AND a.notice_title like concat('%', #{noticeTitle}, '%')
  162. </if>
  163. <if test="noticeType != null and noticeType != ''">
  164. AND a.notice_type = #{noticeType}
  165. </if>
  166. <if test="createBy != null and createBy != ''">
  167. AND su.name like concat('%', #{createBy}, '%')
  168. </if>
  169. <include refid="sysNoticeOrderBy"/>
  170. </select>
  171. </mapper>