NewsMapperExt.xml 4.7 KB

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