SysNoticeMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. a.topping AS "topping",
  21. a.carousel_img_url AS "carouselImgUrl",
  22. a.carousel AS "carousel"
  23. </sql>
  24. <sql id="sysNoticeJoins">
  25. </sql>
  26. <sql id="sysNoticeOrderBy">
  27. order by topping desc, a.create_time desc
  28. </sql>
  29. <select id="get" resultType="SysNotice">
  30. SELECT
  31. <include refid="sysNoticeColumns"/>
  32. FROM sys_notice a
  33. where id = #{id}
  34. </select>
  35. <select id="findList" resultType="SysNotice">
  36. SELECT
  37. <include refid="sysNoticeColumns"/>,
  38. su.name AS "createByName"
  39. FROM sys_notice a
  40. left join sys_user su
  41. on su.id = a.create_by
  42. <include refid="sysNoticeJoins"/>
  43. where a.del_flag = #{DEL_FLAG_NORMAL}
  44. <if test="noticeTitle != null and noticeTitle != ''">
  45. AND a.notice_title like concat('%', #{noticeTitle}, '%')
  46. </if>
  47. <if test="noticeType != null and noticeType != ''">
  48. AND a.notice_type = #{noticeType}
  49. </if>
  50. <if test="carousel != null and carousel != ''">
  51. AND a.carousel = #{carousel}
  52. </if>
  53. <if test="createBy != null and createBy != ''">
  54. AND su.name like concat('%', #{createBy}, '%')
  55. </if>
  56. <include refid="sysNoticeOrderBy"/>
  57. </select>
  58. <insert id="insert" parameterType="SysNotice">
  59. insert into sys_notice (
  60. id,
  61. notice_title,
  62. notice_type,
  63. notice_content,
  64. notice_content_html,
  65. status,
  66. topping,
  67. carousel,
  68. carousel_img_url,
  69. remark,
  70. create_by,
  71. create_dept,
  72. create_time,
  73. update_by,
  74. update_time,
  75. update_ip,
  76. del_flag,
  77. version
  78. )values(
  79. #{id},
  80. #{noticeTitle},
  81. #{noticeType},
  82. #{noticeContent},
  83. #{noticeContentHtml},
  84. #{status},
  85. #{topping},
  86. #{carousel},
  87. #{carouselImgUrl},
  88. #{remark},
  89. #{createBy},
  90. #{createDept},
  91. #{createTime},
  92. #{updateBy},
  93. #{updateTime},
  94. #{updateIp},
  95. #{DEL_FLAG_NORMAL},
  96. 1
  97. )
  98. </insert>
  99. <update id="update" parameterType="SysNotice">
  100. update sys_notice
  101. <set>
  102. <if test="noticeTitle != null and noticeTitle != ''">
  103. notice_title = #{noticeTitle},
  104. </if>
  105. <if test="noticeType != null and noticeType != ''">
  106. notice_type = #{noticeType},
  107. </if>
  108. <if test="topping != null and topping != ''">
  109. topping = #{topping},
  110. </if>
  111. <if test="carousel != null and carousel != ''">
  112. carousel = #{carousel},
  113. </if>
  114. <if test="carouselImgUrl != null and carouselImgUrl != ''">
  115. carousel_img_url = #{carouselImgUrl},
  116. </if>
  117. <if test="noticeContent != null">
  118. notice_content = #{noticeContent},
  119. </if>
  120. <if test="noticeContentHtml != null">
  121. notice_content_html = #{noticeContentHtml},
  122. </if>
  123. <if test="status != null and status != ''">
  124. status = #{status},
  125. </if>
  126. <if test="updateBy != null and updateBy != ''">
  127. update_by = #{updateBy},
  128. </if>
  129. <if test="updateTime != null">
  130. update_time = #{updateTime},
  131. </if>
  132. <if test="updateIp != null and updateIp != ''">
  133. update_ip = #{updateIp},
  134. </if>
  135. version = version + 1
  136. </set>
  137. where id = #{id}
  138. </update>
  139. <delete id="delete">
  140. UPDATE sys_notice SET
  141. del_flag = #{DEL_FLAG_DELETE}
  142. WHERE id = #{id}
  143. </delete>
  144. <update id="deleteNoticeByIds" parameterType="java.util.Map">
  145. UPDATE sys_notice SET
  146. del_flag = #{DEL_FLAG_DELETE}
  147. WHERE id in
  148. <foreach collection="noticeIds" item="ids" open="(" separator="," close=")">
  149. #{ids}
  150. </foreach>
  151. </update>
  152. <select id="getNoticeListByUserId" resultType="SysNotice">
  153. SELECT
  154. id,
  155. notice_title as 'noticeTitle'
  156. FROM
  157. `sys_notice` a
  158. WHERE
  159. NOT EXISTS (
  160. SELECT
  161. 1
  162. FROM
  163. sys_notice_user_read t
  164. WHERE
  165. a.id = t.notice_id
  166. AND t.user_id = #{userId}
  167. )
  168. AND a.del_flag = #{DEL_FLAG_NORMAL}
  169. <include refid="sysNoticeOrderBy"/>
  170. </select>
  171. <select id="findNoticeByUserList" resultType="SysNotice">
  172. SELECT
  173. <include refid="sysNoticeColumns"/>,
  174. su.name AS "createByName",
  175. r.is_read AS "isRead"
  176. FROM sys_notice a
  177. left join sys_user su
  178. on su.id = a.create_by
  179. LEFT JOIN sys_notice_user_read r ON a.id = r.notice_id and r.user_id = #{userId}
  180. where a.del_flag = #{DEL_FLAG_NORMAL} and (r.del_flag = #{DEL_FLAG_NORMAL} or r.id is null)
  181. <if test="noticeTitle != null and noticeTitle != ''">
  182. AND a.notice_title like concat('%', #{noticeTitle}, '%')
  183. </if>
  184. <if test="noticeType != null and noticeType != ''">
  185. AND a.notice_type = #{noticeType}
  186. </if>
  187. <if test="createBy != null and createBy != ''">
  188. AND su.name like concat('%', #{createBy}, '%')
  189. </if>
  190. <include refid="sysNoticeOrderBy"/>
  191. </select>
  192. </mapper>