NewsMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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="BaseResultMap" type="com.goafanti.common.model.News">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  7. <result column="edit_time" jdbcType="TIMESTAMP" property="editTime" />
  8. <result column="title" jdbcType="VARCHAR" property="title" />
  9. <result column="title_img" jdbcType="VARCHAR" property="titleImg" />
  10. <result column="author" jdbcType="VARCHAR" property="author" />
  11. <result column="type" jdbcType="INTEGER" property="type" />
  12. <result column="hot" jdbcType="INTEGER" property="hot" />
  13. <result column="source" jdbcType="VARCHAR" property="source" />
  14. <result column="source_url" jdbcType="VARCHAR" property="sourceUrl" />
  15. <result column="summary" jdbcType="VARCHAR" property="summary" />
  16. <result column="jmrh_flag" jdbcType="INTEGER" property="jmrhFlag" />
  17. <result column="province_id" jdbcType="INTEGER" property="provinceId" />
  18. </resultMap>
  19. <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.goafanti.common.model.News">
  20. <result column="content" jdbcType="LONGVARCHAR" property="content" />
  21. </resultMap>
  22. <sql id="Base_Column_List">
  23. id, create_time, edit_time, title, title_img, author, type, hot, source, source_url,
  24. summary,jmrh_flag,province_id
  25. </sql>
  26. <sql id="Blob_Column_List">
  27. content
  28. </sql>
  29. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
  30. select
  31. id,
  32. content,
  33. create_time as createTime,
  34. edit_time as editTime,
  35. title,
  36. title_img as titleImg,
  37. author,
  38. type,
  39. hot,
  40. source,
  41. source_url as sourceUrl,
  42. summary,
  43. jmrh_flag as jmrhFlag,
  44. province_id as provinceId
  45. from news
  46. where id = #{id,jdbcType=BIGINT}
  47. </select>
  48. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  49. delete from news
  50. where id = #{id,jdbcType=BIGINT}
  51. </delete>
  52. <insert id="insert" parameterType="com.goafanti.common.model.News">
  53. insert into news (id, create_time, edit_time,
  54. title, title_img, author,
  55. type, hot, source,
  56. source_url, summary, content,jmrh_flag,province_id
  57. )
  58. values (#{id,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{editTime,jdbcType=TIMESTAMP},
  59. #{title,jdbcType=VARCHAR}, #{titleImg,jdbcType=VARCHAR}, #{author,jdbcType=VARCHAR},
  60. #{type,jdbcType=INTEGER}, #{hot,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR},
  61. #{sourceUrl,jdbcType=VARCHAR}, #{summary,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR},
  62. #{jmrhFlag,jdbcType=INTEGER}, #{provinceId,jdbcType=INTEGER}
  63. )
  64. </insert>
  65. <insert id="insertSelective" parameterType="com.goafanti.common.model.News">
  66. insert into news
  67. <trim prefix="(" suffix=")" suffixOverrides=",">
  68. <if test="id != null">
  69. id,
  70. </if>
  71. <if test="createTime != null">
  72. create_time,
  73. </if>
  74. <if test="editTime != null">
  75. edit_time,
  76. </if>
  77. <if test="title != null">
  78. title,
  79. </if>
  80. <if test="titleImg != null">
  81. title_img,
  82. </if>
  83. <if test="author != null">
  84. author,
  85. </if>
  86. <if test="type != null">
  87. type,
  88. </if>
  89. <if test="hot != null">
  90. hot,
  91. </if>
  92. <if test="source != null">
  93. source,
  94. </if>
  95. <if test="sourceUrl != null">
  96. source_url,
  97. </if>
  98. <if test="summary != null">
  99. summary,
  100. </if>
  101. <if test="content != null">
  102. content,
  103. </if>
  104. <if test="jmrhFlag != null">
  105. jmrh_flag,
  106. </if>
  107. <if test="provinceId != null">
  108. province_id,
  109. </if>
  110. </trim>
  111. <trim prefix="values (" suffix=")" suffixOverrides=",">
  112. <if test="id != null">
  113. #{id,jdbcType=BIGINT},
  114. </if>
  115. <if test="createTime != null">
  116. #{createTime,jdbcType=TIMESTAMP},
  117. </if>
  118. <if test="editTime != null">
  119. #{editTime,jdbcType=TIMESTAMP},
  120. </if>
  121. <if test="title != null">
  122. #{title,jdbcType=VARCHAR},
  123. </if>
  124. <if test="titleImg != null">
  125. #{titleImg,jdbcType=VARCHAR},
  126. </if>
  127. <if test="author != null">
  128. #{author,jdbcType=VARCHAR},
  129. </if>
  130. <if test="type != null">
  131. #{type,jdbcType=INTEGER},
  132. </if>
  133. <if test="hot != null">
  134. #{hot,jdbcType=INTEGER},
  135. </if>
  136. <if test="source != null">
  137. #{source,jdbcType=VARCHAR},
  138. </if>
  139. <if test="sourceUrl != null">
  140. #{sourceUrl,jdbcType=VARCHAR},
  141. </if>
  142. <if test="summary != null">
  143. #{summary,jdbcType=VARCHAR},
  144. </if>
  145. <if test="content != null">
  146. #{content,jdbcType=LONGVARCHAR},
  147. </if>
  148. <if test="jmrhFlag != null">
  149. #{jmrhFlag,jdbcType=INTEGER},
  150. </if>
  151. <if test="provinceId != null">
  152. #{provinceId,jdbcType=INTEGER},
  153. </if>
  154. </trim>
  155. </insert>
  156. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.News">
  157. update news
  158. <set>
  159. <if test="createTime != null">
  160. create_time = #{createTime,jdbcType=TIMESTAMP},
  161. </if>
  162. <if test="editTime != null">
  163. edit_time = #{editTime,jdbcType=TIMESTAMP},
  164. </if>
  165. <if test="title != null">
  166. title = #{title,jdbcType=VARCHAR},
  167. </if>
  168. <if test="titleImg != null">
  169. title_img = #{titleImg,jdbcType=VARCHAR},
  170. </if>
  171. <if test="author != null">
  172. author = #{author,jdbcType=VARCHAR},
  173. </if>
  174. <if test="type != null">
  175. type = #{type,jdbcType=INTEGER},
  176. </if>
  177. <if test="hot != null">
  178. hot = #{hot,jdbcType=INTEGER},
  179. </if>
  180. <if test="source != null">
  181. source = #{source,jdbcType=VARCHAR},
  182. </if>
  183. <if test="sourceUrl != null">
  184. source_url = #{sourceUrl,jdbcType=VARCHAR},
  185. </if>
  186. <if test="summary != null">
  187. summary = #{summary,jdbcType=VARCHAR},
  188. </if>
  189. <if test="content != null">
  190. content = #{content,jdbcType=LONGVARCHAR},
  191. </if>
  192. <if test="jmrhFlag != null">
  193. content = #{jmrhFlag,jdbcType=INTEGER},
  194. </if>
  195. </set>
  196. where id = #{id,jdbcType=BIGINT}
  197. </update>
  198. <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.goafanti.common.model.News">
  199. update news
  200. set create_time = #{createTime,jdbcType=TIMESTAMP},
  201. edit_time = #{editTime,jdbcType=TIMESTAMP},
  202. title = #{title,jdbcType=VARCHAR},
  203. title_img = #{titleImg,jdbcType=VARCHAR},
  204. author = #{author,jdbcType=VARCHAR},
  205. type = #{type,jdbcType=INTEGER},
  206. hot = #{hot,jdbcType=INTEGER},
  207. source = #{source,jdbcType=VARCHAR},
  208. source_url = #{sourceUrl,jdbcType=VARCHAR},
  209. summary = #{summary,jdbcType=VARCHAR},
  210. content = #{content,jdbcType=LONGVARCHAR},
  211. jmrh_flag = #{jmrhFlag,jdbcType=INTEGER},
  212. province_id = #{provinceId,jdbcType=INTEGER}
  213. where id = #{id,jdbcType=BIGINT}
  214. </update>
  215. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.News">
  216. update news
  217. set create_time = #{createTime,jdbcType=TIMESTAMP},
  218. edit_time = #{editTime,jdbcType=TIMESTAMP},
  219. title = #{title,jdbcType=VARCHAR},
  220. title_img = #{titleImg,jdbcType=VARCHAR},
  221. author = #{author,jdbcType=VARCHAR},
  222. type = #{type,jdbcType=INTEGER},
  223. hot = #{hot,jdbcType=INTEGER},
  224. source = #{source,jdbcType=VARCHAR},
  225. source_url = #{sourceUrl,jdbcType=VARCHAR},
  226. summary = #{summary,jdbcType=VARCHAR},
  227. jmrh_flag = #{jmrhFlag,jdbcType=INTEGER},
  228. province_id = #{provinceId,jdbcType=INTEGER}
  229. where id = #{id,jdbcType=BIGINT}
  230. </update>
  231. <select id="portalNewsList" resultType="com.goafanti.news.bo.NewsPortalList">
  232. select
  233. a.id,
  234. DATE_FORMAT(a.create_time,'%Y-%d-%m') as createTime,
  235. a.title,
  236. a.title_img as titleImg,
  237. a.type,
  238. a.hot,
  239. a.summary,
  240. a.source,
  241. a.content
  242. from news a
  243. where 1 =1
  244. <if test="provinceId != null">
  245. and a.province_id = #{provinceId,jdbcType=INTEGER}
  246. </if>
  247. <!--
  248. <if test="type != null and type != 0" >
  249. and a.type = #{type,jdbcType=INTEGER}
  250. </if>
  251. <if test="hot != null">
  252. and a.hot = #{hot,jdbcType=INTEGER}
  253. </if>
  254. <if test="keyword != null">
  255. and a.title like concat('%',#{keyword},'%')
  256. </if>
  257. -->
  258. order by create_time desc
  259. <if test="page_sql != null">
  260. ${page_sql}
  261. </if>
  262. </select>
  263. <select id="portalNewsCount" resultType="java.lang.Integer">
  264. select
  265. count(0)
  266. from news a
  267. where 1 =1
  268. <if test="provinceId != null">
  269. and a.province_id = #{provinceId,jdbcType=INTEGER}
  270. </if>
  271. <!--
  272. <if test="type != null and type != 0" >
  273. and a.type = #{type,jdbcType=INTEGER}
  274. </if>
  275. <if test="hot != null">
  276. and a.hot = #{hot,jdbcType=INTEGER}
  277. </if>
  278. <if test="keyword != null">
  279. and a.title like concat('%',#{keyword},'%')
  280. </if>
  281. -->
  282. </select>
  283. </mapper>