<?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.dao.UUserDao">
  <resultMap id="BaseResultMap" type="com.yutou.bilibili.mybatis.model.UUser">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="user" jdbcType="VARCHAR" property="user" />
    <result column="password" jdbcType="VARCHAR" property="password" />
    <result column="power" jdbcType="VARCHAR" property="power" />
    <result column="bili_cookie" jdbcType="VARCHAR" property="biliCookie" />
    <result column="loginToken" jdbcType="VARCHAR" property="logintoken" />
    <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, `user`, `password`, `power`, bili_cookie, loginToken, subtime
  </sql>
  <select id="selectByExample" parameterType="com.yutou.bilibili.mybatis.model.UUserExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from u_user
    <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 u_user
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from u_user
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.yutou.bilibili.mybatis.model.UUserExample">
    delete from u_user
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.bilibili.mybatis.model.UUser" useGeneratedKeys="true">
    insert into u_user (`user`, `password`, `power`, 
      bili_cookie, loginToken, subtime
      )
    values (#{user,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{power,jdbcType=VARCHAR}, 
      #{biliCookie,jdbcType=VARCHAR}, #{logintoken,jdbcType=VARCHAR}, #{subtime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.bilibili.mybatis.model.UUser" useGeneratedKeys="true">
    insert into u_user
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="user != null">
        `user`,
      </if>
      <if test="password != null">
        `password`,
      </if>
      <if test="power != null">
        `power`,
      </if>
      <if test="biliCookie != null">
        bili_cookie,
      </if>
      <if test="logintoken != null">
        loginToken,
      </if>
      <if test="subtime != null">
        subtime,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="user != null">
        #{user,jdbcType=VARCHAR},
      </if>
      <if test="password != null">
        #{password,jdbcType=VARCHAR},
      </if>
      <if test="power != null">
        #{power,jdbcType=VARCHAR},
      </if>
      <if test="biliCookie != null">
        #{biliCookie,jdbcType=VARCHAR},
      </if>
      <if test="logintoken != null">
        #{logintoken,jdbcType=VARCHAR},
      </if>
      <if test="subtime != null">
        #{subtime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.yutou.bilibili.mybatis.model.UUserExample" resultType="java.lang.Long">
    select count(*) from u_user
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update u_user
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.user != null">
        `user` = #{record.user,jdbcType=VARCHAR},
      </if>
      <if test="record.password != null">
        `password` = #{record.password,jdbcType=VARCHAR},
      </if>
      <if test="record.power != null">
        `power` = #{record.power,jdbcType=VARCHAR},
      </if>
      <if test="record.biliCookie != null">
        bili_cookie = #{record.biliCookie,jdbcType=VARCHAR},
      </if>
      <if test="record.logintoken != null">
        loginToken = #{record.logintoken,jdbcType=VARCHAR},
      </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 u_user
    set id = #{record.id,jdbcType=INTEGER},
      `user` = #{record.user,jdbcType=VARCHAR},
      `password` = #{record.password,jdbcType=VARCHAR},
      `power` = #{record.power,jdbcType=VARCHAR},
      bili_cookie = #{record.biliCookie,jdbcType=VARCHAR},
      loginToken = #{record.logintoken,jdbcType=VARCHAR},
      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.model.UUser">
    update u_user
    <set>
      <if test="user != null">
        `user` = #{user,jdbcType=VARCHAR},
      </if>
      <if test="password != null">
        `password` = #{password,jdbcType=VARCHAR},
      </if>
      <if test="power != null">
        `power` = #{power,jdbcType=VARCHAR},
      </if>
      <if test="biliCookie != null">
        bili_cookie = #{biliCookie,jdbcType=VARCHAR},
      </if>
      <if test="logintoken != null">
        loginToken = #{logintoken,jdbcType=VARCHAR},
      </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.model.UUser">
    update u_user
    set `user` = #{user,jdbcType=VARCHAR},
      `password` = #{password,jdbcType=VARCHAR},
      `power` = #{power,jdbcType=VARCHAR},
      bili_cookie = #{biliCookie,jdbcType=VARCHAR},
      loginToken = #{logintoken,jdbcType=VARCHAR},
      subtime = #{subtime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>