NewsMapperExt.xml 6.1 KB

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