NewsMapperExt.xml 5.5 KB

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