NewsMapperExt.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 1 =1
  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
  115. where 1 =1
  116. <if test="auditStatus != null">
  117. and audit_status = #{auditStatus,jdbcType=INTEGER}
  118. </if>
  119. <if test="type != null">
  120. and type = #{type,jdbcType=INTEGER}
  121. </if>
  122. <if test="title != null">
  123. and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  124. </if>
  125. <if test="author != null">
  126. and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
  127. </if>
  128. <if test="sDate != null">
  129. and create_time <![CDATA[ >= ]]> #{sDate,jdbcType=TIMESTAMP}
  130. </if>
  131. <if test="eDate != null">
  132. and create_time <![CDATA[ < ]]> #{eDate,jdbcType=TIMESTAMP}
  133. </if>
  134. <if test="source != null">
  135. and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
  136. </if>
  137. <if test="hot != null">
  138. and hot = #{hot,jdbcType=INTEGER}
  139. </if>
  140. </select>
  141. <delete id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  142. delete
  143. from news
  144. where id in
  145. <foreach item="item" index="index" collection="list" open="("
  146. separator="," close=")">
  147. #{item}
  148. </foreach>
  149. </delete>
  150. <select id="findPortalList" resultType="com.goafanti.news.bo.NewsPortalList">
  151. select
  152. a.id,
  153. a.create_time as createTime,
  154. a.title,
  155. a.title_img as titleImg,
  156. a.type,
  157. a.hot,
  158. a.summary,
  159. a.source
  160. from news a
  161. join branch_office_info b
  162. on a.province_id = b.province_id
  163. where 1 =1
  164. <if test="type != null and type != 0" >
  165. and a.type = #{type,jdbcType=INTEGER}
  166. </if>
  167. <if test="website != null">
  168. and b.website = #{website,jdbcType=VARCHAR}
  169. </if>
  170. order by create_time desc
  171. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  172. </select>
  173. <select id="findJmrhNewsList" parameterType="String" resultMap="SummaryResultMap">
  174. select
  175. id,title,create_time
  176. from
  177. news
  178. where
  179. jmrh_flag = 1 and type = #{type,jdbcType=INTEGER}
  180. order by
  181. create_time desc
  182. limit 3;
  183. </select>
  184. <select id="findIndexNewsLists" resultMap="SummaryResultMap">
  185. select
  186. <include refid="Summary_Column_List" />
  187. from news
  188. where
  189. type = 1
  190. order by create_time desc
  191. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  192. </select>
  193. </mapper>