CmWxArticleMapper.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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.caimei.modules.miniprogram.dao.CmWxArticleDao">
  4. <sql id="cmWxArticleColumns">
  5. a.id AS "id",
  6. a.source AS "source",
  7. a.type AS "type",
  8. a.mediaId AS "mediaId",
  9. a.title AS "title",
  10. a.author AS "author",
  11. a.digest AS "digest",
  12. a.content AS "content",
  13. a.contentSourceUrl AS "contentSourceUrlfindAllList",
  14. a.thumbMediaId AS "thumbMediaId",
  15. a.showCoverPic AS "showCoverPic",
  16. a.url AS "url",
  17. a.thumbUrl AS "thumbUrl",
  18. a.needOpenComment AS "needOpenComment",
  19. a.onlyFansCanComment AS "onlyFansCanComment",
  20. a.actType AS "actType",
  21. a.actName AS "actName",
  22. a.actTime AS "actTime",
  23. a.actEndTime AS "actEndTime",
  24. a.actStatus AS "actStatus",
  25. a.deployTime AS "deployTime",
  26. a.deployStatus AS "deployStatus",
  27. a.points AS "points",
  28. a.readings AS "readings",
  29. a.pv AS "pv",
  30. a.basePoints AS "basePoints",
  31. a.baseReadings AS "baseReadings",
  32. a.createTime AS "createTime",
  33. a.updateTime AS "updateTime",
  34. a.tagId as "tagId",
  35. a.tagName as "tagName",
  36. a.keyWord as "keyWord",
  37. a.subtitle as "subtitle"
  38. </sql>
  39. <sql id="cmWxArticleJoins">
  40. </sql>
  41. <select id="get" resultType="CmWxArticle">
  42. SELECT
  43. <include refid="cmWxArticleColumns"/>
  44. FROM cm_wx_article a
  45. <include refid="cmWxArticleJoins"/>
  46. WHERE a.id = #{id}
  47. </select>
  48. <select id="getUnionArticle" resultType="CmWxArticlePo">
  49. SELECT
  50. *
  51. FROM cm_wx_article b
  52. INNER JOIN cm_wx_article_article a
  53. ON a.relatedArticleId = b.id
  54. WHERE a.articleId = #{articleId}
  55. ORDER BY a.sort;
  56. </select>
  57. <select id="getUnionProduct" resultType="ProductPo">
  58. SELECT
  59. *
  60. FROM product b
  61. INNER JOIN cm_wx_article_product a
  62. ON a.relatedProductId = b.productId
  63. WHERE b.articleId = #{articleId}
  64. and a.productCategory = 1
  65. ORDER BY a.sort;
  66. </select>
  67. <select id="findList" resultType="CmWxArticle">
  68. SELECT
  69. <include refid="cmWxArticleColumns"/>
  70. FROM cm_wx_article a
  71. <include refid="cmWxArticleJoins"/>
  72. <where>
  73. <if test="type != null and type != ''">
  74. AND a.type = #{type}
  75. </if>
  76. <choose>
  77. <when test="source !=null and source != ''">
  78. AND a.source = #{source}
  79. </when>
  80. <otherwise>
  81. AND a.source != 2
  82. </otherwise>
  83. </choose>
  84. <if test="deployStatus != null and deployStatus != ''">
  85. AND a.deployStatus = #{deployStatus}
  86. </if>
  87. <if test="deployTime != null and deployTime != ''">
  88. AND STR_TO_DATE(deployTime,'%Y-%m-%d %H:%i') <![CDATA[ > ]]> STR_TO_DATE(#{deployTime},'%Y-%m-%d %H:%i')
  89. AND STR_TO_DATE(deployTime,'%Y-%m-%d %H:%i') <![CDATA[ < ]]> DATE_SUB(STR_TO_DATE(#{deployTime},'%Y-%m-%d %H:%i'),INTERVAL -1 DAY)
  90. </if>
  91. <if test="title != null and title != ''">
  92. AND a.title LIKE
  93. <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
  94. <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
  95. <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
  96. </if>
  97. </where>
  98. <choose>
  99. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  100. ORDER BY ${page.orderBy} DESC
  101. </when>
  102. <otherwise>
  103. </otherwise>
  104. </choose>
  105. </select>
  106. <select id="findAllList" resultType="CmWxArticle">
  107. SELECT
  108. <include refid="cmWxArticleColumns"/>
  109. FROM cm_wx_article a
  110. <include refid="cmWxArticleJoins"/>
  111. <where>
  112. <if test="source != null and source != ''">
  113. AND a.source = #{source}
  114. </if>
  115. <if test="type != null and type != ''">
  116. AND a.type = #{type}
  117. </if>
  118. </where>
  119. <choose>
  120. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  121. ORDER BY ${page.orderBy} DESC
  122. </when>
  123. <otherwise>
  124. </otherwise>
  125. </choose>
  126. </select>
  127. <insert id="insert" parameterType="CmWxArticle" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
  128. INSERT INTO cm_wx_article
  129. <trim prefix="(" suffix=")" suffixOverrides="," >
  130. <if test="source != null" >
  131. source,
  132. </if>
  133. <if test="type != null" >
  134. type,
  135. </if>
  136. <if test="mediaId != null" >
  137. mediaId,
  138. </if>
  139. <if test="title != null" >
  140. title,
  141. </if>
  142. <if test="author != null" >
  143. author,
  144. </if>
  145. <if test="digest != null" >
  146. digest,
  147. </if>
  148. <if test="content != null" >
  149. content,
  150. </if>
  151. <if test="contentSourceUrl != null" >
  152. contentSourceUrl,
  153. </if>
  154. <if test="thumbMediaId != null" >
  155. thumbMediaId,
  156. </if>
  157. <if test="showCoverPic != null" >
  158. showCoverPic,
  159. </if>
  160. <if test="url != null" >
  161. url,
  162. </if>
  163. <if test="thumbUrl != null" >
  164. thumbUrl,
  165. </if>
  166. <if test="needOpenComment != null" >
  167. needOpenComment,
  168. </if>
  169. <if test="onlyFansCanComment != null" >
  170. onlyFansCanComment,
  171. </if>
  172. <if test="actType != null" >
  173. actType,
  174. </if>
  175. <if test="actName != null" >
  176. actName,
  177. </if>
  178. <if test="actTime != null" >
  179. actTime,
  180. </if>
  181. <if test="actEndTime != null" >
  182. actEndTime,
  183. </if>
  184. <if test="actStatus != null" >
  185. actStatus,
  186. </if>
  187. <if test="deployTime != null" >
  188. deployTime,
  189. </if>
  190. <if test="deployStatus != null" >
  191. deployStatus,
  192. </if>
  193. <if test="points != null" >
  194. points,
  195. </if>
  196. <if test="readings != null" >
  197. readings,
  198. </if>
  199. <if test="pv != null" >
  200. pv,
  201. </if>
  202. <if test="basePoints != null" >
  203. basePoints,
  204. </if>
  205. <if test="baseReadings != null" >
  206. baseReadings,
  207. </if>
  208. <if test="createTime != null" >
  209. createTime,
  210. </if>
  211. <if test="updateTime != null" >
  212. updateTime,
  213. </if>
  214. <if test="tagId != null" >
  215. tagId,
  216. </if>
  217. <if test="keyWord != null" >
  218. keyWord,
  219. </if>
  220. <if test="subtitle != null" >
  221. subtitle
  222. </if>
  223. </trim>
  224. <trim prefix="values (" suffix=")" suffixOverrides="," >
  225. <if test="source != null" >
  226. #{source},
  227. </if>
  228. <if test="type != null" >
  229. #{type},
  230. </if>
  231. <if test="mediaId != null" >
  232. #{mediaId},
  233. </if>
  234. <if test="title != null" >
  235. #{title},
  236. </if>
  237. <if test="author != null" >
  238. #{author},
  239. </if>
  240. <if test="digest != null" >
  241. #{digest},
  242. </if>
  243. <if test="content != null" >
  244. #{content},
  245. </if>
  246. <if test="contentSourceUrl != null" >
  247. #{contentSourceUrl},
  248. </if>
  249. <if test="thumbMediaId != null" >
  250. #{thumbMediaId},
  251. </if>
  252. <if test="showCoverPic != null" >
  253. #{showCoverPic},
  254. </if>
  255. <if test="url != null" >
  256. #{url},
  257. </if>
  258. <if test="thumbUrl != null" >
  259. #{thumbUrl},
  260. </if>
  261. <if test="needOpenComment != null" >
  262. #{needOpenComment},
  263. </if>
  264. <if test="onlyFansCanComment != null" >
  265. #{onlyFansCanComment},
  266. </if>
  267. <if test="actType != null" >
  268. #{actType},
  269. </if>
  270. <if test="actName != null" >
  271. #{actName},
  272. </if>
  273. <if test="actTime != null" >
  274. #{actTime},
  275. </if>
  276. <if test="actEndTime != null" >
  277. #{actEndTime},
  278. </if>
  279. <if test="actStatus != null" >
  280. #{actStatus},
  281. </if>
  282. <if test="deployTime != null" >
  283. #{deployTime},
  284. </if>
  285. <if test="deployStatus != null" >
  286. #{deployStatus},
  287. </if>
  288. <if test="points != null" >
  289. #{points},
  290. </if>
  291. <if test="readings != null" >
  292. #{readings},
  293. </if>
  294. <if test="pv != null" >
  295. #{pv},
  296. </if>
  297. <if test="basePoints != null" >
  298. #{basePoints},
  299. </if>
  300. <if test="baseReadings != null" >
  301. #{baseReadings},
  302. </if>
  303. <if test="createTime != null" >
  304. #{createTime},
  305. </if>
  306. <if test="updateTime != null" >
  307. #{updateTime},
  308. </if>
  309. <if test="tagId != null" >
  310. #{tagId},
  311. </if>
  312. <if test="keyWord != null" >
  313. #{keyWord},
  314. </if>
  315. <if test="subtitle != null" >
  316. #{subtitle}
  317. </if>
  318. </trim>
  319. </insert>
  320. <update id="update">
  321. UPDATE cm_wx_article SET
  322. source = #{source},
  323. type = #{type},
  324. mediaId = #{mediaId},
  325. title = #{title},
  326. author = #{author},
  327. digest = #{digest},
  328. content = #{content},
  329. contentSourceUrl = #{contentSourceUrl},
  330. thumbMediaId = #{thumbMediaId},
  331. showCoverPic = #{showCoverPic},
  332. url = #{url},
  333. thumbUrl = #{thumbUrl},
  334. needOpenComment = #{needOpenComment},
  335. onlyFansCanComment = #{onlyFansCanComment},
  336. actType = #{actType},
  337. actName = #{actName},
  338. actTime = #{actTime},
  339. actEndTime = #{actEndTime},
  340. actStatus = #{actStatus},
  341. deployTime = #{deployTime},
  342. deployStatus = #{deployStatus},
  343. points = #{points},
  344. readings = #{readings},
  345. pv = #{pv},
  346. basePoints = #{basePoints},
  347. baseReadings = #{baseReadings},
  348. createTime = #{createTime},
  349. updateTime = #{updateTime},
  350. tagId = #{tagId},
  351. keyWord = #{keyWord},
  352. subtitle = #{subtitle}
  353. WHERE id = #{id}
  354. </update>
  355. <update id="deploy">
  356. UPDATE cm_wx_article SET
  357. deployTime = #{deployTime},
  358. deployStatus = #{deployStatus}
  359. WHERE id = #{id}
  360. </update>
  361. <update id="persist">
  362. UPDATE cm_wx_article SET
  363. content = #{content},
  364. thumbUrl = #{thumbUrl},
  365. type = #{type}
  366. WHERE id = #{id}
  367. </update>
  368. <delete id="delete">
  369. DELETE FROM cm_wx_article
  370. WHERE id = #{id}
  371. </delete>
  372. <delete id="deleteAllUnionArticle">
  373. DELETE FROM cm_wx_article_article
  374. WHERE articleId = #{articleId}
  375. </delete>
  376. <delete id="deleteAllUnionProduct">
  377. DELETE FROM cm_wx_article_product
  378. WHERE articleId = #{articleId}
  379. </delete>
  380. <insert id="insertArtile" parameterType="CmWxArticlePo" keyProperty="id" useGeneratedKeys="true">
  381. INSERT INTO cm_wx_article_article(
  382. articleId,
  383. relatedArticleId,
  384. sort
  385. ) VALUES (
  386. #{articleId},
  387. #{id},
  388. #{sort}
  389. )
  390. </insert>
  391. <insert id="insertProduct" parameterType="ProductPo" keyProperty="id" useGeneratedKeys="true">
  392. INSERT INTO cm_wx_article_product(
  393. articleId,
  394. relatedProductId,
  395. sort
  396. ) VALUES (
  397. #{articleId},
  398. #{productID},
  399. #{sort}
  400. )
  401. </insert>
  402. </mapper>