NewsMapperExt.xml 5.4 KB

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