SysNoticeMapper.xml 5.8 KB

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