FsCourseWatchCommentMapper.xml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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.fs.course.mapper.FsCourseWatchCommentMapper">
  6. <resultMap type="FsCourseWatchComment" id="FsCourseWatchCommentResult">
  7. <result property="commentId" column="comment_id" />
  8. <result property="userId" column="user_id" />
  9. <result property="userType" column="user_type" />
  10. <result property="courseId" column="course_id" />
  11. <result property="videoId" column="video_id" />
  12. <result property="type" column="type" />
  13. <result property="parentId" column="parent_id" />
  14. <result property="content" column="content" />
  15. <result property="createTime" column="create_time" />
  16. <result property="updateTime" column="update_time" />
  17. <result property="isRevoke" column="is_revoke" />
  18. <result property="time" column="time" />
  19. <result property="fontSize" column="font_size" />
  20. <result property="mode" column="mode" />
  21. <result property="color" column="color" />
  22. </resultMap>
  23. <sql id="selectFsCourseWatchCommentVo">
  24. select comment_id, user_id, user_type, course_id, video_id, type, parent_id, content, create_time, update_time, is_revoke, `time`,
  25. font_size, mode, color from fs_course_watch_comment
  26. </sql>
  27. <select id="selectFsCourseWatchCommentList" resultType="com.fs.course.vo.FsCourseWatchCommentListVO">
  28. SELECT
  29. fs_course_watch_comment.comment_id,
  30. fs_course_watch_comment.user_id,
  31. fs_course_watch_comment.user_type,
  32. fs_course_watch_comment.course_id,
  33. fs_course_watch_comment.video_id,
  34. fs_course_watch_comment.type,
  35. fs_course_watch_comment.parent_id,
  36. fs_course_watch_comment.content,
  37. fs_course_watch_comment.create_time,
  38. fs_course_watch_comment.update_time,
  39. fs_course_watch_comment.is_revoke,
  40. fs_course_watch_comment.`time`,
  41. fs_course_watch_comment.font_size,
  42. fs_course_watch_comment.`mode`,
  43. fs_course_watch_comment.color,
  44. fs_user.nick_name
  45. <if test="isAll != null and isAll == true ">
  46. ,fs_user_course.course_name, fs_user_course_video.title
  47. </if>
  48. FROM
  49. fs_course_watch_comment
  50. LEFT JOIN fs_user ON fs_user.user_id = fs_course_watch_comment.user_id
  51. <if test="isAll != null and isAll == true">
  52. LEFT JOIN fs_user_course on fs_user_course.course_id = fs_course_watch_comment.course_id
  53. LEFT JOIN fs_user_course_video on fs_user_course_video.video_id = fs_course_watch_comment.video_id
  54. </if>
  55. <where>
  56. <if test="courseId != null "> and fs_course_watch_comment.course_id = #{courseId}</if>
  57. <if test="videoId != null "> and fs_course_watch_comment.video_id = #{videoId}</if>
  58. <if test="nickName != null and nickName != '' ">and fs_user.nick_name like concat('%', #{nickName}, '%')</if>
  59. <if test="isAll != null and isAll == true and keywords != null and keywords !='' ">
  60. AND (fs_user.nickname LIKE concat('%',#{keywords},'%')
  61. or fs_user_course.course_name LIKE concat('%',#{keywords},'%')
  62. or fs_user_course_video.title LIKE concat('%',#{keywords},'%')
  63. )
  64. </if>
  65. </where>
  66. </select>
  67. <select id="selectFsCourseWatchCommentByCommentId" parameterType="Long" resultMap="FsCourseWatchCommentResult">
  68. <include refid="selectFsCourseWatchCommentVo"/>
  69. where comment_id = #{commentId}
  70. </select>
  71. <insert id="insertFsCourseWatchComment" parameterType="FsCourseWatchComment" useGeneratedKeys="true" keyProperty="commentId">
  72. insert into fs_course_watch_comment
  73. <trim prefix="(" suffix=")" suffixOverrides=",">
  74. <if test="userId != null">user_id,</if>
  75. <if test="userType != null">user_type,</if>
  76. <if test="courseId != null">course_id,</if>
  77. <if test="videoId != null">video_id,</if>
  78. <if test="type != null">type,</if>
  79. <if test="parentId != null">parent_id,</if>
  80. <if test="content != null">content,</if>
  81. <if test="createTime != null">create_time,</if>
  82. <if test="updateTime != null">update_time,</if>
  83. <if test="isRevoke != null">is_revoke,</if>
  84. <if test="time != null">`time`,</if>
  85. <if test="fontSize != null">font_size,</if>
  86. <if test="mode != null">mode,</if>
  87. <if test="color != null">color,</if>
  88. </trim>
  89. <trim prefix="values (" suffix=")" suffixOverrides=",">
  90. <if test="userId != null">#{userId},</if>
  91. <if test="userType != null">#{userType},</if>
  92. <if test="courseId != null">#{courseId},</if>
  93. <if test="videoId != null">#{videoId},</if>
  94. <if test="type != null">#{type},</if>
  95. <if test="parentId != null">#{parentId},</if>
  96. <if test="content != null">#{content},</if>
  97. <if test="createTime != null">#{createTime},</if>
  98. <if test="updateTime != null">#{updateTime},</if>
  99. <if test="isRevoke != null">#{isRevoke},</if>
  100. <if test="time != null">#{time},</if>
  101. <if test="fontSize != null">#{fontSize},</if>
  102. <if test="mode != null">#{mode},</if>
  103. <if test="color != null">#{color},</if>
  104. </trim>
  105. </insert>
  106. <update id="updateFsCourseWatchComment" parameterType="FsCourseWatchComment">
  107. update fs_course_watch_comment
  108. <trim prefix="SET" suffixOverrides=",">
  109. <if test="userId != null">user_id = #{userId},</if>
  110. <if test="userType != null">user_type = #{userType},</if>
  111. <if test="courseId != null">course_id = #{courseId},</if>
  112. <if test="videoId != null">video_id = #{videoId},</if>
  113. <if test="type != null">type = #{type},</if>
  114. <if test="parentId != null">parent_id = #{parentId},</if>
  115. <if test="content != null">content = #{content},</if>
  116. <if test="createTime != null">create_time = #{createTime},</if>
  117. <if test="updateTime != null">update_time = #{updateTime},</if>
  118. <if test="isRevoke != null">is_revoke = #{isRevoke},</if>
  119. <if test="time != null">`time` = #{time},</if>
  120. <if test="fontSize != null">font_size = #{fontSize},</if>
  121. <if test="mode != null">mode = #{mode},</if>
  122. <if test="color != null">color = #{color},</if>
  123. </trim>
  124. where comment_id = #{commentId}
  125. </update>
  126. <delete id="deleteFsCourseWatchCommentByCommentId" parameterType="Long">
  127. delete from fs_course_watch_comment where comment_id = #{commentId}
  128. </delete>
  129. <delete id="deleteFsCourseWatchCommentByCommentIds" parameterType="String">
  130. delete from fs_course_watch_comment where comment_id in
  131. <foreach item="commentId" collection="array" open="(" separator="," close=")">
  132. #{commentId}
  133. </foreach>
  134. </delete>
  135. <select id="selectH5CourseWatchComments" resultType="com.fs.course.vo.FsCourseWatchCommentVO">
  136. select cwc.comment_id, cwc.user_id, cwc.user_type, cwc.course_id, cwc.video_id, cwc.type, cwc.content, cwc.create_time,
  137. fs_user.nick_name,cwc.time,cwc.font_size, cwc.mode, cwc.color from fs_course_watch_comment cwc
  138. left join fs_user on fs_user.user_id = cwc.user_id
  139. <where>
  140. and cwc.is_revoke = 0
  141. <if test="courseId != null">
  142. and cwc.course_id = #{courseId}
  143. </if>
  144. <if test="videoId != null">
  145. and cwc.video_id = #{videoId}
  146. </if>
  147. </where>
  148. order by cwc.create_time desc
  149. </select>
  150. <select id="selectH5CourseWatchCommentsRound" resultType="com.fs.course.vo.FsCourseWatchCommentVO">
  151. select * from (
  152. select cwc.comment_id, cwc.user_id, cwc.user_type, cwc.course_id, cwc.video_id, cwc.type, cwc.content,
  153. cwc.create_time,
  154. fs_user.nick_name,cwc.time,cwc.font_size, cwc.mode, cwc.color from fs_course_watch_comment cwc
  155. left join fs_user on fs_user.user_id = cwc.user_id
  156. <where>
  157. and cwc.is_revoke = 0
  158. <if test="courseId != null">
  159. and cwc.course_id = #{courseId}
  160. </if>
  161. <if test="videoId != null">
  162. and cwc.video_id = #{videoId}
  163. </if>
  164. </where>
  165. ORDER BY RAND() LIMIT #{listNum}
  166. ) a
  167. </select>
  168. </mapper>