NoticeMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.goafanti.common.dao.NoticeMapper" >
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.Notice" >
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="aid" property="aid" jdbcType="VARCHAR" />
  7. <result column="notice_type" property="noticeType" jdbcType="INTEGER" />
  8. <result column="content" property="content" jdbcType="VARCHAR" />
  9. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  10. <result column="readed" property="readed" jdbcType="INTEGER" />
  11. <result column="uid" property="uid" jdbcType="VARCHAR" />
  12. <result column="pid" property="pid" jdbcType="VARCHAR" />
  13. <result column="rid" property="rid" jdbcType="VARCHAR" />
  14. <result column="year" property="year" jdbcType="INTEGER" />
  15. </resultMap>
  16. <sql id="Base_Column_List" >
  17. id, aid, notice_type, content, create_time, readed, uid, pid, rid, year
  18. </sql>
  19. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  20. select
  21. <include refid="Base_Column_List" />
  22. from notice
  23. where id = #{id,jdbcType=VARCHAR}
  24. </select>
  25. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  26. delete from notice
  27. where id = #{id,jdbcType=VARCHAR}
  28. </delete>
  29. <insert id="insert" parameterType="com.goafanti.common.model.Notice" >
  30. insert into notice (id, aid, notice_type,
  31. content, create_time, readed, uid, pid, rid, year
  32. )
  33. values (#{id,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR}, #{noticeType,jdbcType=INTEGER},
  34. #{content,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{readed,jdbcType=INTEGER},
  35. #{uid,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR}, #{rid,jdbcType=VARCHAR}, #{year,jdbcType=INTEGER}
  36. )
  37. </insert>
  38. <insert id="insertSelective" parameterType="com.goafanti.common.model.Notice" >
  39. insert into notice
  40. <trim prefix="(" suffix=")" suffixOverrides="," >
  41. <if test="id != null" >
  42. id,
  43. </if>
  44. <if test="aid != null" >
  45. aid,
  46. </if>
  47. <if test="noticeType != null" >
  48. notice_type,
  49. </if>
  50. <if test="content != null" >
  51. content,
  52. </if>
  53. <if test="createTime != null" >
  54. create_time,
  55. </if>
  56. <if test="readed != null" >
  57. readed,
  58. </if>
  59. <if test="uid != null" >
  60. uid,
  61. </if>
  62. <if test="pid != null" >
  63. pid,
  64. </if>
  65. <if test="rid != null" >
  66. rid,
  67. </if>
  68. <if test="year != null" >
  69. year,
  70. </if>
  71. </trim>
  72. <trim prefix="values (" suffix=")" suffixOverrides="," >
  73. <if test="id != null" >
  74. #{id,jdbcType=VARCHAR},
  75. </if>
  76. <if test="aid != null" >
  77. #{aid,jdbcType=VARCHAR},
  78. </if>
  79. <if test="noticeType != null" >
  80. #{noticeType,jdbcType=INTEGER},
  81. </if>
  82. <if test="content != null" >
  83. #{content,jdbcType=VARCHAR},
  84. </if>
  85. <if test="createTime != null" >
  86. #{createTime,jdbcType=TIMESTAMP},
  87. </if>
  88. <if test="readed != null" >
  89. #{readed,jdbcType=INTEGER},
  90. </if>
  91. <if test="uid != null" >
  92. #{uid,jdbcType=VARCHAR},
  93. </if>
  94. <if test="pid != null" >
  95. #{pid,jdbcType=VARCHAR},
  96. </if>
  97. <if test="rid != null" >
  98. #{rid,jdbcType=VARCHAR},
  99. </if>
  100. <if test="year != null" >
  101. #{year,jdbcType=INTEGER},
  102. </if>
  103. </trim>
  104. </insert>
  105. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Notice" >
  106. update notice
  107. <set >
  108. <if test="aid != null" >
  109. aid = #{aid,jdbcType=VARCHAR},
  110. </if>
  111. <if test="noticeType != null" >
  112. notice_type = #{noticeType,jdbcType=INTEGER},
  113. </if>
  114. <if test="content != null" >
  115. content = #{content,jdbcType=VARCHAR},
  116. </if>
  117. <if test="createTime != null" >
  118. create_time = #{createTime,jdbcType=TIMESTAMP},
  119. </if>
  120. <if test="readed != null" >
  121. readed = #{readed,jdbcType=INTEGER},
  122. </if>
  123. <if test="uid != null" >
  124. uid = #{uid,jdbcType=VARCHAR},
  125. </if>
  126. <if test="pid != null" >
  127. pid = #{pid,jdbcType=VARCHAR},
  128. </if>
  129. <if test="rid != null" >
  130. rid = #{rid,jdbcType=VARCHAR},
  131. </if>
  132. <if test="year != null" >
  133. year = #{year,jdbcType=INTEGER},
  134. </if>
  135. </set>
  136. where id = #{id,jdbcType=VARCHAR}
  137. </update>
  138. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Notice" >
  139. update notice
  140. set aid = #{aid,jdbcType=VARCHAR},
  141. notice_type = #{noticeType,jdbcType=INTEGER},
  142. content = #{content,jdbcType=VARCHAR},
  143. create_time = #{createTime,jdbcType=TIMESTAMP},
  144. readed = #{readed,jdbcType=INTEGER},
  145. uid = #{uid,jdbcType=VARCHAR},
  146. pid = #{pid,jdbcType=VARCHAR},
  147. rid = #{rid,jdbcType=VARCHAR},
  148. year = #{year,jdbcType=INTEGER}
  149. where id = #{id,jdbcType=VARCHAR}
  150. </update>
  151. <select id="findUnreadNoticeListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.NoticeBo">
  152. select n.id, n.aid, n.uid, n.notice_type as noticeType, n.content, n.create_time as createTime,
  153. oi.unit_name as unitName, n.rid, a.name as principle, n.readed, n.year
  154. from notice n
  155. LEFT JOIN organization_identity oi on n.uid = oi.uid
  156. LEFT JOIN admin a on a.id = n.pid
  157. where n.readed = 0
  158. <if test="aid != null">
  159. and n.aid = #{aid,jdbcType=VARCHAR}
  160. </if>
  161. order by n.create_time desc
  162. <if test="page_sql!=null">
  163. ${page_sql}
  164. </if>
  165. </select>
  166. <select id="findUnreadNoticeCount" resultType="java.lang.Integer" parameterType="java.lang.String">
  167. select count(1)
  168. from notice n
  169. where n.readed = 0
  170. <if test="aid != null">
  171. and n.aid = #{aid,jdbcType=VARCHAR}
  172. </if>
  173. </select>
  174. <select id="findReadedNoticeListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.NoticeBo">
  175. select n.id, n.uid, n.aid, n.notice_type as noticeType, n.content, n.create_time as createTime,
  176. oi.unit_name as unitName, n.rid, a.name as principle, n.readed, n.year
  177. from notice n
  178. LEFT JOIN organization_identity oi on n.uid = oi.uid
  179. LEFT JOIN admin a on a.id = n.pid
  180. where n.readed = 1
  181. <if test="aid != null">
  182. and n.aid = #{aid,jdbcType=VARCHAR}
  183. </if>
  184. order by n.create_time desc
  185. <if test="page_sql!=null">
  186. ${page_sql}
  187. </if>
  188. </select>
  189. <select id="findReadedNoticeCount" resultType="java.lang.Integer" parameterType="java.lang.String">
  190. select count(1)
  191. from notice n
  192. where n.readed = 1
  193. <if test="aid != null">
  194. and n.aid = #{aid,jdbcType=VARCHAR}
  195. </if>
  196. </select>
  197. <select id="selectUnreadedCount" resultType="java.lang.Integer" parameterType="java.lang.String">
  198. select count(1) from notice where readed = 0
  199. <if test="_parameter">
  200. and aid = #{_parameter,jdbcType=VARCHAR}
  201. </if>
  202. </select>
  203. <update id="batchUpdateUnreaded" parameterType="java.util.List">
  204. update notice set readed = 1
  205. where id in
  206. <foreach item="item" index="index" collection="list" open="("
  207. separator="," close=")">
  208. #{item}
  209. </foreach>
  210. </update>
  211. <insert id="insertBatch" parameterType="com.goafanti.common.model.Notice">
  212. insert into notice (id, aid, notice_type, content, create_time, readed, uid, pid, rid, year)
  213. values
  214. <foreach item="item" index="index" collection="list" separator=",">
  215. (
  216. #{item.id,jdbcType=VARCHAR}, #{item.aid,jdbcType=VARCHAR}, #{item.noticeType,jdbcType=INTEGER},
  217. #{item.content,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.readed,jdbcType=INTEGER},
  218. #{item.uid,jdbcType=VARCHAR}, #{item.pid,jdbcType=VARCHAR}, #{item.rid,jdbcType=VARCHAR},
  219. #{item.year,jdbcType=INTEGER}
  220. )
  221. </foreach>
  222. </insert>
  223. </mapper>