FsUserCourseCommentMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.FsUserCourseCommentMapper">
  6. <resultMap type="FsUserCourseComment" id="FsUserCourseCommentResult">
  7. <result property="commentId" column="comment_id" />
  8. <result property="userId" column="user_id" />
  9. <result property="courseId" column="course_id" />
  10. <result property="type" column="type" />
  11. <result property="parentId" column="parent_id" />
  12. <result property="content" column="content" />
  13. <result property="replyCount" column="reply_count" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="likes" column="likes" />
  17. <result property="toUserId" column="to_user_id" />
  18. <result property="isDel" column="is_del" />
  19. <result property="nickName" column="nick_name" />
  20. </resultMap>
  21. <sql id="selectFsUserCourseCommentVo">
  22. select comment_id,to_user_id, user_id,is_del, course_id, type, parent_id, content, reply_count, create_time, update_time, likes, nick_name from fs_user_course_comment
  23. </sql>
  24. <select id="selectFsUserCourseCommentList" parameterType="FsUserCourseComment" resultMap="FsUserCourseCommentResult">
  25. <include refid="selectFsUserCourseCommentVo"/>
  26. <where>
  27. <if test="userId != null "> and user_id = #{userId}</if>
  28. <if test="courseId != null "> and course_id = #{courseId}</if>
  29. <if test="type != null "> and type = #{type}</if>
  30. <if test="parentId != null "> and parent_id = #{parentId}</if>
  31. <if test="content != null and content != ''"> and content = #{content}</if>
  32. <if test="replyCount != null "> and reply_count = #{replyCount}</if>
  33. <if test="likes != null "> and likes = #{likes}</if>
  34. <if test="isDel != null "> and is_del = #{isDel}</if>
  35. </where>
  36. </select>
  37. <select id="selectFsUserCourseCommentByCommentId" parameterType="Long" resultMap="FsUserCourseCommentResult">
  38. <include refid="selectFsUserCourseCommentVo"/>
  39. where comment_id = #{commentId}
  40. </select>
  41. <insert id="insertFsUserCourseComment" parameterType="FsUserCourseComment" useGeneratedKeys="true" keyProperty="commentId">
  42. insert into fs_user_course_comment
  43. <trim prefix="(" suffix=")" suffixOverrides=",">
  44. <if test="userId != null">user_id,</if>
  45. <if test="courseId != null">course_id,</if>
  46. <if test="type != null">type,</if>
  47. <if test="parentId != null">parent_id,</if>
  48. <if test="content != null">content,</if>
  49. <if test="replyCount != null">reply_count,</if>
  50. <if test="createTime != null">create_time,</if>
  51. <if test="updateTime != null">update_time,</if>
  52. <if test="likes != null">likes,</if>
  53. <if test="toUserId != null">to_user_id,</if>
  54. <if test="isDel != null">is_del,</if>
  55. <if test="nickName != null">nick_name,</if>
  56. </trim>
  57. <trim prefix="values (" suffix=")" suffixOverrides=",">
  58. <if test="userId != null">#{userId},</if>
  59. <if test="courseId != null">#{courseId},</if>
  60. <if test="type != null">#{type},</if>
  61. <if test="parentId != null">#{parentId},</if>
  62. <if test="content != null">#{content},</if>
  63. <if test="replyCount != null">#{replyCount},</if>
  64. <if test="createTime != null">#{createTime},</if>
  65. <if test="updateTime != null">#{updateTime},</if>
  66. <if test="likes != null">#{likes},</if>
  67. <if test="toUserId != null">#{toUserId},</if>
  68. <if test="isDel != null">#{isDel},</if>
  69. <if test="nickName != null">#{nickName},</if>
  70. </trim>
  71. </insert>
  72. <update id="updateFsUserCourseComment" parameterType="FsUserCourseComment">
  73. update fs_user_course_comment
  74. <trim prefix="SET" suffixOverrides=",">
  75. <if test="userId != null">user_id = #{userId},</if>
  76. <if test="courseId != null">course_id = #{courseId},</if>
  77. <if test="type != null">type = #{type},</if>
  78. <if test="parentId != null">parent_id = #{parentId},</if>
  79. <if test="content != null">content = #{content},</if>
  80. <if test="replyCount != null">reply_count = #{replyCount},</if>
  81. <if test="createTime != null">create_time = #{createTime},</if>
  82. <if test="updateTime != null">update_time = #{updateTime},</if>
  83. <if test="likes != null">likes = #{likes},</if>
  84. <if test="toUserId != null">to_user_id = #{toUserId},</if>
  85. <if test="isDel != null">is_del = #{isDel},</if>
  86. <if test="nickName != null">nick_name = #{nickName},</if>
  87. </trim>
  88. where comment_id = #{commentId}
  89. </update>
  90. <update id="deleteFsUserCourseCommentByCommentId" parameterType="Long">
  91. update fs_user_course_comment set is_del = 1 where comment_id = #{commentId}
  92. </update>
  93. <update id="deleteFsUserCourseCommentByCommentIds" parameterType="String">
  94. update fs_user_course_comment set is_del = 1 where comment_id in
  95. <foreach item="commentId" collection="array" open="(" separator="," close=")">
  96. #{commentId}
  97. </foreach>
  98. </update>
  99. <select id="selectFsUserCourseCommentListByTypeAndCourseId" resultType="com.fs.course.domain.FsUserCourseComment">
  100. select * from fs_user_course_comment where type = #{type} and course_id = #{courseId} and is_del = 0 order by create_time desc
  101. </select>
  102. <select id="selectCommentsByCourseIdAndUserIds" resultMap="FsUserCourseCommentResult">
  103. <include refid="selectFsUserCourseCommentVo"/>
  104. WHERE course_id = #{courseId} AND type = 1 AND is_del = 0
  105. AND user_id IN
  106. <foreach item="userId" collection="userIds" open="(" separator="," close=")">
  107. #{userId}
  108. </foreach>
  109. ORDER BY user_id, create_time ASC
  110. </select>
  111. </mapper>