<?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.qs.mp.framework.mapper.AppTokenMapper" >
  <resultMap id="BaseResultMap" type="com.qs.mp.framework.domain.AppToken" >
    <id column="_id" property="id" jdbcType="INTEGER" />
    <result column="app_id" property="appId" jdbcType="VARCHAR" />
    <result column="access_token" property="accessToken" jdbcType="VARCHAR" />
    <result column="app_secret" property="appSecret" jdbcType="VARCHAR" />
    <result column="expire_timestamp" property="expireTimestamp" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" 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="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    _id, app_id, access_token, app_secret, expire_timestamp
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.qs.mp.framework.domain.AppTokenExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    'true' as QUERYID,
    <include refid="Base_Column_List" />
    from qs_app_token
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from qs_app_token
    where app_id = #{appId}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from qs_app_token
    where _id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.qs.mp.framework.domain.AppToken" >
    insert into qs_app_token (_id, app_id, access_token, 
      app_secret, expire_timestamp)
    values (#{id,jdbcType=INTEGER}, #{appId,jdbcType=VARCHAR}, #{accessToken,jdbcType=VARCHAR}, 
      #{appSecret,jdbcType=VARCHAR}, #{expireTimestamp,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.qs.mp.framework.domain.AppToken" >
    insert into qs_app_token
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        _id,
      </if>
      <if test="appId != null" >
        app_id,
      </if>
      <if test="accessToken != null" >
        access_token,
      </if>
      <if test="appSecret != null" >
        app_secret,
      </if>
      <if test="expireTimestamp != null" >
        expire_timestamp,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="appId != null" >
        #{appId,jdbcType=VARCHAR},
      </if>
      <if test="accessToken != null" >
        #{accessToken,jdbcType=VARCHAR},
      </if>
      <if test="appSecret != null" >
        #{appSecret,jdbcType=VARCHAR},
      </if>
      <if test="expireTimestamp != null" >
        #{expireTimestamp,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.qs.mp.framework.domain.AppTokenExample" resultType="java.lang.Integer" >
    select count(*) from qs_app_token
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update qs_app_token
    <set >
      <if test="record.id != null" >
        _id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.appId != null" >
        app_id = #{record.appId,jdbcType=VARCHAR},
      </if>
      <if test="record.accessToken != null" >
        access_token = #{record.accessToken,jdbcType=VARCHAR},
      </if>
      <if test="record.appSecret != null" >
        app_secret = #{record.appSecret,jdbcType=VARCHAR},
      </if>
      <if test="record.expireTimestamp != null" >
        expire_timestamp = #{record.expireTimestamp,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update qs_app_token
    set _id = #{record.id,jdbcType=INTEGER},
      app_id = #{record.appId,jdbcType=VARCHAR},
      access_token = #{record.accessToken,jdbcType=VARCHAR},
      app_secret = #{record.appSecret,jdbcType=VARCHAR},
      expire_timestamp = #{record.expireTimestamp,jdbcType=TIMESTAMP}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.qs.mp.framework.domain.AppToken" >
    update qs_app_token
    <set >
      <if test="appId != null" >
        app_id = #{appId,jdbcType=VARCHAR},
      </if>
      <if test="accessToken != null" >
        access_token = #{accessToken,jdbcType=VARCHAR},
      </if>
      <if test="appSecret != null" >
        app_secret = #{appSecret,jdbcType=VARCHAR},
      </if>
      <if test="expireTimestamp != null" >
        expire_timestamp = #{expireTimestamp,jdbcType=TIMESTAMP},
      </if>
    </set>
    where _id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.qs.mp.framework.domain.AppToken" >
    update qs_app_token
    set app_id = #{appId,jdbcType=VARCHAR},
      access_token = #{accessToken,jdbcType=VARCHAR},
      app_secret = #{appSecret,jdbcType=VARCHAR},
      expire_timestamp = #{expireTimestamp,jdbcType=TIMESTAMP}
    where _id = #{id,jdbcType=INTEGER}
  </update>
</mapper>