NewsMapper.xml 13 KB

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