CmsArticleMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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.backendsys.mapper.Cms.CmsArticleMapper">-->
  4. <!-- &lt;!&ndash;ac.user,&ndash;&gt;-->
  5. <!-- &lt;!&ndash;ac.category,&ndash;&gt;-->
  6. <!-- &lt;!&ndash; a.audit_status audit_status, &ndash;&gt;-->
  7. <!-- <sql id="includeArticle">-->
  8. <!-- a.id id,-->
  9. <!-- a.id article_id,-->
  10. <!-- uf.user_id user_id,-->
  11. <!-- COALESCE(uf.nickname, '') user_nickname,-->
  12. <!-- ac.id category_id,-->
  13. <!-- ac.category_name category_name,-->
  14. <!-- at.title title,-->
  15. <!-- COALESCE(at.description, '') description,-->
  16. <!-- a.status status,-->
  17. <!-- a.is_top is_top,-->
  18. <!-- a.create_time create_time,-->
  19. <!-- a.update_time update_time-->
  20. <!-- </sql>-->
  21. <!-- &lt;!&ndash; at.title title,-->
  22. <!-- at.content content,-->
  23. <!-- COALESCE(at.description, '') description, &ndash;&gt;-->
  24. <!-- &lt;!&ndash; a.audit_status audit_status, &ndash;&gt;-->
  25. <!-- <sql id="includeArticleDetail">-->
  26. <!-- a.id id,-->
  27. <!-- a.id article_id,-->
  28. <!-- uf.user_id user_id,-->
  29. <!-- COALESCE(uf.nickname, '') user_nickname,-->
  30. <!-- ac.id category_id,-->
  31. <!-- ac.category_name category_name,-->
  32. <!-- COALESCE(a.meta_keyword, '') meta_keyword,-->
  33. <!-- COALESCE(a.meta_description, '') meta_description,-->
  34. <!-- a.status status,-->
  35. <!-- a.is_top is_top,-->
  36. <!-- a.create_time create_time,-->
  37. <!-- a.update_time update_time-->
  38. <!-- </sql>-->
  39. <!-- -->
  40. <!-- -->
  41. <!-- <sql id="includeArticleTranslation">-->
  42. <!-- id,-->
  43. <!-- article_id,-->
  44. <!-- language,-->
  45. <!-- title,-->
  46. <!-- description,-->
  47. <!-- content-->
  48. <!-- </sql>-->
  49. <!-- <resultMap id="resultMapArticle" type="java.util.LinkedHashMap">-->
  50. <!-- <id property="id" column="id" jdbcType="BIGINT" />-->
  51. <!-- <result property="article_id" column="article_id" javaType="java.lang.Long"/>-->
  52. <!-- <result property="user_id" column="user_id" javaType="java.lang.Long"/>-->
  53. <!-- <result property="category_id" column="category_id" javaType="java.lang.Long"/>-->
  54. <!-- <result property="category_name" column="category_name" />-->
  55. <!-- <result property="title" column="title" />-->
  56. <!-- <result property="description" column="description" />-->
  57. <!-- <result property="status" column="status" javaType="java.lang.Integer"/>-->
  58. <!-- &lt;!&ndash; <result property="audit_status" column="audit_status" javaType="java.lang.Integer"/> &ndash;&gt;-->
  59. <!-- <result property="is_top" column="is_top" javaType="java.lang.Integer"/>-->
  60. <!-- <result property="create_time" column="create_time" />-->
  61. <!-- <result property="update_time" column="update_time" />-->
  62. <!-- </resultMap>-->
  63. <!-- <resultMap id="resultMapArticleDetail" type="java.util.LinkedHashMap">-->
  64. <!-- <id property="id" column="id" jdbcType="BIGINT" />-->
  65. <!-- <result property="article_id" column="article_id" javaType="java.lang.Long"/>-->
  66. <!-- <result property="user_id" column="user_id" javaType="java.lang.Long"/>-->
  67. <!-- <result property="category_id" column="category_id" javaType="java.lang.Long"/>-->
  68. <!-- <result property="category_name" column="category_name" />-->
  69. <!-- &lt;!&ndash; <result property="title" column="title" />-->
  70. <!-- <result property="content" column="content" />-->
  71. <!-- <result property="description" column="description" /> &ndash;&gt;-->
  72. <!-- <result property="meta_keyword" column="meta_keyword" />-->
  73. <!-- <result property="meta_description" column="meta_description" />-->
  74. <!-- <result property="status" column="status" javaType="java.lang.Integer"/>-->
  75. <!-- &lt;!&ndash; <result property="audit_status" column="audit_status" javaType="java.lang.Integer"/> &ndash;&gt;-->
  76. <!-- <result property="is_top" column="is_top" javaType="java.lang.Integer"/>-->
  77. <!-- <result property="create_time" column="create_time" />-->
  78. <!-- <result property="update_time" column="update_time" />-->
  79. <!-- <collection property="translations" javaType="java.util.List"-->
  80. <!-- select="queryTranslationsById" column="id">-->
  81. <!-- <id property="id" column="id" />-->
  82. <!-- <result property="title" column="title" />-->
  83. <!-- <result property="content" column="content" />-->
  84. <!-- <result property="description" column="description" />-->
  85. <!-- </collection>-->
  86. <!-- </resultMap>-->
  87. <!-- <sql id="leftJoinCategory">-->
  88. <!-- LEFT JOIN cms_article_category ac ON a.category_id = ac.id-->
  89. <!-- </sql>-->
  90. <!-- <sql id="leftJoinUser">-->
  91. <!-- LEFT JOIN sys_user_info uf ON a.user_id = uf.user_id-->
  92. <!-- </sql>-->
  93. <!-- <sql id="leftJoinTranslations">-->
  94. <!-- LEFT JOIN cms_article_i18n at ON a.id = at.article_id-->
  95. <!-- </sql>-->
  96. <!-- &lt;!&ndash; 查 列表 &ndash;&gt;-->
  97. <!-- <select id="queryArticleList" resultMap="resultMapArticle">-->
  98. <!-- SELECT-->
  99. <!-- <include refid="includeArticle" />-->
  100. <!-- FROM cms_article a-->
  101. <!-- <include refid="leftJoinCategory" />-->
  102. <!-- <include refid="leftJoinUser" />-->
  103. <!-- <include refid="leftJoinTranslations" />-->
  104. <!-- <where>-->
  105. <!-- at.language = #{lang}-->
  106. <!-- <if test="title != null and title != ''">-->
  107. <!-- AND at.title LIKE CONCAT('%', #{title}, '%')-->
  108. <!-- </if>-->
  109. <!-- <if test="user_id != null and user_id != ''">-->
  110. <!-- AND a.user_id = #{user_id}-->
  111. <!-- </if>-->
  112. <!-- <if test="category_id != null and category_id != ''">-->
  113. <!-- AND a.category_id = #{category_id}-->
  114. <!-- </if>-->
  115. <!-- <if test="status != null and status != ''">-->
  116. <!-- AND a.status = #{status}-->
  117. <!-- </if>-->
  118. <!-- <if test="create_time != null and create_time != ''">-->
  119. <!-- AND a.create_time >= #{create_time}-->
  120. <!-- </if>-->
  121. <!-- </where>-->
  122. <!-- ORDER BY a.is_top = 1 DESC, a.update_time DESC-->
  123. <!-- </select>-->
  124. <!-- &lt;!&ndash; <if test="audit_status != null and audit_status != ''">-->
  125. <!-- AND a.audit_status = #{audit_status}-->
  126. <!-- </if> &ndash;&gt;-->
  127. <!-- &lt;!&ndash; 查 详情 (带翻译 Array) (二次查询) &ndash;&gt;-->
  128. <!-- <select id="queryArticleDetail" resultMap="resultMapArticleDetail">-->
  129. <!-- SELECT <include refid="includeArticleDetail" />-->
  130. <!-- FROM cms_article a-->
  131. <!-- <include refid="leftJoinCategory" />-->
  132. <!-- <include refid="leftJoinUser" />-->
  133. <!-- WHERE a.id = #{article_id}-->
  134. <!-- </select>-->
  135. <!-- &lt;!&ndash; and at.language = #{lang} &ndash;&gt;-->
  136. <!-- &lt;!&ndash; 查 翻译集合 (子查询) &ndash;&gt;-->
  137. <!-- <select id="queryTranslationsById" resultType="java.util.LinkedHashMap">-->
  138. <!-- SELECT <include refid="includeArticleTranslation" />-->
  139. <!-- FROM cms_article_i18n-->
  140. <!-- WHERE article_id = #{id}-->
  141. <!-- </select>-->
  142. <!-- &lt;!&ndash; 查 详情 (公共) (带翻译 Object) (关联查询) &ndash;&gt;-->
  143. <!-- <select id="queryArticleDetailPublic" resultMap="resultMapArticle">-->
  144. <!-- SELECT <include refid="includeArticle" />, content-->
  145. <!-- FROM cms_article a-->
  146. <!-- <include refid="leftJoinCategory" />-->
  147. <!-- <include refid="leftJoinUser" />-->
  148. <!-- <include refid="leftJoinTranslations" />-->
  149. <!-- WHERE a.id = #{article_id} AND at.language = #{lang}-->
  150. <!-- </select>-->
  151. <!-- &lt;!&ndash; 审核功能,参考 /System/SysUserMapper.xml &ndash;&gt;-->
  152. <!-- <insert id="insertArticle" parameterType="com.backendsys.entity.Cms.CmsArticleDTO"-->
  153. <!-- useGeneratedKeys="true" keyProperty="article_id">-->
  154. <!-- INSERT INTO cms_article (-->
  155. <!-- user_id, category_id-->
  156. <!-- <if test="meta_keyword != null and meta_keyword != ''">, meta_keyword</if>-->
  157. <!-- <if test="meta_description != null and meta_description != ''">, meta_description</if>-->
  158. <!-- <if test="status != null and status != ''">, status</if>-->
  159. <!-- <if test="is_top != null and is_top != ''">, is_top</if>-->
  160. <!-- )-->
  161. <!-- VALUES (-->
  162. <!-- #{user_id}, #{category_id}-->
  163. <!-- <if test="meta_keyword != null and meta_keyword != ''">, #{meta_keyword}</if>-->
  164. <!-- <if test="meta_description != null and meta_description != ''">, #{meta_description}</if>-->
  165. <!-- <if test="status != null and status != ''">, #{status}</if>-->
  166. <!-- <if test="is_top != null and is_top != ''">, #{is_top}</if>-->
  167. <!-- );-->
  168. <!-- </insert>-->
  169. <!-- <insert id="insertArticleTranslations" parameterType="java.util.List">-->
  170. <!-- INSERT INTO cms_article_i18n (-->
  171. <!-- article_id, language, title, content, description-->
  172. <!-- )-->
  173. <!-- VALUES -->
  174. <!-- <foreach collection="translations" item="translation" separator=",">-->
  175. <!-- (#{translation.article_id}, #{translation.language}, #{translation.title}, #{translation.content}, #{translation.description})-->
  176. <!-- </foreach>-->
  177. <!-- </insert>-->
  178. <!-- <update id="updateArticle" parameterType="com.backendsys.entity.Cms.CmsArticleDTO"-->
  179. <!-- useGeneratedKeys="true" keyProperty="article_id">-->
  180. <!-- UPDATE cms_article-->
  181. <!-- SET-->
  182. <!-- category_id = #{category_id}-->
  183. <!-- <if test="meta_keyword != null and meta_keyword != ''">, meta_keyword = #{meta_keyword}</if>-->
  184. <!-- <if test="meta_description != null and meta_description != ''">, meta_description = #{meta_description}</if>-->
  185. <!-- <if test="status != null and status != ''">, status = #{status}</if>-->
  186. <!-- <if test="is_top != null and is_top != ''">, is_top = #{is_top}</if>-->
  187. <!-- WHERE id = #{article_id};-->
  188. <!-- <foreach collection="translations" item="translation" separator=";">-->
  189. <!-- UPDATE cms_article_i18n-->
  190. <!-- <set>-->
  191. <!-- title = #{translation.title},-->
  192. <!-- content = #{translation.content},-->
  193. <!-- <if test="translation.description != null and translation.description != ''">-->
  194. <!-- description = #{translation.description}-->
  195. <!-- </if>-->
  196. <!-- </set>-->
  197. <!-- WHERE article_id = ${article_id} AND language = #{translation.language}-->
  198. <!-- </foreach>-->
  199. <!-- </update>-->
  200. <!-- &lt;!&ndash; <if test="audit_status != null and audit_status != ''">, audit_status = #{audit_status}</if> &ndash;&gt;-->
  201. <!-- &lt;!&ndash; 删除 &ndash;&gt;-->
  202. <!-- <delete id="deleteArticle" parameterType="java.lang.Long">-->
  203. <!-- DELETE FROM cms_article WHERE id = #{article_id};-->
  204. <!-- DELETE FROM cms_article_i18n WHERE article_id = #{article_id};-->
  205. <!-- </delete>-->
  206. <!-- &lt;!&ndash; 删除 (批量) &ndash;&gt;-->
  207. <!-- <delete id="deleteArticleBatch" parameterType="java.lang.Long">-->
  208. <!-- DELETE FROM cms_article WHERE id IN-->
  209. <!-- <foreach collection="ids" item="id" open="(" separator="," close=")">-->
  210. <!-- #{id}-->
  211. <!-- </foreach>;-->
  212. <!-- DELETE FROM cms_article_i18n WHERE article_id IN-->
  213. <!-- <foreach collection="ids" item="id" open="(" separator="," close=")">-->
  214. <!-- #{id}-->
  215. <!-- </foreach>;-->
  216. <!-- </delete>-->
  217. <!--</mapper>-->