<?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.yutou.bilibili.mybatis.Bili.mybatis.dao.BilibiliLiveInfoDao">
  <resultMap id="BaseResultMap" type="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfo">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="roomid" jdbcType="INTEGER" property="roomid" />
    <result column="popular" jdbcType="INTEGER" property="popular" />
    <result column="userIndex" jdbcType="INTEGER" property="userindex" />
    <result column="vipUserIndex" jdbcType="INTEGER" property="vipuserindex" />
    <result column="giftUser" jdbcType="INTEGER" property="giftuser" />
    <result column="subtime" jdbcType="TIMESTAMP" property="subtime" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, roomid, popular, userIndex, vipUserIndex, giftUser, subtime
  </sql>
  <select id="selectByExample" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfoExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from bilibili_live_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from bilibili_live_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from bilibili_live_info
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfoExample">
    delete from bilibili_live_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfo" useGeneratedKeys="true">
    insert into bilibili_live_info (roomid, popular, userIndex, 
      vipUserIndex, giftUser, subtime
      )
    values (#{roomid,jdbcType=INTEGER}, #{popular,jdbcType=INTEGER}, #{userindex,jdbcType=INTEGER}, 
      #{vipuserindex,jdbcType=INTEGER}, #{giftuser,jdbcType=INTEGER}, #{subtime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfo" useGeneratedKeys="true">
    insert into bilibili_live_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="roomid != null">
        roomid,
      </if>
      <if test="popular != null">
        popular,
      </if>
      <if test="userindex != null">
        userIndex,
      </if>
      <if test="vipuserindex != null">
        vipUserIndex,
      </if>
      <if test="giftuser != null">
        giftUser,
      </if>
      <if test="subtime != null">
        subtime,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="roomid != null">
        #{roomid,jdbcType=INTEGER},
      </if>
      <if test="popular != null">
        #{popular,jdbcType=INTEGER},
      </if>
      <if test="userindex != null">
        #{userindex,jdbcType=INTEGER},
      </if>
      <if test="vipuserindex != null">
        #{vipuserindex,jdbcType=INTEGER},
      </if>
      <if test="giftuser != null">
        #{giftuser,jdbcType=INTEGER},
      </if>
      <if test="subtime != null">
        #{subtime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfoExample" resultType="java.lang.Long">
    select count(*) from bilibili_live_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update bilibili_live_info
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.roomid != null">
        roomid = #{record.roomid,jdbcType=INTEGER},
      </if>
      <if test="record.popular != null">
        popular = #{record.popular,jdbcType=INTEGER},
      </if>
      <if test="record.userindex != null">
        userIndex = #{record.userindex,jdbcType=INTEGER},
      </if>
      <if test="record.vipuserindex != null">
        vipUserIndex = #{record.vipuserindex,jdbcType=INTEGER},
      </if>
      <if test="record.giftuser != null">
        giftUser = #{record.giftuser,jdbcType=INTEGER},
      </if>
      <if test="record.subtime != null">
        subtime = #{record.subtime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update bilibili_live_info
    set id = #{record.id,jdbcType=INTEGER},
      roomid = #{record.roomid,jdbcType=INTEGER},
      popular = #{record.popular,jdbcType=INTEGER},
      userIndex = #{record.userindex,jdbcType=INTEGER},
      vipUserIndex = #{record.vipuserindex,jdbcType=INTEGER},
      giftUser = #{record.giftuser,jdbcType=INTEGER},
      subtime = #{record.subtime,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfo">
    update bilibili_live_info
    <set>
      <if test="roomid != null">
        roomid = #{roomid,jdbcType=INTEGER},
      </if>
      <if test="popular != null">
        popular = #{popular,jdbcType=INTEGER},
      </if>
      <if test="userindex != null">
        userIndex = #{userindex,jdbcType=INTEGER},
      </if>
      <if test="vipuserindex != null">
        vipUserIndex = #{vipuserindex,jdbcType=INTEGER},
      </if>
      <if test="giftuser != null">
        giftUser = #{giftuser,jdbcType=INTEGER},
      </if>
      <if test="subtime != null">
        subtime = #{subtime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliLiveInfo">
    update bilibili_live_info
    set roomid = #{roomid,jdbcType=INTEGER},
      popular = #{popular,jdbcType=INTEGER},
      userIndex = #{userindex,jdbcType=INTEGER},
      vipUserIndex = #{vipuserindex,jdbcType=INTEGER},
      giftUser = #{giftuser,jdbcType=INTEGER},
      subtime = #{subtime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="queryTimeOfRoomid"
          resultMap="BaseResultMap">
    select * from `bilibili_live_info`
    <where>
      <if test="startTime!=null">
        subtime>=#{startTime,jdbcType=TIMESTAMP}
      </if>
      <if test="endTime!=null">
        AND subtime <![CDATA[<=]]> #{endTime,jdbcType=TIMESTAMP}
      </if>
      <if test="roomid!=null">
        AND roomid=#{roomid,jdbcType=INTEGER}
      </if>
    </where>
    ;
  </select>
</mapper>