<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.wzj.soopin.content.mapper.CommentMapper" >
  <resultMap id="BaseResultMap" type="com.wzj.soopin.content.domain.po.Comment" >
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" property="id" jdbcType="VARCHAR" />
    	<result column="member_id" property="vlogerId" jdbcType="VARCHAR" />
    <result column="father_comment_id" property="fatherCommentId" jdbcType="VARCHAR" />
    <result column="vlog_id" property="vlogId" jdbcType="VARCHAR" />
    <result column="comment_user_id" property="commentUserId" jdbcType="VARCHAR" />
    <result column="content" property="content" jdbcType="VARCHAR" />
    <result column="like_counts" property="likeCounts" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <!-- 根据视频ID查询评论列表 -->
  <select id="selectByVlogId" resultType="com.wzj.soopin.content.domain.po.Comment">
    SELECT * FROM cont_comment
    WHERE vlog_id = #{vlogId}
    ORDER BY create_time DESC
  </select>

  <!-- 根据父评论ID查询子评论列表 -->
  <select id="selectByFatherCommentId" resultType="com.wzj.soopin.content.domain.po.Comment">
    SELECT * FROM cont_comment
    WHERE father_comment_id = #{fatherCommentId}
    ORDER BY create_time ASC
  </select>

  <!-- 根据评论ID查询评论信息 -->
  <select id="selectByCommentId" resultType="com.wzj.soopin.content.domain.po.Comment">
    SELECT * FROM cont_comment
    WHERE id = #{commentId}
  </select>

  <!-- 根据视频ID统计评论数量 -->
  <select id="countByVlogId" resultType="java.lang.Integer">
    SELECT COUNT(*) FROM cont_comment
    WHERE vlog_id = #{vlogId}
  </select>
</mapper>
