NewsMapperExt.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. </resultMap>
  14. <sql id="Summary_Column_List">
  15. id, create_time, title, title_img, type, hot, summary, source
  16. </sql>
  17. <select id="findList" resultType="com.goafanti.news.bo.NewsSummary">
  18. select
  19. a.id,
  20. a.create_time as createTime,
  21. a.title,
  22. a.title_img as titleImg,
  23. a.type,
  24. a.hot,
  25. a.summary,
  26. a.source
  27. from news a
  28. join branch_office_info b
  29. on a.province_id = b.province_id
  30. where 1=1
  31. <if test="type != null">
  32. and a.type = #{type,jdbcType=INTEGER}
  33. </if>
  34. <if test="website != null">
  35. and b.website = #{website,jdbcType=VARCHAR}
  36. </if>
  37. order by create_time desc
  38. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  39. </select>
  40. <select id="findIndexNewsList" resultMap="SummaryResultMap">
  41. select
  42. <include refid="Summary_Column_List" />
  43. from news
  44. where hot = 1
  45. <if test=" type != null">
  46. and type = #{type,jdbcType=INTEGER}
  47. </if>
  48. order by create_time desc
  49. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  50. </select>
  51. <select id="findNewsListByPage" parameterType="String" resultMap="BaseResultMap">
  52. select
  53. id,
  54. create_time,
  55. title,
  56. author,
  57. type,
  58. hot,
  59. source,
  60. summary
  61. from news
  62. where 1 =1
  63. <if test="type != null">
  64. and type = #{type,jdbcType=INTEGER}
  65. </if>
  66. <if test="title != null">
  67. and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  68. </if>
  69. <if test="author != null">
  70. and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
  71. </if>
  72. <if test="sDate != null">
  73. and create_time <![CDATA[ >= ]]> #{sDate,jdbcType=TIMESTAMP}
  74. </if>
  75. <if test="eDate != null">
  76. and create_time <![CDATA[ < ]]> #{eDate,jdbcType=TIMESTAMP}
  77. </if>
  78. <if test="source != null">
  79. and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
  80. </if>
  81. <if test="hot != null">
  82. and hot = #{hot,jdbcType=INTEGER}
  83. </if>
  84. order by create_time desc
  85. <if test="page_sql!=null">
  86. ${page_sql}
  87. </if>
  88. </select>
  89. <select id="findNewsCount" parameterType="String" resultType="java.lang.Integer">
  90. select
  91. count(1)
  92. from news
  93. where 1 =1
  94. <if test="type != null">
  95. and type = #{type,jdbcType=INTEGER}
  96. </if>
  97. <if test="title != null">
  98. and title like CONCAT('%',#{title,jdbcType=VARCHAR},'%')
  99. </if>
  100. <if test="author != null">
  101. and author like CONCAT('%',#{author,jdbcType=VARCHAR},'%')
  102. </if>
  103. <if test="sDate != null">
  104. and create_time <![CDATA[ >= ]]> #{sDate,jdbcType=TIMESTAMP}
  105. </if>
  106. <if test="eDate != null">
  107. and create_time <![CDATA[ < ]]> #{eDate,jdbcType=TIMESTAMP}
  108. </if>
  109. <if test="source != null">
  110. and source like CONCAT('%',#{source,jdbcType=VARCHAR},'%')
  111. </if>
  112. <if test="hot != null">
  113. and hot = #{hot,jdbcType=INTEGER}
  114. </if>
  115. </select>
  116. <delete id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  117. delete
  118. from news
  119. where id in
  120. <foreach item="item" index="index" collection="list" open="("
  121. separator="," close=")">
  122. #{item}
  123. </foreach>
  124. </delete>
  125. <select id="findPortalList" resultType="com.goafanti.news.bo.NewsPortalList">
  126. select
  127. a.id,
  128. a.create_time as createTime,
  129. a.title,
  130. a.title_img as titleImg,
  131. a.type,
  132. a.hot,
  133. a.summary,
  134. a.source,
  135. a.content
  136. from news a
  137. join branch_office_info b
  138. on a.province_id = b.province_id
  139. where 1 =1
  140. <if test="type != null and type != 0" >
  141. and a.type = #{type,jdbcType=INTEGER}
  142. </if>
  143. <if test="website != null">
  144. and b.website = #{website,jdbcType=VARCHAR}
  145. </if>
  146. order by create_time desc
  147. limit #{pageNo,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER}
  148. </select>
  149. <select id="findJmrhNewsList" parameterType="String" resultMap="SummaryResultMap">
  150. select
  151. id,title,create_time
  152. from
  153. news
  154. where
  155. jmrh_flag = 1 and type = #{type,jdbcType=INTEGER}
  156. order by
  157. create_time desc
  158. limit 3;
  159. </select>
  160. </mapper>