NewsMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. audit_status as auditStatus,
  46. release_status as releaseStatus,
  47. top_number as topNumber,
  48. hotspot
  49. from news
  50. where id = #{id,jdbcType=BIGINT}
  51. </select>
  52. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  53. delete from news
  54. where id = #{id,jdbcType=BIGINT}
  55. </delete>
  56. <insert id="insert" parameterType="com.goafanti.common.model.News">
  57. insert into news (id, create_time, edit_time,
  58. title, title_img, author,
  59. type, hot, source,
  60. source_url, summary, content,jmrh_flag,province_id,top_number,hotspot
  61. )
  62. values (#{id,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{editTime,jdbcType=TIMESTAMP},
  63. #{title,jdbcType=VARCHAR}, #{titleImg,jdbcType=VARCHAR}, #{author,jdbcType=VARCHAR},
  64. #{type,jdbcType=INTEGER}, #{hot,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR},
  65. #{sourceUrl,jdbcType=VARCHAR}, #{summary,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR},
  66. #{jmrhFlag,jdbcType=INTEGER}, #{provinceId,jdbcType=INTEGER}, #{topNumber,jdbcType=INTEGER}, #{hotspot,jdbcType=INTEGER}
  67. )
  68. </insert>
  69. <insert id="insertSelective" parameterType="com.goafanti.common.model.News">
  70. insert into news
  71. <trim prefix="(" suffix=")" suffixOverrides=",">
  72. <if test="id != null">
  73. id,
  74. </if>
  75. <if test="createTime != null">
  76. create_time,
  77. </if>
  78. <if test="editTime != null">
  79. edit_time,
  80. </if>
  81. <if test="title != null">
  82. title,
  83. </if>
  84. <if test="titleImg != null">
  85. title_img,
  86. </if>
  87. <if test="author != null">
  88. author,
  89. </if>
  90. <if test="type != null">
  91. type,
  92. </if>
  93. <if test="hot != null">
  94. hot,
  95. </if>
  96. <if test="source != null">
  97. source,
  98. </if>
  99. <if test="sourceUrl != null">
  100. source_url,
  101. </if>
  102. <if test="summary != null">
  103. summary,
  104. </if>
  105. <if test="content != null">
  106. content,
  107. </if>
  108. <if test="jmrhFlag != null">
  109. jmrh_flag,
  110. </if>
  111. <if test="provinceId != null">
  112. province_id,
  113. </if>
  114. </trim>
  115. <trim prefix="values (" suffix=")" suffixOverrides=",">
  116. <if test="id != null">
  117. #{id,jdbcType=BIGINT},
  118. </if>
  119. <if test="createTime != null">
  120. #{createTime,jdbcType=TIMESTAMP},
  121. </if>
  122. <if test="editTime != null">
  123. #{editTime,jdbcType=TIMESTAMP},
  124. </if>
  125. <if test="title != null">
  126. #{title,jdbcType=VARCHAR},
  127. </if>
  128. <if test="titleImg != null">
  129. #{titleImg,jdbcType=VARCHAR},
  130. </if>
  131. <if test="author != null">
  132. #{author,jdbcType=VARCHAR},
  133. </if>
  134. <if test="type != null">
  135. #{type,jdbcType=INTEGER},
  136. </if>
  137. <if test="hot != null">
  138. #{hot,jdbcType=INTEGER},
  139. </if>
  140. <if test="source != null">
  141. #{source,jdbcType=VARCHAR},
  142. </if>
  143. <if test="sourceUrl != null">
  144. #{sourceUrl,jdbcType=VARCHAR},
  145. </if>
  146. <if test="summary != null">
  147. #{summary,jdbcType=VARCHAR},
  148. </if>
  149. <if test="content != null">
  150. #{content,jdbcType=LONGVARCHAR},
  151. </if>
  152. <if test="jmrhFlag != null">
  153. #{jmrhFlag,jdbcType=INTEGER},
  154. </if>
  155. <if test="provinceId != null">
  156. #{provinceId,jdbcType=INTEGER},
  157. </if>
  158. </trim>
  159. </insert>
  160. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.News">
  161. update news
  162. <set>
  163. <if test="createTime != null">
  164. create_time = #{createTime,jdbcType=TIMESTAMP},
  165. </if>
  166. <if test="editTime != null">
  167. edit_time = #{editTime,jdbcType=TIMESTAMP},
  168. </if>
  169. <if test="title != null">
  170. title = #{title,jdbcType=VARCHAR},
  171. </if>
  172. <if test="titleImg != null">
  173. title_img = #{titleImg,jdbcType=VARCHAR},
  174. </if>
  175. <if test="author != null">
  176. author = #{author,jdbcType=VARCHAR},
  177. </if>
  178. <if test="type != null">
  179. type = #{type,jdbcType=INTEGER},
  180. </if>
  181. <if test="hot != null">
  182. hot = #{hot,jdbcType=INTEGER},
  183. </if>
  184. <if test="source != null">
  185. source = #{source,jdbcType=VARCHAR},
  186. </if>
  187. <if test="sourceUrl != null">
  188. source_url = #{sourceUrl,jdbcType=VARCHAR},
  189. </if>
  190. <if test="summary != null">
  191. summary = #{summary,jdbcType=VARCHAR},
  192. </if>
  193. <if test="content != null">
  194. content = #{content,jdbcType=LONGVARCHAR},
  195. </if>
  196. <if test="jmrhFlag != null">
  197. content = #{jmrhFlag,jdbcType=INTEGER},
  198. </if>
  199. </set>
  200. where id = #{id,jdbcType=BIGINT}
  201. </update>
  202. <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.goafanti.common.model.News">
  203. update news
  204. set create_time = #{createTime,jdbcType=TIMESTAMP},
  205. edit_time = #{editTime,jdbcType=TIMESTAMP},
  206. title = #{title,jdbcType=VARCHAR},
  207. title_img = #{titleImg,jdbcType=VARCHAR},
  208. author = #{author,jdbcType=VARCHAR},
  209. type = #{type,jdbcType=INTEGER},
  210. hot = #{hot,jdbcType=INTEGER},
  211. source = #{source,jdbcType=VARCHAR},
  212. source_url = #{sourceUrl,jdbcType=VARCHAR},
  213. summary = #{summary,jdbcType=VARCHAR},
  214. content = #{content,jdbcType=LONGVARCHAR},
  215. jmrh_flag = #{jmrhFlag,jdbcType=INTEGER},
  216. province_id = #{provinceId,jdbcType=INTEGER},
  217. audit_status = #{auditStatus,jdbcType=INTEGER},
  218. release_status = #{releaseStatus,jdbcType=INTEGER},
  219. top_number = #{topNumber,jdbcType=INTEGER},
  220. hotspot = #{hotspot,jdbcType=INTEGER}
  221. where id = #{id,jdbcType=BIGINT}
  222. </update>
  223. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.News">
  224. update news
  225. set create_time = #{createTime,jdbcType=TIMESTAMP},
  226. edit_time = #{editTime,jdbcType=TIMESTAMP},
  227. title = #{title,jdbcType=VARCHAR},
  228. title_img = #{titleImg,jdbcType=VARCHAR},
  229. author = #{author,jdbcType=VARCHAR},
  230. type = #{type,jdbcType=INTEGER},
  231. hot = #{hot,jdbcType=INTEGER},
  232. source = #{source,jdbcType=VARCHAR},
  233. source_url = #{sourceUrl,jdbcType=VARCHAR},
  234. summary = #{summary,jdbcType=VARCHAR},
  235. jmrh_flag = #{jmrhFlag,jdbcType=INTEGER},
  236. province_id = #{provinceId,jdbcType=INTEGER}
  237. where id = #{id,jdbcType=BIGINT}
  238. </update>
  239. <select id="portalNewsList" resultType="com.goafanti.news.bo.NewsPortalList">
  240. select
  241. a.id,
  242. DATE_FORMAT(a.create_time,'%Y-%m-%d') as createTime,
  243. a.title,
  244. a.title_img as titleImg,
  245. a.type,
  246. a.hot,
  247. a.summary,
  248. a.source,
  249. a.content
  250. from news a
  251. where
  252. a.type != 1 and a.type != 2
  253. <if test="provinceId != null">
  254. and a.province_id = #{provinceId,jdbcType=INTEGER}
  255. </if>
  256. <if test="type != null and type != 0 " >
  257. and a.type = #{type,jdbcType=INTEGER}
  258. </if>
  259. <!--
  260. <if test="hot != null">
  261. and a.hot = #{hot,jdbcType=INTEGER}
  262. </if>
  263. -->
  264. <if test="keyword != null">
  265. and a.title like concat('%',#{keyword},'%')
  266. </if>
  267. order by create_time desc
  268. <if test="page_sql != null">
  269. ${page_sql}
  270. </if>
  271. </select>
  272. <select id="portalNewsCount" resultType="java.lang.Integer">
  273. select
  274. count(0)
  275. from news a
  276. where
  277. a.type != 1 and a.type != 2
  278. <if test="provinceId != null">
  279. and a.province_id = #{provinceId,jdbcType=INTEGER}
  280. </if>
  281. <if test="type != null and type != 0 and type != 1 and type != 2" >
  282. and a.type = #{type,jdbcType=INTEGER}
  283. </if>
  284. <!--
  285. <if test="hot != null">
  286. and a.hot = #{hot,jdbcType=INTEGER}
  287. </if>
  288. -->
  289. <if test="keyword != null">
  290. and a.title like concat('%',#{keyword},'%')
  291. </if>
  292. </select>
  293. <select id="portalNewsPolicy" resultType="com.goafanti.news.bo.NewsPortalList">
  294. select
  295. a.id,
  296. DATE_FORMAT(a.create_time,'%Y-%d-%m') as createTime,
  297. a.title,
  298. a.title_img as titleImg,
  299. a.type,
  300. a.hot,
  301. a.summary,
  302. a.source,
  303. a.content
  304. from news a
  305. where
  306. a.type =5 or a.type =4
  307. order by create_time desc
  308. </select>
  309. <select id="portalNewsQuestion" resultType="com.goafanti.news.bo.NewsPortalList">
  310. select
  311. a.id,
  312. DATE_FORMAT(a.create_time,'%Y-%d-%m') as createTime,
  313. a.title,
  314. a.title_img as titleImg,
  315. a.type,
  316. a.hot,
  317. a.summary,
  318. a.source,
  319. a.content
  320. from news a
  321. where
  322. a.type =2
  323. order by create_time desc
  324. </select>
  325. <select id="newsInterest" resultType="com.goafanti.news.bo.newsInterestBo">
  326. select
  327. n.id,n.title ,n.create_time as createTime
  328. from news_interest ni
  329. LEFT join news n on ni.new_id=n.id
  330. where uid=#{uid,jdbcType=VARCHAR}
  331. </select>
  332. <select id="appNewsList" resultType="com.goafanti.news.bo.NewsPortalList">
  333. select
  334. a.id,
  335. DATE_FORMAT(a.create_time,'%Y-%m-%d') as createTime,
  336. a.title,
  337. a.title_img as titleImg,
  338. a.type,
  339. a.hot,
  340. a.summary,
  341. a.source,
  342. a.content,
  343. top_number as topNumber,
  344. hotspot
  345. from news a
  346. left join district_glossory d on a.province_id=d.id
  347. where
  348. a.type != 1 and a.type != 2
  349. <if test="param != null">
  350. and a.title like concat('%',#{param},'%')
  351. or a.source like concat('%',#{param},'%')
  352. or d.name like concat('%',#{param},'%')
  353. </if>
  354. order by IF(ISNULL(top_number),1,0) ,top_number asc,
  355. IF(ISNULL(hotspot),1,0),hotspot asc,
  356. create_time desc
  357. <if test="page_sql != null">
  358. ${page_sql}
  359. </if>
  360. </select>
  361. <select id="appNewsCount" resultType="java.lang.Integer">
  362. select
  363. count(0)
  364. from news a
  365. left join district_glossory d on a.province_id=d.id
  366. where
  367. a.type != 1 and a.type != 2
  368. <if test="param != null">
  369. and a.title like concat('%',#{param},'%')
  370. or a.source like concat('%',#{param},'%')
  371. or d.name like concat('%',#{param},'%')
  372. </if>
  373. </select>
  374. </mapper>