NewsMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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. <result column="keyword" jdbcType="VARCHAR" property="keyword" />
  19. </resultMap>
  20. <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.goafanti.common.model.News">
  21. <result column="content" jdbcType="LONGVARCHAR" property="content" />
  22. </resultMap>
  23. <sql id="Base_Column_List">
  24. id, create_time, edit_time, title, title_img, author, type, hot, source, source_url,
  25. summary,jmrh_flag,province_id,keyword
  26. </sql>
  27. <sql id="Blob_Column_List">
  28. content
  29. </sql>
  30. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultType="com.goafanti.news.bo.NewsResult">
  31. select
  32. n.id,
  33. n.content,
  34. n.create_time as createTime,
  35. n.edit_time as editTime,
  36. n.title,
  37. n.title_img as titleImg,
  38. n.author,
  39. n.type,
  40. n.hot,
  41. n.source,
  42. n.source_url as sourceUrl,
  43. n.summary,
  44. n.province_id as provinceId,
  45. n.audit_status as auditStatus,
  46. n.release_status as releaseStatus,
  47. n.top_number as topNumber,
  48. n.hotspot,
  49. n.release_date as releaseDate,
  50. n.keyword
  51. from news n
  52. where n.id = #{id,jdbcType=BIGINT}
  53. </select>
  54. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  55. delete from news
  56. where id = #{id,jdbcType=BIGINT}
  57. </delete>
  58. <insert id="insert" parameterType="com.goafanti.common.model.News">
  59. insert into news (id, create_time, edit_time,
  60. title, title_img, author,
  61. type, hot, source,
  62. source_url, summary, content,province_id,top_number,hotspot,audit_status,release_status,release_date,keyword
  63. )
  64. values (#{id,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{editTime,jdbcType=TIMESTAMP},
  65. #{title,jdbcType=VARCHAR}, #{titleImg,jdbcType=VARCHAR}, #{author,jdbcType=VARCHAR},
  66. #{type,jdbcType=INTEGER}, #{hot,jdbcType=INTEGER}, #{source,jdbcType=VARCHAR},
  67. #{sourceUrl,jdbcType=VARCHAR}, #{summary,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR},
  68. #{provinceId,jdbcType=INTEGER}, #{topNumber,jdbcType=INTEGER}, #{hotspot,jdbcType=INTEGER},#{auditStatus,jdbcType=INTEGER},
  69. #{releaseStatus,jdbcType=INTEGER},#{releaseDate,jdbcType=TIMESTAMP},#{keyword,jdbcType=VARCHAR}
  70. )
  71. </insert>
  72. <insert id="insertSelective" parameterType="com.goafanti.common.model.News">
  73. insert into news
  74. <trim prefix="(" suffix=")" suffixOverrides=",">
  75. <if test="id != null">
  76. id,
  77. </if>
  78. <if test="createTime != null">
  79. create_time,
  80. </if>
  81. <if test="editTime != null">
  82. edit_time,
  83. </if>
  84. <if test="title != null">
  85. title,
  86. </if>
  87. <if test="titleImg != null">
  88. title_img,
  89. </if>
  90. <if test="author != null">
  91. author,
  92. </if>
  93. <if test="type != null">
  94. type,
  95. </if>
  96. <if test="hot != null">
  97. hot,
  98. </if>
  99. <if test="source != null">
  100. source,
  101. </if>
  102. <if test="sourceUrl != null">
  103. source_url,
  104. </if>
  105. <if test="summary != null">
  106. summary,
  107. </if>
  108. <if test="content != null">
  109. content,
  110. </if>
  111. <if test="jmrhFlag != null">
  112. jmrh_flag,
  113. </if>
  114. <if test="provinceId != null">
  115. province_id,
  116. </if>
  117. <if test="keyword != null">
  118. keyword,
  119. </if>
  120. </trim>
  121. <trim prefix="values (" suffix=")" suffixOverrides=",">
  122. <if test="id != null">
  123. #{id,jdbcType=BIGINT},
  124. </if>
  125. <if test="createTime != null">
  126. #{createTime,jdbcType=TIMESTAMP},
  127. </if>
  128. <if test="editTime != null">
  129. #{editTime,jdbcType=TIMESTAMP},
  130. </if>
  131. <if test="title != null">
  132. #{title,jdbcType=VARCHAR},
  133. </if>
  134. <if test="titleImg != null">
  135. #{titleImg,jdbcType=VARCHAR},
  136. </if>
  137. <if test="author != null">
  138. #{author,jdbcType=VARCHAR},
  139. </if>
  140. <if test="type != null">
  141. #{type,jdbcType=INTEGER},
  142. </if>
  143. <if test="hot != null">
  144. #{hot,jdbcType=INTEGER},
  145. </if>
  146. <if test="source != null">
  147. #{source,jdbcType=VARCHAR},
  148. </if>
  149. <if test="sourceUrl != null">
  150. #{sourceUrl,jdbcType=VARCHAR},
  151. </if>
  152. <if test="summary != null">
  153. #{summary,jdbcType=VARCHAR},
  154. </if>
  155. <if test="content != null">
  156. #{content,jdbcType=LONGVARCHAR},
  157. </if>
  158. <if test="jmrhFlag != null">
  159. #{jmrhFlag,jdbcType=INTEGER},
  160. </if>
  161. <if test="provinceId != null">
  162. #{provinceId,jdbcType=INTEGER},
  163. </if>
  164. <if test="keyword != null">
  165. #{keyword,jdbcType=VARCHAR},
  166. </if>
  167. </trim>
  168. </insert>
  169. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.News">
  170. update news
  171. <set>
  172. <if test="createTime != null">
  173. create_time = #{createTime,jdbcType=TIMESTAMP},
  174. </if>
  175. <if test="editTime != null">
  176. edit_time = #{editTime,jdbcType=TIMESTAMP},
  177. </if>
  178. <if test="title != null">
  179. title = #{title,jdbcType=VARCHAR},
  180. </if>
  181. <if test="titleImg != null">
  182. title_img = #{titleImg,jdbcType=VARCHAR},
  183. </if>
  184. <if test="author != null">
  185. author = #{author,jdbcType=VARCHAR},
  186. </if>
  187. <if test="type != null">
  188. type = #{type,jdbcType=INTEGER},
  189. </if>
  190. <if test="hot != null">
  191. hot = #{hot,jdbcType=INTEGER},
  192. </if>
  193. <if test="source != null">
  194. source = #{source,jdbcType=VARCHAR},
  195. </if>
  196. <if test="sourceUrl != null">
  197. source_url = #{sourceUrl,jdbcType=VARCHAR},
  198. </if>
  199. <if test="summary != null">
  200. summary = #{summary,jdbcType=VARCHAR},
  201. </if>
  202. <if test="content != null">
  203. content = #{content,jdbcType=LONGVARCHAR},
  204. </if>
  205. <if test="releaseDate!=null">
  206. release_date=#{releaseDate,jdbcType=TIMESTAMP},
  207. </if>
  208. <if test="provinceId!=null">
  209. province_id=#{provinceId,jdbcType=INTEGER},
  210. </if>
  211. <if test="auditStatus!=null">
  212. audit_status=#{auditStatus,jdbcType=INTEGER},
  213. </if>
  214. <if test="releaseStatus!=null">
  215. release_status=#{releaseStatus,jdbcType=INTEGER},
  216. </if>
  217. <if test="topNumber!=null">
  218. top_number=#{topNumber,jdbcType=INTEGER},
  219. </if>
  220. <if test="hotspot!=null">
  221. hotspot=#{hotspot,jdbcType=INTEGER},
  222. </if>
  223. <if test="keyword != null">
  224. keyword= #{keyword,jdbcType=VARCHAR},
  225. </if>
  226. </set>
  227. where id = #{id,jdbcType=BIGINT}
  228. </update>
  229. <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.goafanti.common.model.News">
  230. update news
  231. set create_time = #{createTime,jdbcType=TIMESTAMP},
  232. edit_time = #{editTime,jdbcType=TIMESTAMP},
  233. title = #{title,jdbcType=VARCHAR},
  234. title_img = #{titleImg,jdbcType=VARCHAR},
  235. author = #{author,jdbcType=VARCHAR},
  236. type = #{type,jdbcType=INTEGER},
  237. hot = #{hot,jdbcType=INTEGER},
  238. source = #{source,jdbcType=VARCHAR},
  239. source_url = #{sourceUrl,jdbcType=VARCHAR},
  240. summary = #{summary,jdbcType=VARCHAR},
  241. content = #{content,jdbcType=LONGVARCHAR},
  242. jmrh_flag = #{jmrhFlag,jdbcType=INTEGER},
  243. province_id = #{provinceId,jdbcType=INTEGER},
  244. audit_status = #{auditStatus,jdbcType=INTEGER},
  245. release_status = #{releaseStatus,jdbcType=INTEGER},
  246. top_number = #{topNumber,jdbcType=INTEGER},
  247. hotspot = #{hotspot,jdbcType=INTEGER},
  248. keyword= #{keyword,jdbcType=VARCHAR},
  249. where id = #{id,jdbcType=BIGINT}
  250. </update>
  251. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.News">
  252. update news
  253. set create_time = #{createTime,jdbcType=TIMESTAMP},
  254. edit_time = #{editTime,jdbcType=TIMESTAMP},
  255. title = #{title,jdbcType=VARCHAR},
  256. title_img = #{titleImg,jdbcType=VARCHAR},
  257. author = #{author,jdbcType=VARCHAR},
  258. type = #{type,jdbcType=INTEGER},
  259. hot = #{hot,jdbcType=INTEGER},
  260. source = #{source,jdbcType=VARCHAR},
  261. source_url = #{sourceUrl,jdbcType=VARCHAR},
  262. summary = #{summary,jdbcType=VARCHAR},
  263. jmrh_flag = #{jmrhFlag,jdbcType=INTEGER},
  264. province_id = #{provinceId,jdbcType=INTEGER},
  265. keyword= #{keyword,jdbcType=VARCHAR},
  266. where id = #{id,jdbcType=BIGINT}
  267. </update>
  268. <select id="portalNewsList" resultType="com.goafanti.news.bo.NewsPortalList">
  269. select
  270. a.id,
  271. DATE_FORMAT(a.create_time,'%Y-%m-%d') as createTime,
  272. a.title,
  273. a.title_img as titleImg,
  274. a.type,
  275. a.hot,
  276. a.summary,
  277. a.source,
  278. a.content,
  279. release_date as releaseDate
  280. from news a
  281. where 1=1
  282. and (a.type = 0 or a.type = 99 or a.type =98)
  283. <if test="provinceId != null">
  284. and a.province_id = #{provinceId,jdbcType=INTEGER}
  285. </if>
  286. <if test="type != null" >
  287. and a.type = #{type,jdbcType=INTEGER}
  288. </if>
  289. <!--
  290. <if test="hot != null">
  291. and a.hot = #{hot,jdbcType=INTEGER}
  292. </if>
  293. -->
  294. <if test="keyword != null">
  295. and a.title like concat('%',#{keyword},'%')
  296. </if>
  297. <if test="auditStatus!=null">
  298. and a.audit_status=#{auditStatus,jdbcType=INTEGER}
  299. </if>
  300. order by release_date desc
  301. <if test="page_sql != null">
  302. ${page_sql}
  303. </if>
  304. </select>
  305. <select id="portalNewsCount" resultType="java.lang.Integer">
  306. select
  307. count(0)
  308. from news a
  309. where
  310. (a.type = 0 or a.type = 99 or a.type =98)
  311. <if test="provinceId != null">
  312. and a.province_id = #{provinceId,jdbcType=INTEGER}
  313. </if>
  314. <if test="type != null and type != 0 and type != 1 and type != 2" >
  315. and a.type = #{type,jdbcType=INTEGER}
  316. </if>
  317. <!--
  318. <if test="hot != null">
  319. and a.hot = #{hot,jdbcType=INTEGER}
  320. </if>
  321. -->
  322. <if test="keyword != null">
  323. and a.title like concat('%',#{keyword},'%')
  324. </if>
  325. <if test="auditStatus!=null">
  326. and a.audit_status=#{auditStatus,jdbcType=INTEGER}
  327. </if>
  328. </select>
  329. <select id="portalNewsPolicy" resultType="com.goafanti.news.bo.NewsPortalList">
  330. select
  331. a.id,
  332. DATE_FORMAT(a.create_time,'%Y-%d-%m') as createTime,
  333. a.title,
  334. a.title_img as titleImg,
  335. a.type,
  336. a.hot,
  337. a.summary,
  338. a.source,
  339. a.content
  340. from news a
  341. where
  342. a.type =5 or a.type =4
  343. order by create_time desc
  344. </select>
  345. <select id="portalNewsQuestion" resultType="com.goafanti.news.bo.NewsPortalList">
  346. select
  347. a.id,
  348. DATE_FORMAT(a.create_time,'%Y-%d-%m') as createTime,
  349. a.title,
  350. a.title_img as titleImg,
  351. a.type,
  352. a.hot,
  353. a.summary,
  354. a.source,
  355. a.content
  356. from news a
  357. where
  358. a.type =2
  359. order by create_time desc
  360. </select>
  361. <select id="newsInterest" resultType="com.goafanti.news.bo.newsInterestBo">
  362. select
  363. n.id,n.title ,n.create_time as createTime
  364. from news_interest ni
  365. LEFT join news n on ni.new_id=n.id
  366. where uid=#{uid,jdbcType=VARCHAR}
  367. </select>
  368. <select id="appNewsList" resultType="com.goafanti.app.bo.AppDiscoveryBo">
  369. select
  370. a.id,
  371. DATE_FORMAT(a.release_date,'%Y-%m-%d') as releaseDate,
  372. a.title,
  373. a.content,
  374. a.title_img as titleImg
  375. from news a
  376. left join district_glossory d on a.province_id=d.id
  377. where a.type =0 and audit_status=2
  378. order by a.release_date desc
  379. <if test="page_sql != null">
  380. ${page_sql}
  381. </if>
  382. </select>
  383. <select id="appNewsCount" resultType="java.lang.Integer">
  384. select
  385. count(0)
  386. from news a
  387. left join district_glossory d on a.province_id=d.id
  388. where a.type =0
  389. </select>
  390. <select id="getNewsList" resultType="com.goafanti.common.model.News">
  391. select
  392. title,
  393. create_time as createTime,
  394. id
  395. from
  396. news
  397. order by
  398. create_time desc limit #{0}
  399. </select>
  400. <select id="getPolicyDetail" resultType="com.goafanti.common.bo.PolicyEntity">
  401. select p.id,p.title,p.title_img as titleImg,p.summary,
  402. p.content,dg1.name as provinceS,dg2.name as cityS,edit_time as editTime ,create_time as createTime,p.id,p.source,p.source_url as sourceUrl from policy p
  403. left join district_glossory dg1 on dg1.id=p.province
  404. left join district_glossory dg2 on dg2.id=p.city
  405. where audit_status = 2 and p.id=#{0}
  406. </select>
  407. <select id="encyclopediaList" resultType="com.goafanti.app.bo.AppDiscoveryBo">
  408. select
  409. a.id,
  410. DATE_FORMAT(a.release_date,'%Y-%m-%d') as releaseDate,
  411. a.title,
  412. a.content,
  413. a.title_img as titleImg
  414. from news a
  415. left join district_glossory d on a.province_id=d.id
  416. where a.type =98 and audit_status=2
  417. order by a.release_date desc
  418. <if test="page_sql != null">
  419. ${page_sql}
  420. </if>
  421. </select>
  422. <select id="encyclopediaCount" resultType="java.lang.Integer">
  423. select
  424. count(0)
  425. from news a
  426. left join district_glossory d on a.province_id=d.id
  427. where a.type =98
  428. </select>
  429. </mapper>