NewsMapperExt.xml 4.3 KB

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