FsUserVideoCommentMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.FsUserVideoCommentMapper">
  6. <resultMap type="FsUserVideoComment" id="FsUserVideoCommentResult">
  7. <result property="commentId" column="comment_id" />
  8. <result property="userId" column="user_id" />
  9. <result property="videoId" column="video_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="synced" column="synced" />
  18. <result property="commentCode" column="comment_code" />
  19. </resultMap>
  20. <sql id="selectFsUserVideoCommentVo">
  21. select comment_id,synced, user_id,comment_code, video_id, type, parent_id, content, reply_count, create_time, update_time, likes from fs_user_video_comment
  22. </sql>
  23. <select id="selectFsUserVideoCommentList" parameterType="FsUserVideoComment" resultMap="FsUserVideoCommentResult">
  24. <include refid="selectFsUserVideoCommentVo"/>
  25. <where>
  26. <if test="userId != null "> and user_id = #{userId}</if>
  27. <if test="videoId != null "> and video_id = #{videoId}</if>
  28. <if test="type != null "> and type = #{type}</if>
  29. <if test="parentId != null "> and parent_id = #{parentId}</if>
  30. <if test="content != null and content != ''"> and content = #{content}</if>
  31. <if test="replyCount != null "> and reply_count = #{replyCount}</if>
  32. <if test="likes != null "> and likes = #{likes}</if>
  33. </where>
  34. </select>
  35. <select id="selectFsUserVideoCommentByCommentId" parameterType="Long" resultMap="FsUserVideoCommentResult">
  36. <include refid="selectFsUserVideoCommentVo"/>
  37. where comment_id = #{commentId}
  38. </select>
  39. <insert id="insertFsUserVideoComment" parameterType="FsUserVideoComment" useGeneratedKeys="true" keyProperty="commentId">
  40. insert into fs_user_video_comment
  41. <trim prefix="(" suffix=")" suffixOverrides=",">
  42. <if test="userId != null">user_id,</if>
  43. <if test="videoId != null">video_id,</if>
  44. <if test="type != null">type,</if>
  45. <if test="parentId != null">parent_id,</if>
  46. <if test="content != null">content,</if>
  47. <if test="replyCount != null">reply_count,</if>
  48. <if test="createTime != null">create_time,</if>
  49. <if test="updateTime != null">update_time,</if>
  50. <if test="likes != null">likes,</if>
  51. <if test="commentCode != null">comment_code,</if>
  52. <if test="synced != null">synced,</if>
  53. </trim>
  54. <trim prefix="values (" suffix=")" suffixOverrides=",">
  55. <if test="userId != null">#{userId},</if>
  56. <if test="videoId != null">#{videoId},</if>
  57. <if test="type != null">#{type},</if>
  58. <if test="parentId != null">#{parentId},</if>
  59. <if test="content != null">#{content},</if>
  60. <if test="replyCount != null">#{replyCount},</if>
  61. <if test="createTime != null">#{createTime},</if>
  62. <if test="updateTime != null">#{updateTime},</if>
  63. <if test="likes != null">#{likes},</if>
  64. <if test="commentCode != null">#{commentCode},</if>
  65. <if test="synced != null">#{synced},</if>
  66. </trim>
  67. </insert>
  68. <update id="updateFsUserVideoComment" parameterType="FsUserVideoComment">
  69. update fs_user_video_comment
  70. <trim prefix="SET" suffixOverrides=",">
  71. <if test="userId != null">user_id = #{userId},</if>
  72. <if test="videoId != null">video_id = #{videoId},</if>
  73. <if test="type != null">type = #{type},</if>
  74. <if test="parentId != null">parent_id = #{parentId},</if>
  75. <if test="content != null">content = #{content},</if>
  76. <if test="replyCount != null">reply_count = #{replyCount},</if>
  77. <if test="createTime != null">create_time = #{createTime},</if>
  78. <if test="updateTime != null">update_time = #{updateTime},</if>
  79. <if test="likes != null">likes = #{likes},</if>
  80. <if test="commentCode != null">comment_code = #{commentCode},</if>
  81. <if test="synced != null">synced = #{synced},</if>
  82. </trim>
  83. where comment_id = #{commentId}
  84. </update>
  85. <delete id="deleteFsUserVideoCommentByCommentId" parameterType="Long">
  86. delete from fs_user_video_comment where comment_id = #{commentId}
  87. </delete>
  88. <delete id="deleteFsUserVideoCommentByCommentIds" parameterType="String">
  89. delete from fs_user_video_comment where comment_id in
  90. <foreach item="commentId" collection="array" open="(" separator="," close=")">
  91. #{commentId}
  92. </foreach>
  93. </delete>
  94. <insert id="batchInsertComments" parameterType="java.util.List">
  95. INSERT INTO fs_user_video_comment (video_id, user_id,comment_code, content, create_time, parent_id,synced)
  96. VALUES
  97. <foreach collection="comments" item="comment" separator=",">
  98. (#{comment.videoId}, #{comment.userId},#{comment.commentCode}, #{comment.content}, #{comment.createTime}, #{comment.parentId},#{comment.synced})
  99. </foreach>
  100. </insert>
  101. </mapper>