<?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.read.video.SvideoVideoReadMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.video.pojo.SvideoVideo">
    <id column="video_id" property="videoId" />
    <result column="video_name" property="videoName" />
    <result column="video_path" property="videoPath" />
    <result column="video_image" property="videoImage" />
    <result column="video_theme_image" property="videoThemeImage" />
    <result column="introduction" property="introduction" />
    <result column="author_id" property="authorId" />
    <result column="member_name" property="memberName" />
    <result column="member_nickname" property="memberNickname" />
    <result column="member_avatar" property="memberAvatar" />
    <result column="like_num" property="likeNum" />
    <result column="comment_num" property="commentNum" />
    <result column="share_num" property="shareNum" />
    <result column="goods_num" property="goodsNum" />
    <result column="click_num" property="clickNum" />
    <result column="label_id" property="labelId" />
    <result column="label_name" property="labelName" />
    <result column="is_delete" property="isDelete" />
    <result column="state" property="state" />
    <result column="remark" property="remark" />
    <result column="create_time" property="createTime" />
    <result column="update_time" property="updateTime" />
    <result column="video_type" property="videoType" />
    <result column="video_content" property="videoContent" />
    <result column="image_info" property="imageInfo" />
    <result column="width" property="width" />
    <result column="height" property="height" />
  </resultMap>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `video_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.videoIdNotEquals != null">
          AND `video_id` != #{example.videoIdNotEquals}
        </if>
        <if test="example.videoIdIn != null">
          AND `video_id` in (${example.videoIdIn})
        </if>
        <if test="example.videoName != null">
          AND `video_name` = #{example.videoName}
        </if>
        <if test="example.videoNameLike != null">
          AND `video_name` like concat('%',#{example.videoNameLike},'%')
        </if>
        <if test="example.videoPath != null">
          AND `video_path` = #{example.videoPath}
        </if>
        <if test="example.videoImage != null">
          AND `video_image` = #{example.videoImage}
        </if>
        <if test="example.videoThemeImage != null">
          AND `video_theme_image` = #{example.videoThemeImage}
        </if>
        <if test="example.introduction != null">
          AND `introduction` = #{example.introduction}
        </if>
        <if test="example.authorId != null">
          AND `author_id` = #{example.authorId}
        </if>
        <if test="example.memberName != null">
          AND `member_name` = #{example.memberName}
        </if>
        <if test="example.memberNameLike != null">
          AND `member_name` like concat('%',#{example.memberNameLike},'%')
        </if>
        <if test="example.memberNicknameLike != null">
          AND `author_id` in ( select `author_id` from `author` where `member_nickname` like concat('%',#{example.memberNicknameLike},'%') )
        </if>
        <if test="example.memberNickname != null">
          AND `member_nickname` = #{example.memberNickname}
        </if>
        <if test="example.memberAvatar != null">
          AND `member_avatar` = #{example.memberAvatar}
        </if>
        <if test="example.likeNum != null">
          AND `like_num` = #{example.likeNum}
        </if>
        <if test="example.commentNum != null">
          AND `comment_num` = #{example.commentNum}
        </if>
        <if test="example.shareNum != null">
          AND `share_num` = #{example.shareNum}
        </if>
        <if test="example.goodsNum != null">
          AND `goods_num` = #{example.goodsNum}
        </if>
        <if test="example.goodsNumLike != null">
          AND `goods_num` like concat('%',#{example.goodsNumLike},'%')
        </if>
        <if test="example.clickNum != null">
          AND `click_num` = #{example.clickNum}
        </if>
        <if test="example.labelId != null">
          AND `label_id` = #{example.labelId}
        </if>
        <if test="example.labelName != null">
          AND `label_name` = #{example.labelName}
        </if>
        <if test="example.labelNameLike != null">
          AND `label_name` like concat('%',#{example.labelNameLike},'%')
        </if>
        <if test="example.isDelete != null">
          AND `is_delete` = #{example.isDelete}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.stateIn != null">
          AND `state` in (${example.stateIn})
        </if>
        <if test="example.stateNotIn != null">
          AND `state` not in (${example.stateNotIn})
        </if>
        <if test="example.stateNotEquals != null">
          AND `state` != #{example.stateNotEquals}
        </if>
        <if test="example.remark != null">
          AND `remark` = #{example.remark}
        </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.updateTimeAfter != null">
          AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
        </if>
        <if test="example.updateTimeBefore != null">
          AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
        </if>
        <if test="example.videoType != null">
          AND `video_type` = #{example.videoType}
        </if>
        <if test="example.videoContent != null">
          AND `video_content` = #{example.videoContent}
        </if>
        <if test="example.videoContentLike != null">
          AND `video_content` like concat('%',#{example.videoContentLike},'%')
        </if>
        <if test="example.imageInfo != null">
          AND `image_info` = #{example.imageInfo}
        </if>
        <if test="example.width != null">
          AND `width` = #{example.width}
        </if>
        <if test="example.height != null">
          AND `height` = #{example.height}
        </if>
        <if test="example.keyword != null">
          AND ( `video_name` LIKE concat('%',#{example.keyword},'%') OR `introduction` LIKE concat('%',#{example.keyword},'%') )
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `video_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.SvideoVideoExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `svideo_video`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `svideo_video`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `svideo_video`
    <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_video`
    <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_video`
    <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_video`
    <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>
</mapper>