NewsMapperExt.xml 5.5 KB

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