KnowledgeContentMapper.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.base.mapper.KnowledgeContentMapper">
  6. <resultMap type="KnowledgeContent" id="KnowledgeContentResult">
  7. <result property="id" column="id" />
  8. <result property="title" column="title" />
  9. <result property="description" column="description" />
  10. <result property="contentType" column="content_type" />
  11. <result property="contentCategory" column="content_category" />
  12. <result property="imageUrl" column="image_url" />
  13. <result property="source" column="source" />
  14. <result property="viewCount" column="view_count" />
  15. <result property="videoUrl" column="video_url" />
  16. <result property="duration" column="duration" />
  17. <result property="articleContent" column="article_content" />
  18. <result property="author" column="author" />
  19. <result property="tags" column="tags" />
  20. <result property="publishDate" column="publish_date" />
  21. <result property="createTime" column="create_time" />
  22. <result property="updateTime" column="update_time" />
  23. <result property="status" column="status" />
  24. </resultMap>
  25. <sql id="selectKnowledgeContentVo">
  26. select id, title, description, content_type, content_category, image_url, source, view_count, video_url, duration, article_content, author, tags, publish_date, create_time, update_time, status from knowledge_content
  27. </sql>
  28. <select id="selectKnowledgeContentList" parameterType="KnowledgeContent" resultMap="KnowledgeContentResult">
  29. <include refid="selectKnowledgeContentVo"/>
  30. <where>
  31. <if test="title != null and title != ''"> and title = #{title}</if>
  32. <if test="description != null and description != ''"> and description = #{description}</if>
  33. <if test="contentType != null and contentType != ''"> and content_type = #{contentType}</if>
  34. <if test="contentCategory != null and contentCategory != ''"> and content_category = #{contentCategory}</if>
  35. <if test="imageUrl != null and imageUrl != ''"> and image_url = #{imageUrl}</if>
  36. <if test="source != null and source != ''"> and source = #{source}</if>
  37. <if test="viewCount != null "> and view_count = #{viewCount}</if>
  38. <if test="videoUrl != null and videoUrl != ''"> and video_url = #{videoUrl}</if>
  39. <if test="duration != null and duration != ''"> and duration = #{duration}</if>
  40. <if test="articleContent != null and articleContent != ''"> and article_content = #{articleContent}</if>
  41. <if test="author != null and author != ''"> and author = #{author}</if>
  42. <if test="tags != null and tags != ''"> and tags = #{tags}</if>
  43. <if test="publishDate != null "> and publish_date = #{publishDate}</if>
  44. <if test="status != null "> and status = #{status}</if>
  45. </where>
  46. </select>
  47. <select id="selectKnowledgeContentById" parameterType="Long" resultMap="KnowledgeContentResult">
  48. <include refid="selectKnowledgeContentVo"/>
  49. where id = #{id}
  50. </select>
  51. <insert id="insertKnowledgeContent" parameterType="KnowledgeContent" useGeneratedKeys="true" keyProperty="id">
  52. insert into knowledge_content
  53. <trim prefix="(" suffix=")" suffixOverrides=",">
  54. <if test="title != null and title != ''">title,</if>
  55. <if test="description != null">description,</if>
  56. <if test="contentType != null and contentType != ''">content_type,</if>
  57. <if test="contentCategory != null and contentCategory != ''">content_category,</if>
  58. <if test="imageUrl != null and imageUrl != ''">image_url,</if>
  59. <if test="source != null">source,</if>
  60. <if test="viewCount != null">view_count,</if>
  61. <if test="videoUrl != null">video_url,</if>
  62. <if test="duration != null">duration,</if>
  63. <if test="articleContent != null">article_content,</if>
  64. <if test="author != null">author,</if>
  65. <if test="tags != null">tags,</if>
  66. <if test="publishDate != null">publish_date,</if>
  67. <if test="createTime != null">create_time,</if>
  68. <if test="updateTime != null">update_time,</if>
  69. <if test="status != null">status,</if>
  70. </trim>
  71. <trim prefix="values (" suffix=")" suffixOverrides=",">
  72. <if test="title != null and title != ''">#{title},</if>
  73. <if test="description != null">#{description},</if>
  74. <if test="contentType != null and contentType != ''">#{contentType},</if>
  75. <if test="contentCategory != null and contentCategory != ''">#{contentCategory},</if>
  76. <if test="imageUrl != null and imageUrl != ''">#{imageUrl},</if>
  77. <if test="source != null">#{source},</if>
  78. <if test="viewCount != null">#{viewCount},</if>
  79. <if test="videoUrl != null">#{videoUrl},</if>
  80. <if test="duration != null">#{duration},</if>
  81. <if test="articleContent != null">#{articleContent},</if>
  82. <if test="author != null">#{author},</if>
  83. <if test="tags != null">#{tags},</if>
  84. <if test="publishDate != null">#{publishDate},</if>
  85. <if test="createTime != null">#{createTime},</if>
  86. <if test="updateTime != null">#{updateTime},</if>
  87. <if test="status != null">#{status},</if>
  88. </trim>
  89. </insert>
  90. <insert id="insertKnowledgeImages" parameterType="KnowledgeImages" useGeneratedKeys="true" keyProperty="id">
  91. insert into knowledge_image (
  92. <if test="articleId != null">article_id,</if>
  93. <if test="url != null">url,</if>
  94. <if test="title != null">title,</if>
  95. <if test="subtitle != null">subtitle,</if>
  96. <if test="color != null">color,</if>
  97. <if test="sortOrder != null">sort_order,</if>
  98. <if test="imageType != null">image_type,</if>
  99. create_time
  100. ) values (
  101. <if test="articleId != null">#{articleId},</if>
  102. <if test="url != null">#{url},</if>
  103. <if test="title != null">#{title},</if>
  104. <if test="subtitle != null">#{subtitle},</if>
  105. <if test="color != null">#{color},</if>
  106. <if test="sortOrder != null">#{sortOrder},</if>
  107. <if test="imageType != null">#{imageType},</if>
  108. sysdate()
  109. )
  110. </insert>
  111. <update id="updateKnowledgeContent" parameterType="KnowledgeContent">
  112. update knowledge_content
  113. <trim prefix="SET" suffixOverrides=",">
  114. <if test="title != null and title != ''">title = #{title},</if>
  115. <if test="description != null">description = #{description},</if>
  116. <if test="contentType != null and contentType != ''">content_type = #{contentType},</if>
  117. <if test="contentCategory != null and contentCategory != ''">content_category = #{contentCategory},</if>
  118. <if test="imageUrl != null and imageUrl != ''">image_url = #{imageUrl},</if>
  119. <if test="source != null">source = #{source},</if>
  120. <if test="viewCount != null">view_count = #{viewCount},</if>
  121. <if test="videoUrl != null">video_url = #{videoUrl},</if>
  122. <if test="duration != null">duration = #{duration},</if>
  123. <if test="articleContent != null">article_content = #{articleContent},</if>
  124. <if test="author != null">author = #{author},</if>
  125. <if test="tags != null">tags = #{tags},</if>
  126. <if test="publishDate != null">publish_date = #{publishDate},</if>
  127. <if test="createTime != null">create_time = #{createTime},</if>
  128. <if test="updateTime != null">update_time = #{updateTime},</if>
  129. <if test="status != null">status = #{status},</if>
  130. </trim>
  131. where id = #{id}
  132. </update>
  133. <delete id="deleteKnowledgeContentById" parameterType="Long">
  134. delete from knowledge_content where id = #{id}
  135. </delete>
  136. <delete id="deleteKnowledgeContentByIds" parameterType="String">
  137. delete from knowledge_content where id in
  138. <foreach item="id" collection="array" open="(" separator="," close=")">
  139. #{id}
  140. </foreach>
  141. </delete>
  142. </mapper>