NewsMapperExt.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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" resultType="com.goafanti.common.model.News">
  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.title_img as titleImg,
  70. n.hotspot,
  71. n.source_url as sourceUrl,
  72. n.release_date as releaseDate
  73. from news n
  74. <if test="publishPage !=null">
  75. left join news_publish np on np.news_id= n.id
  76. </if>
  77. where (n.type =0 or n.type=98 or n.type=99)
  78. <if test="publishPage !=null">
  79. and np.publish_page =#{publishPage,jdbcType=VARCHAR}
  80. </if>
  81. <if test="auditStatus != null">
  82. and audit_status = #{auditStatus,jdbcType=INTEGER}
  83. </if>
  84. <if test="releaseStatus != null">
  85. and release_status = #{releaseStatus,jdbcType=INTEGER}
  86. </if>
  87. <if test="type != null">
  88. and type = #{type,jdbcType=INTEGER}
  89. </if>
  90. <if test="title != null">
  91. and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  92. </if>
  93. <if test="author != null">
  94. and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
  95. </if>
  96. <if test="sDate != null">
  97. and create_time <![CDATA[ >= ]]> #{sDate,jdbcType=TIMESTAMP}
  98. </if>
  99. <if test="eDate != null">
  100. and create_time <![CDATA[ < ]]> #{eDate,jdbcType=TIMESTAMP}
  101. </if>
  102. <if test="source != null">
  103. and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
  104. </if>
  105. <if test="hot != null">
  106. and hot = #{hot,jdbcType=INTEGER}
  107. </if>
  108. order by release_date desc
  109. <if test="page_sql!=null">
  110. ${page_sql}
  111. </if>
  112. </select>
  113. <select id="findNewsCount" parameterType="String" resultType="java.lang.Integer">
  114. select
  115. count(1)
  116. from news n
  117. <if test="publishPage !=null">
  118. left join news_publish np on np.news_id= n.id
  119. </if>
  120. where (n.type =0 or n.type=98 or n.type=99)
  121. <if test="publishPage !=null">
  122. and np.publish_page =#{publishPage,jdbcType=VARCHAR}
  123. </if>
  124. <if test="auditStatus != null">
  125. and audit_status = #{auditStatus,jdbcType=INTEGER}
  126. </if>
  127. <if test="releaseStatus != null">
  128. and release_status = #{releaseStatus,jdbcType=INTEGER}
  129. </if>
  130. <if test="type != null">
  131. and type = #{type,jdbcType=INTEGER}
  132. </if>
  133. <if test="title != null">
  134. and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  135. </if>
  136. <if test="author != null">
  137. and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
  138. </if>
  139. <if test="sDate != null">
  140. and create_time <![CDATA[ >= ]]> #{sDate,jdbcType=TIMESTAMP}
  141. </if>
  142. <if test="eDate != null">
  143. and create_time <![CDATA[ < ]]> #{eDate,jdbcType=TIMESTAMP}
  144. </if>
  145. <if test="source != null">
  146. and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
  147. </if>
  148. <if test="hot != null">
  149. and hot = #{hot,jdbcType=INTEGER}
  150. </if>
  151. </select>
  152. <delete id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  153. delete
  154. from news
  155. where id in
  156. <foreach item="item" index="index" collection="list" open="("
  157. separator="," close=")">
  158. #{item}
  159. </foreach>
  160. </delete>
  161. <select id="findPortalList" resultType="com.goafanti.news.bo.NewsPortalList">
  162. select
  163. a.id,
  164. a.create_time as createTime,
  165. a.title,
  166. a.title_img as titleImg,
  167. a.type,
  168. a.hot,
  169. a.summary,
  170. a.source
  171. from news a
  172. join branch_office_info b
  173. on a.province_id = b.province_id
  174. where 1 =1
  175. <if test="type != null and type != 0" >
  176. and a.type = #{type,jdbcType=INTEGER}
  177. </if>
  178. <if test="website != null">
  179. and b.website = #{website,jdbcType=VARCHAR}
  180. </if>
  181. order by create_time desc
  182. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  183. </select>
  184. <select id="findJmrhNewsList" parameterType="String" resultMap="SummaryResultMap">
  185. select
  186. id,title,create_time
  187. from
  188. news
  189. where
  190. jmrh_flag = 1 and type = #{type,jdbcType=INTEGER}
  191. order by
  192. create_time desc
  193. limit 3;
  194. </select>
  195. <select id="findIndexNewsLists" resultMap="SummaryResultMap">
  196. select
  197. <include refid="Summary_Column_List" />
  198. from news
  199. where
  200. type = 1
  201. order by create_time desc
  202. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  203. </select>
  204. <select id="selectinformationDetail" resultType="com.goafanti.news.bo.NewsPortalList">
  205. select id,create_time as createTime,title,title_img as titleImg,type,hot,
  206. summary,source,audit_status as auditStatus,release_date as releaseDate,release_status as releaseStatus
  207. from news where type=0
  208. and id= #{id,jdbcType=VARCHAR}
  209. </select>
  210. </mapper>