<?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.slodon.b2b2c.dao.write.video.SvideoReplyWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.video.pojo.SvideoReply">
    <id column="reply_id" property="replyId" />
    <result column="parent_reply_id" property="parentReplyId" />
    <result column="comment_id" property="commentId" />
    <result column="from_author_id" property="fromAuthorId" />
    <result column="from_author_name" property="fromAuthorName" />
    <result column="member_avatar" property="memberAvatar" />
    <result column="to_author_id" property="toAuthorId" />
    <result column="to_author_name" property="toAuthorName" />
    <result column="like_num" property="likeNum" />
    <result column="video_id" property="videoId" />
    <result column="video_image" property="videoImage" />
    <result column="is_read" property="isRead" />
    <result column="create_time" property="createTime" />
    <result column="content" property="content" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="parentReplyId != null">
        `parent_reply_id`,
      </if>
      <if test="commentId != null">
        `comment_id`,
      </if>
      <if test="fromAuthorId != null">
        `from_author_id`,
      </if>
      <if test="fromAuthorName != null">
        `from_author_name`,
      </if>
      <if test="memberAvatar != null">
        `member_avatar`,
      </if>
      <if test="toAuthorId != null">
        `to_author_id`,
      </if>
      <if test="toAuthorName != null">
        `to_author_name`,
      </if>
      <if test="likeNum != null">
        `like_num`,
      </if>
      <if test="videoId != null">
        `video_id`,
      </if>
      <if test="videoImage != null">
        `video_image`,
      </if>
      <if test="isRead != null">
        `is_read`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="content != null">
        `content`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `reply_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.replyIdNotEquals != null">
          AND `reply_id` != #{example.replyIdNotEquals}
        </if>
        <if test="example.replyIdIn != null">
          AND `reply_id` in (${example.replyIdIn})
        </if>
        <if test="example.parentReplyId != null">
          AND `parent_reply_id` = #{example.parentReplyId}
        </if>
        <if test="example.commentId != null">
          AND `comment_id` = #{example.commentId}
        </if>
        <if test="example.fromAuthorId != null">
          AND `from_author_id` = #{example.fromAuthorId}
        </if>
        <if test="example.fromAuthorName != null">
          AND `from_author_name` = #{example.fromAuthorName}
        </if>
        <if test="example.fromAuthorNameLike != null">
          AND `from_author_name` like concat('%',#{example.fromAuthorNameLike},'%')
        </if>
        <if test="example.memberAvatar != null">
          AND `member_avatar` = #{example.memberAvatar}
        </if>
        <if test="example.toAuthorId != null">
          AND `to_author_id` = #{example.toAuthorId}
        </if>
        <if test="example.toAuthorName != null">
          AND `to_author_name` = #{example.toAuthorName}
        </if>
        <if test="example.toAuthorNameLike != null">
          AND `to_author_name` like concat('%',#{example.toAuthorNameLike},'%')
        </if>
        <if test="example.likeNum != null">
          AND `like_num` = #{example.likeNum}
        </if>
        <if test="example.videoId != null">
          AND `video_id` = #{example.videoId}
        </if>
        <if test="example.videoImage != null">
          AND `video_image` = #{example.videoImage}
        </if>
        <if test="example.isRead != null">
          AND `is_read` = #{example.isRead}
        </if>
        <if test="example.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
        <if test="example.content != null">
          AND `content` = #{example.content}
        </if>
        <if test="example.contentLike != null">
          AND `content` like concat('%',#{example.contentLike},'%')
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `reply_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.video.example.SvideoReplyExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `svideo_reply`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `svideo_reply`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `svideo_reply`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `svideo_reply`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `svideo_reply`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `svideo_reply`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `svideo_reply`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `svideo_reply`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="reply_id" keyProperty="replyId" parameterType="com.slodon.b2b2c.video.pojo.SvideoReply" useGeneratedKeys="true">
    INSERT INTO `svideo_reply`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="parentReplyId != null">
        #{parentReplyId},
      </if>
      <if test="commentId != null">
        #{commentId},
      </if>
      <if test="fromAuthorId != null">
        #{fromAuthorId},
      </if>
      <if test="fromAuthorName != null">
        #{fromAuthorName},
      </if>
      <if test="memberAvatar != null">
        #{memberAvatar},
      </if>
      <if test="toAuthorId != null">
        #{toAuthorId},
      </if>
      <if test="toAuthorName != null">
        #{toAuthorName},
      </if>
      <if test="likeNum != null">
        #{likeNum},
      </if>
      <if test="videoId != null">
        #{videoId},
      </if>
      <if test="videoImage != null">
        #{videoImage},
      </if>
      <if test="isRead != null">
        #{isRead},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="content != null">
        #{content},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `svideo_reply`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.parentReplyId != null">
        `parent_reply_id` = #{record.parentReplyId},
      </if>
      <if test="record.commentId != null">
        `comment_id` = #{record.commentId},
      </if>
      <if test="record.fromAuthorId != null">
        `from_author_id` = #{record.fromAuthorId},
      </if>
      <if test="record.fromAuthorName != null">
        `from_author_name` = #{record.fromAuthorName},
      </if>
      <if test="record.memberAvatar != null">
        `member_avatar` = #{record.memberAvatar},
      </if>
      <if test="record.toAuthorId != null">
        `to_author_id` = #{record.toAuthorId},
      </if>
      <if test="record.toAuthorName != null">
        `to_author_name` = #{record.toAuthorName},
      </if>
      <if test="record.likeNum != null">
        `like_num` = #{record.likeNum},
      </if>
      <if test="record.videoId != null">
        `video_id` = #{record.videoId},
      </if>
      <if test="record.videoImage != null">
        `video_image` = #{record.videoImage},
      </if>
      <if test="record.isRead != null">
        `is_read` = #{record.isRead},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.content != null">
        `content` = #{record.content},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `svideo_reply`
    <trim prefix="SET" suffixOverrides=",">
      <if test="parentReplyId != null">
        `parent_reply_id` = #{parentReplyId},
      </if>
      <if test="commentId != null">
        `comment_id` = #{commentId},
      </if>
      <if test="fromAuthorId != null">
        `from_author_id` = #{fromAuthorId},
      </if>
      <if test="fromAuthorName != null">
        `from_author_name` = #{fromAuthorName},
      </if>
      <if test="memberAvatar != null">
        `member_avatar` = #{memberAvatar},
      </if>
      <if test="toAuthorId != null">
        `to_author_id` = #{toAuthorId},
      </if>
      <if test="toAuthorName != null">
        `to_author_name` = #{toAuthorName},
      </if>
      <if test="likeNum != null">
        `like_num` = #{likeNum},
      </if>
      <if test="videoId != null">
        `video_id` = #{videoId},
      </if>
      <if test="videoImage != null">
        `video_image` = #{videoImage},
      </if>
      <if test="isRead != null">
        `is_read` = #{isRead},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="content != null">
        `content` = #{content},
      </if>
    </trim>
    WHERE `reply_id` = #{replyId}
  </update>
</mapper>