NewsMapperExt.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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.NewsMapper">
  4. <resultMap id="SummaryResultMap" type="com.goafanti.news.bo.NewsSummary">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  7. <result column="title" jdbcType="VARCHAR" property="title" />
  8. <result column="title_img" jdbcType="VARCHAR" property="titleImg" />
  9. <result column="type" jdbcType="INTEGER" property="type" />
  10. <result column="hot" jdbcType="INTEGER" property="hot" />
  11. <result column="summary" jdbcType="VARCHAR" property="summary" />
  12. <result column="source" jdbcType="VARCHAR" property="source" />
  13. </resultMap>
  14. <sql id="Summary_Column_List">
  15. id, create_time, title, title_img, type, hot, summary, source
  16. </sql>
  17. <select id="findList" resultType="com.goafanti.news.bo.NewsSummary">
  18. select
  19. a.id,
  20. a.create_time as createTime,
  21. a.title,
  22. a.title_img as titleImg,
  23. a.type,
  24. a.hot,
  25. a.summary,
  26. a.source
  27. from news a
  28. join branch_office_info b
  29. on a.province_id = b.province_id
  30. where 1=1
  31. <if test="type != null">
  32. and a.type = #{type,jdbcType=INTEGER}
  33. </if>
  34. <if test="website != null">
  35. and b.website = #{website,jdbcType=VARCHAR}
  36. </if>
  37. order by create_time desc
  38. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  39. </select>
  40. <select id="findIndexNewsList" resultMap="SummaryResultMap">
  41. select
  42. a.id,
  43. a.create_time as createTime,
  44. a.title,
  45. a.title_img as titleImg,
  46. a.type,
  47. a.hot,
  48. a.summary,
  49. a.source
  50. from news a
  51. join branch_office_info b
  52. on a.province_id = b.province_id
  53. where a.hot = 1
  54. <if test=" type != null">
  55. and a.type = #{type,jdbcType=INTEGER}
  56. </if>
  57. <if test="website != null">
  58. and b.website = #{website,jdbcType=VARCHAR}
  59. </if>
  60. order by create_time desc
  61. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  62. </select>
  63. <select id="findNewsListByPage" parameterType="String" resultMap="BaseResultMap">
  64. select
  65. id,
  66. create_time,
  67. title,
  68. author,
  69. type,
  70. hot,
  71. source,
  72. summary
  73. from news
  74. where 1 =1
  75. <if test="type != null">
  76. and type = #{type,jdbcType=INTEGER}
  77. </if>
  78. <if test="title != null">
  79. and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  80. </if>
  81. <if test="author != null">
  82. and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
  83. </if>
  84. <if test="sDate != null">
  85. and create_time <![CDATA[ >= ]]> #{sDate,jdbcType=TIMESTAMP}
  86. </if>
  87. <if test="eDate != null">
  88. and create_time <![CDATA[ < ]]> #{eDate,jdbcType=TIMESTAMP}
  89. </if>
  90. <if test="source != null">
  91. and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
  92. </if>
  93. <if test="hot != null">
  94. and hot = #{hot,jdbcType=INTEGER}
  95. </if>
  96. order by create_time desc
  97. <if test="page_sql!=null">
  98. ${page_sql}
  99. </if>
  100. </select>
  101. <select id="findNewsCount" parameterType="String" resultType="java.lang.Integer">
  102. select
  103. count(1)
  104. from news
  105. where 1 =1
  106. <if test="type != null">
  107. and type = #{type,jdbcType=INTEGER}
  108. </if>
  109. <if test="title != null">
  110. and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  111. </if>
  112. <if test="author != null">
  113. and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
  114. </if>
  115. <if test="sDate != null">
  116. and create_time <![CDATA[ >= ]]> #{sDate,jdbcType=TIMESTAMP}
  117. </if>
  118. <if test="eDate != null">
  119. and create_time <![CDATA[ < ]]> #{eDate,jdbcType=TIMESTAMP}
  120. </if>
  121. <if test="source != null">
  122. and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
  123. </if>
  124. <if test="hot != null">
  125. and hot = #{hot,jdbcType=INTEGER}
  126. </if>
  127. </select>
  128. <delete id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  129. delete
  130. from news
  131. where id in
  132. <foreach item="item" index="index" collection="list" open="("
  133. separator="," close=")">
  134. #{item}
  135. </foreach>
  136. </delete>
  137. <select id="findPortalList" resultType="com.goafanti.news.bo.NewsPortalList">
  138. select
  139. a.id,
  140. a.create_time as createTime,
  141. a.title,
  142. a.title_img as titleImg,
  143. a.type,
  144. a.hot,
  145. a.summary,
  146. a.source,
  147. a.content
  148. from news a
  149. join branch_office_info b
  150. on a.province_id = b.province_id
  151. where 1 =1
  152. <if test="type != null and type != 0" >
  153. and a.type = #{type,jdbcType=INTEGER}
  154. </if>
  155. <if test="website != null">
  156. and b.website = #{website,jdbcType=VARCHAR}
  157. </if>
  158. order by create_time desc
  159. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  160. </select>
  161. <select id="findJmrhNewsList" parameterType="String" resultMap="SummaryResultMap">
  162. select
  163. id,title,create_time
  164. from
  165. news
  166. where
  167. jmrh_flag = 1 and type = #{type,jdbcType=INTEGER}
  168. order by
  169. create_time desc
  170. limit 3;
  171. </select>
  172. </mapper>