<?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.BilibiliUpInfoDao">
  <resultMap id="BaseResultMap" type="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="url" jdbcType="VARCHAR" property="url" />
    <result column="mid" jdbcType="INTEGER" property="mid" />
    <result column="roomid" jdbcType="INTEGER" property="roomid" />
    <result column="offlineListening" jdbcType="INTEGER" property="offlinelistening" />
    <result column="saveDanmu" jdbcType="INTEGER" property="savedanmu" />
    <result column="enable" jdbcType="INTEGER" property="enable" />
    <result column="live" jdbcType="INTEGER" property="live" />
    <result column="saveLive" jdbcType="INTEGER" property="savelive" />
  </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, `name`, url, mid, roomid, offlineListening, saveDanmu, `enable`, live, saveLive
  </sql>
  <select id="selectByExample" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfoExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from bilibili_up_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_up_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from bilibili_up_info
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfoExample">
    delete from bilibili_up_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.BilibiliUpInfo" useGeneratedKeys="true">
    insert into bilibili_up_info (`name`, url, mid, 
      roomid, offlineListening, saveDanmu, 
      `enable`, live, saveLive
      )
    values (#{name,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{mid,jdbcType=INTEGER}, 
      #{roomid,jdbcType=INTEGER}, #{offlinelistening,jdbcType=INTEGER}, #{savedanmu,jdbcType=INTEGER}, 
      #{enable,jdbcType=INTEGER}, #{live,jdbcType=INTEGER}, #{savelive,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo" useGeneratedKeys="true">
    insert into bilibili_up_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="name != null">
        `name`,
      </if>
      <if test="url != null">
        url,
      </if>
      <if test="mid != null">
        mid,
      </if>
      <if test="roomid != null">
        roomid,
      </if>
      <if test="offlinelistening != null">
        offlineListening,
      </if>
      <if test="savedanmu != null">
        saveDanmu,
      </if>
      <if test="enable != null">
        `enable`,
      </if>
      <if test="live != null">
        live,
      </if>
      <if test="savelive != null">
        saveLive,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        #{url,jdbcType=VARCHAR},
      </if>
      <if test="mid != null">
        #{mid,jdbcType=INTEGER},
      </if>
      <if test="roomid != null">
        #{roomid,jdbcType=INTEGER},
      </if>
      <if test="offlinelistening != null">
        #{offlinelistening,jdbcType=INTEGER},
      </if>
      <if test="savedanmu != null">
        #{savedanmu,jdbcType=INTEGER},
      </if>
      <if test="enable != null">
        #{enable,jdbcType=INTEGER},
      </if>
      <if test="live != null">
        #{live,jdbcType=INTEGER},
      </if>
      <if test="savelive != null">
        #{savelive,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfoExample" resultType="java.lang.Long">
    select count(*) from bilibili_up_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update bilibili_up_info
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.name != null">
        `name` = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.url != null">
        url = #{record.url,jdbcType=VARCHAR},
      </if>
      <if test="record.mid != null">
        mid = #{record.mid,jdbcType=INTEGER},
      </if>
      <if test="record.roomid != null">
        roomid = #{record.roomid,jdbcType=INTEGER},
      </if>
      <if test="record.offlinelistening != null">
        offlineListening = #{record.offlinelistening,jdbcType=INTEGER},
      </if>
      <if test="record.savedanmu != null">
        saveDanmu = #{record.savedanmu,jdbcType=INTEGER},
      </if>
      <if test="record.enable != null">
        `enable` = #{record.enable,jdbcType=INTEGER},
      </if>
      <if test="record.live != null">
        live = #{record.live,jdbcType=INTEGER},
      </if>
      <if test="record.savelive != null">
        saveLive = #{record.savelive,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update bilibili_up_info
    set id = #{record.id,jdbcType=INTEGER},
      `name` = #{record.name,jdbcType=VARCHAR},
      url = #{record.url,jdbcType=VARCHAR},
      mid = #{record.mid,jdbcType=INTEGER},
      roomid = #{record.roomid,jdbcType=INTEGER},
      offlineListening = #{record.offlinelistening,jdbcType=INTEGER},
      saveDanmu = #{record.savedanmu,jdbcType=INTEGER},
      `enable` = #{record.enable,jdbcType=INTEGER},
      live = #{record.live,jdbcType=INTEGER},
      saveLive = #{record.savelive,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo">
    update bilibili_up_info
    <set>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="url != null">
        url = #{url,jdbcType=VARCHAR},
      </if>
      <if test="mid != null">
        mid = #{mid,jdbcType=INTEGER},
      </if>
      <if test="roomid != null">
        roomid = #{roomid,jdbcType=INTEGER},
      </if>
      <if test="offlinelistening != null">
        offlineListening = #{offlinelistening,jdbcType=INTEGER},
      </if>
      <if test="savedanmu != null">
        saveDanmu = #{savedanmu,jdbcType=INTEGER},
      </if>
      <if test="enable != null">
        `enable` = #{enable,jdbcType=INTEGER},
      </if>
      <if test="live != null">
        live = #{live,jdbcType=INTEGER},
      </if>
      <if test="savelive != null">
        saveLive = #{savelive,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yutou.bilibili.mybatis.Bili.mybatis.model.BilibiliUpInfo">
    update bilibili_up_info
    set `name` = #{name,jdbcType=VARCHAR},
      url = #{url,jdbcType=VARCHAR},
      mid = #{mid,jdbcType=INTEGER},
      roomid = #{roomid,jdbcType=INTEGER},
      offlineListening = #{offlinelistening,jdbcType=INTEGER},
      saveDanmu = #{savedanmu,jdbcType=INTEGER},
      `enable` = #{enable,jdbcType=INTEGER},
      live = #{live,jdbcType=INTEGER},
      saveLive = #{savelive,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>


  <select id="queryToRoomIds"
          resultMap="BaseResultMap">
    select * from `bilibili_up_info`
    <where>

      <foreach collection="roomid" item='item' open=" (" close=")" separator="or"> roomid=#{item,jdbcType=INTEGER}
      </foreach>
    </where>
    ;
  </select>
</mapper>