zxl
73 分钟以前 e2e015e02fb67ef7c348fbcb2152a34ccb34004d
framework/src/main/resources/mapper/lmk/VideoCommentMapper.xml
@@ -10,11 +10,16 @@
        <result column="reply_id" property="replyId" />
        <result column="reply_user_id" property="replyUserId" />
        <result column="reply_user_nickname" property="replyUserNickname" />
        <result column="reply_user_avatar" property="replyUserAvatar" />
        <result column="master_comment_id" property="masterCommentId" />
        <result column="status" property="status" />
        <result column="create_by" property="userId" />
        <result column="thumbs_up_num" property="thumbsUpNum" />
        <result column="userId" property="userId" />
        <result column="user_nickname" property="userNickname" />
        <result column="user_avatar" property="userAvatar" />
        <result column="create_time" property="createTime" />
        <result column="replyTotalCount" property="replyTotalCount" />
        <result column="has_thumbs_up" property="hasThumbsUp" />
    </resultMap>
@@ -28,9 +33,16 @@
            LVC.video_id,
            LVC.comment_content,
            LVC.reply_id,
            LVC.reply_user_id,
            LVC.reply_user_nickname,
            LVC.master_comment_id,
            LVC.status,
            LVC.id
            LVC.thumbs_up_num,
            LVC.id,
            LVC.user_id,
            LVC.user_nickname,
            LVC.user_avatar,
            LVC.create_time
        FROM
            lmk_video_comment LVC
        WHERE
@@ -43,9 +55,16 @@
            LVC.video_id,
            LVC.comment_content,
            LVC.reply_id,
            LVC.reply_user_id,
            LVC.reply_user_nickname,
            LVC.master_comment_id,
            LVC.status,
            LVC.id
            LVC.thumbs_up_num,
            LVC.id,
            LVC.user_id,
            LVC.user_nickname,
            LVC.user_avatar,
            LVC.create_time
        FROM
            lmk_video_comment LVC
        WHERE
@@ -60,19 +79,33 @@
            LVC.reply_id,
            LVC.reply_user_id,
            LVC.reply_user_nickname,
            LVC.reply_user_avatar,
            LVC.master_comment_id,
            LVC.status,
            LVC.thumbs_up_num,
            LVC.id,
            LVC.create_by,
            LVC.user_id,
            LVC.user_nickname,
            LVC.user_avatar
            LVC.user_avatar,
            LVC.create_time,
            COUNT(replies.id) as replyTotalCount,
            CASE
                WHEN TUC.id IS NOT NULL THEN 1
                ELSE 0
                END AS has_thumbs_up
        FROM
             lmk_video_comment LVC
            lmk_video_comment LVC
                LEFT JOIN lmk_video_comment replies ON replies.master_comment_id = LVC.id AND replies.status = 'normal' AND replies.delete_flag = 0
                LEFT JOIN lmk_thumbs_up_record TUC ON LVC.id = TUC.ref_id AND TUC.thumbs_up_type = 'video_comment' AND TUC.user_id = #{query.userId} AND TUC.delete_flag = 0
        WHERE
              LVC.id = LVC.master_comment_id
              AND LVC.video_id = #{query.videoId}
              AND LVC.status = 'normal'
              AND LVC.delete_flag = 0
            LVC.master_comment_id IS NULL
          AND LVC.video_id = #{query.videoId}
          AND LVC.status = 'normal'
          AND LVC.delete_flag = 0
        GROUP BY
            LVC.id, LVC.video_id, LVC.comment_content, LVC.reply_id,
            LVC.reply_user_id, LVC.reply_user_nickname, LVC.master_comment_id,
            LVC.status, LVC.user_id, LVC.user_nickname, LVC.user_avatar, LVC.create_time
        ORDER BY
            LVC.create_time DESC
    </select>
@@ -84,17 +117,25 @@
            LVC.reply_id,
            LVC.reply_user_id,
            LVC.reply_user_nickname,
            LVC.reply_user_avatar,
            LVC.master_comment_id,
            LVC.status,
            LVC.thumbs_up_num,
            LVC.id,
            LVC.create_by,
            LVC.user_id,
            LVC.user_nickname,
            LVC.user_avatar
            LVC.user_avatar,
            LVC.create_time,
            0 as replyTotalCount,
            CASE
                WHEN TUC.id IS NOT NULL THEN 1
                ELSE 0
                END AS has_thumbs_up
        FROM
            lmk_video_comment LVC
                LEFT JOIN lmk_thumbs_up_record TUC ON LVC.id = TUC.ref_id AND TUC.thumbs_up_type = 'video_comment' AND TUC.user_id = #{query.userId} AND TUC.delete_flag = 0
        WHERE
              LVC.id = LVC.master_comment_id
              AND LVC.video_id = #{query.videoId}
              LVC.video_id = #{query.videoId}
              AND LVC.master_comment_id = #{query.masterCommentId}
              AND LVC.status = 'normal'
              AND LVC.delete_flag = 0
@@ -102,4 +143,32 @@
            LVC.create_time ASC
    </select>
    <select id="countNumGroupByVideo" resultType="cn.lili.modules.lmk.domain.vo.CollectTypeNumVO">
        SELECT
               LV.id as id,
               COUNT(LVC.video_id) as countNum
        FROM
             lmk_video LV
                LEFT JOIN lmk_video_comment LVC ON LVC.video_id = LV.id AND LVC.delete_flag = 0 AND LVC.status = 'normal'
        WHERE
             LV.comment_num_job = 1 AND LV.delete_flag = 0 AND LV.status = '1'
        GROUP BY
             LVC.video_id
    </select>
    <update id="updateCommentThumbsUpNumBatch">
        UPDATE lmk_video_comment
        SET thumbs_up_num = CASE id
        <foreach collection="list" item="comment">
            WHEN #{comment.id} THEN #{comment.countNum}
        </foreach>
        ELSE thumbs_up_num
        END
        WHERE id IN
        <foreach collection="list" item="comment" open="(" separator="," close=")">
            #{comment.id}
        </foreach>
    </update>
</mapper>