NewsMapper.xml 10 KB

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