CommunityNewsMapper.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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.system.mapper.CommunityNewsMapper">
  6. <resultMap type="CommunityNews" id="CommunityNewsResult">
  7. <result property="communityId" column="community_id" />
  8. <result property="communityTitle" column="community_title" />
  9. <result property="communityType" column="community_type" />
  10. <result property="communityContent" column="community_content" />
  11. <result property="status" column="status" />
  12. <result property="publishTime" column="publish_time" />
  13. <result property="userId" column="user_id" />
  14. <result property="staffId" column="staff_id" />
  15. <result property="staffName" column="staff_name" />
  16. <result property="author" column="author" />
  17. <result property="source" column="source" />
  18. <result property="coverImage" column="cover_image" />
  19. <result property="viewCount" column="view_count" />
  20. <result property="isTop" column="is_top" />
  21. <result property="userComment" column="user_comment" />
  22. <result property="userLikes" column="user_likes" />
  23. <result property="userStars" column="user_stars" />
  24. <result property="createBy" column="create_by" />
  25. <result property="createTime" column="create_time" />
  26. <result property="updateBy" column="update_by" />
  27. <result property="updateTime" column="update_time" />
  28. <result property="remark" column="remark" />
  29. </resultMap>
  30. <sql id="selectCommunityNewsVo">
  31. select community_id, community_title, community_type, community_content, status, publish_time, user_id, staff_id, staff_name, author, source, cover_image, view_count, is_top, user_comment, user_likes, user_stars, create_by, create_time, update_by, update_time, remark from community_news
  32. </sql>
  33. <select id="selectCommunityNewsList" parameterType="CommunityNews" resultMap="CommunityNewsResult">
  34. <include refid="selectCommunityNewsVo"/>
  35. <where>
  36. <if test="communityTitle != null and communityTitle != ''"> and community_title like concat('%', #{communityTitle}, '%')</if>
  37. <if test="communityType != null and communityType != ''"> and community_type = #{communityType}</if>
  38. <if test="communityContent != null and communityContent != ''"> and community_content = #{communityContent}</if>
  39. <if test="status != null and status != ''"> and status = #{status}</if>
  40. <if test="publishTime != null "> and publish_time = #{publishTime}</if>
  41. <if test="userId != null "> and user_id = #{userId}</if>
  42. <if test="staffId != null "> and staff_id = #{staffId}</if>
  43. <if test="staffName != null and staffName != ''"> and staff_name like concat('%', #{staffName}, '%')</if>
  44. <if test="author != null and author != ''"> and author = #{author}</if>
  45. <if test="source != null and source != ''"> and source = #{source}</if>
  46. <if test="coverImage != null and coverImage != ''"> and cover_image = #{coverImage}</if>
  47. <if test="viewCount != null "> and view_count = #{viewCount}</if>
  48. <if test="isTop != null and isTop != ''"> and is_top = #{isTop}</if>
  49. <if test="userComment != null and userComment != ''"> and user_comment = #{userComment}</if>
  50. <if test="userLikes != null and userLikes != ''"> and user_likes = #{userLikes}</if>
  51. <if test="userStars != null and userStars != ''"> and user_stars = #{userStars}</if>
  52. </where>
  53. order by is_top DESC, publish_time DESC,create_time DESC
  54. </select>
  55. <select id="selectCommunityNewsByCommunityId" parameterType="Long" resultMap="CommunityNewsResult">
  56. <include refid="selectCommunityNewsVo"/>
  57. where community_id = #{communityId}
  58. </select>
  59. <insert id="insertCommunityNews" parameterType="CommunityNews" useGeneratedKeys="true" keyProperty="communityId">
  60. insert into community_news
  61. <trim prefix="(" suffix=")" suffixOverrides=",">
  62. <if test="communityTitle != null and communityTitle != ''">community_title,</if>
  63. <if test="communityType != null and communityType != ''">community_type,</if>
  64. <if test="communityContent != null">community_content,</if>
  65. <if test="status != null">status,</if>
  66. <if test="publishTime != null">publish_time,</if>
  67. <if test="userId != null">user_id,</if>
  68. <if test="staffId != null">staff_id,</if>
  69. <if test="staffName != null">staff_name,</if>
  70. <if test="author != null">author,</if>
  71. <if test="source != null">source,</if>
  72. <if test="coverImage != null">cover_image,</if>
  73. <if test="viewCount != null">view_count,</if>
  74. <if test="isTop != null">is_top,</if>
  75. <if test="userComment != null">user_comment,</if>
  76. <if test="userLikes != null">user_likes,</if>
  77. <if test="userStars != null">user_stars,</if>
  78. <if test="createBy != null">create_by,</if>
  79. <if test="createTime != null">create_time,</if>
  80. <if test="updateBy != null">update_by,</if>
  81. <if test="updateTime != null">update_time,</if>
  82. <if test="remark != null">remark,</if>
  83. </trim>
  84. <trim prefix="values (" suffix=")" suffixOverrides=",">
  85. <if test="communityTitle != null and communityTitle != ''">#{communityTitle},</if>
  86. <if test="communityType != null and communityType != ''">#{communityType},</if>
  87. <if test="communityContent != null">#{communityContent},</if>
  88. <if test="status != null">#{status},</if>
  89. <if test="publishTime != null">#{publishTime},</if>
  90. <if test="userId != null">#{userId},</if>
  91. <if test="staffId != null">#{staffId},</if>
  92. <if test="staffName != null">#{staffName},</if>
  93. <if test="author != null">#{author},</if>
  94. <if test="source != null">#{source},</if>
  95. <if test="coverImage != null">#{coverImage},</if>
  96. <if test="viewCount != null">#{viewCount},</if>
  97. <if test="isTop != null">#{isTop},</if>
  98. <if test="userComment != null">#{userComment},</if>
  99. <if test="userLikes != null">#{userLikes},</if>
  100. <if test="userStars != null">#{userStars},</if>
  101. <if test="createBy != null">#{createBy},</if>
  102. <if test="createTime != null">#{createTime},</if>
  103. <if test="updateBy != null">#{updateBy},</if>
  104. <if test="updateTime != null">#{updateTime},</if>
  105. <if test="remark != null">#{remark},</if>
  106. </trim>
  107. </insert>
  108. <update id="updateCommunityNews" parameterType="CommunityNews">
  109. update community_news
  110. <trim prefix="SET" suffixOverrides=",">
  111. <if test="communityTitle != null and communityTitle != ''">community_title = #{communityTitle},</if>
  112. <if test="communityType != null and communityType != ''">community_type = #{communityType},</if>
  113. <if test="communityContent != null">community_content = #{communityContent},</if>
  114. <if test="status != null">status = #{status},</if>
  115. <if test="publishTime != null">publish_time = #{publishTime},</if>
  116. <if test="userId != null">user_id = #{userId},</if>
  117. <if test="staffId != null">staff_id = #{staffId},</if>
  118. <if test="staffName != null">staff_name = #{staffName},</if>
  119. <if test="author != null">author = #{author},</if>
  120. <if test="source != null">source = #{source},</if>
  121. <if test="coverImage != null">cover_image = #{coverImage},</if>
  122. <if test="viewCount != null">view_count = #{viewCount},</if>
  123. <if test="isTop != null">is_top = #{isTop},</if>
  124. <if test="userComment != null">user_comment = #{userComment},</if>
  125. <if test="userLikes != null">user_likes = #{userLikes},</if>
  126. <if test="userStars != null">user_stars = #{userStars},</if>
  127. <if test="createBy != null">create_by = #{createBy},</if>
  128. <if test="createTime != null">create_time = #{createTime},</if>
  129. <if test="updateBy != null">update_by = #{updateBy},</if>
  130. <if test="updateTime != null">update_time = #{updateTime},</if>
  131. <if test="remark != null">remark = #{remark},</if>
  132. </trim>
  133. where community_id = #{communityId}
  134. </update>
  135. <update id="updateCommunityNewsStars" parameterType="CommunityNews">
  136. update community_news set user_stars = #{userStars} where community_id = #{communityId}
  137. </update>
  138. <update id="updateCommunityNewsStarsByCommunityId" parameterType="String">
  139. update community_news set status = '2' where community_id in
  140. <foreach item="communityId" collection="array" open="(" separator="," close=")">
  141. #{communityId}
  142. </foreach>
  143. </update>
  144. <delete id="deleteCommunityNewsByCommunityId" parameterType="Long">
  145. delete from community_news where community_id = #{communityId}
  146. </delete>
  147. <delete id="deleteCommunityNewsByCommunityIds" parameterType="String">
  148. delete from community_news where community_id in
  149. <foreach item="communityId" collection="array" open="(" separator="," close=")">
  150. #{communityId}
  151. </foreach>
  152. </delete>
  153. </mapper>