<?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.yd.dal.mapper.tencent.TenInterfRecordMapper">
  <resultMap id="BaseResultMap" type="com.yd.dal.entity.tencent.TenInterfRecord">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="interf_type" jdbcType="VARCHAR" property="interfType" />
    <result column="appid" jdbcType="VARCHAR" property="appid" />
    <result column="secret" jdbcType="VARCHAR" property="secret" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="grant_type" jdbcType="VARCHAR" property="grantType" />
    <result column="component_appid" jdbcType="VARCHAR" property="componentAppid" />
    <result column="component_access_token" jdbcType="VARCHAR" property="componentAccessToken" />
    <result column="i_type" jdbcType="VARCHAR" property="iType" />
    <result column="access_token" jdbcType="VARCHAR" property="accessToken" />
    <result column="expires_in" jdbcType="BIGINT" property="expiresIn" />
    <result column="refresh_token" jdbcType="VARCHAR" property="refreshToken" />
    <result column="openid" jdbcType="VARCHAR" property="openid" />
    <result column="i_scope" jdbcType="VARCHAR" property="iScope" />
    <result column="errcode" jdbcType="VARCHAR" property="errcode" />
    <result column="errmsg" jdbcType="VARCHAR" property="errmsg" />
    <result column="ticket" jdbcType="VARCHAR" property="ticket" />
    <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
  </resultMap>
  <sql id="Base_Column_List">
    id, interf_type, appid, secret, code, grant_type, component_appid, component_access_token, 
    i_type, access_token, expires_in, refresh_token, openid, i_scope, errcode, errmsg, 
    ticket, created_at
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from ag_ten_interf_record
    where id = #{id,jdbcType=BIGINT}
  </select>
    <select id="findByTenInterfRecordOrderBy" resultMap="BaseResultMap">
      select
      <include refid="Base_Column_List" />
      from ag_ten_interf_record
        <where>
          <if test="info.id != null">
            and id = #{info.id,jdbcType=VARCHAR}
          </if>
          <if test="info.interfType != null">
            and interf_type = #{info.interfType,jdbcType=VARCHAR}
          </if>
          <if test="info.appid != null">
            and appid = #{info.appid,jdbcType=VARCHAR}
          </if>
          <if test="info.secret != null">
            and secret = #{info.secret,jdbcType=VARCHAR}
          </if>
          <if test="info.code != null">
            and code = #{info.code,jdbcType=VARCHAR}
          </if>
          <if test="info.grantType != null">
            and grant_type = #{info.grantType,jdbcType=VARCHAR}
          </if>
          <if test="info.componentAppid != null">
            and component_appid = #{info.componentAppid,jdbcType=VARCHAR}
          </if>
          <if test="info.componentAccessToken != null">
            and component_access_token = #{info.componentAccessToken,jdbcType=VARCHAR}
          </if>
          <if test="info.iType != null">
            and i_type = #{info.iType,jdbcType=VARCHAR}
          </if>
          <if test="info.accessToken != null">
            and access_token = #{info.accessToken,jdbcType=VARCHAR}
          </if>
          <if test="info.expiresIn != null">
            and expires_in = #{info.expiresIn,jdbcType=BIGINT}
          </if>
          <if test="info.refreshToken != null">
            and refresh_token = #{info.refreshToken,jdbcType=VARCHAR}
          </if>
          <if test="info.openid != null">
            and openid = #{info.openid,jdbcType=VARCHAR}
          </if>
          <if test="info.iScope != null">
            and i_scope = #{info.iScope,jdbcType=VARCHAR}
          </if>
          <if test="info.errcode != null">
            and errcode = #{info.errcode,jdbcType=VARCHAR}
          </if>
          <if test="info.errmsg != null">
            and errmsg = #{info.errmsg,jdbcType=VARCHAR}
          </if>
          <if test="info.ticket != null">
            and ticket = #{info.ticket,jdbcType=VARCHAR}
          </if>
          <if test="info.createdAt != null">
            and created_at = #{info.createdAt,jdbcType=TIMESTAMP}
          </if>
        </where>
      <if test="orderBy != null ">
        order by ${orderBy}
      </if>
    </select>
    <select id="findByAppIdAndGrantType" resultType="com.yd.dal.entity.tencent.TenInterfRecord">
      select
        <include refid="Base_Column_List"></include>
      from ag_ten_interf_record t
      where t.interf_type = #{type}
        and t.appid = #{appId}
        and t.grant_type = #{grantType}
        and t.expires_in is not null
        and t.created_at >(NOW() - INTERVAL 1 DAY) order by created_at desc
    </select>
  <select id="findByAccessTokenAndIType" resultType="com.yd.dal.entity.tencent.TenInterfRecord">
    select
    <include refid="Base_Column_List"></include>
    from ag_ten_interf_record t
    where t.interf_type = #{type}
    and t.access_token = #{accessToken}
    and t.i_type = #{pType}
    and t.expires_in is not null
    and t.created_at >(NOW() - INTERVAL 1 DAY) order by created_at desc
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ag_ten_interf_record
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.tencent.TenInterfRecord" useGeneratedKeys="true">
    insert into ag_ten_interf_record (interf_type, appid, secret, 
      code, grant_type, component_appid, 
      component_access_token, i_type, access_token, 
      expires_in, refresh_token, openid, 
      i_scope, errcode, errmsg, 
      ticket, created_at)
    values (#{interfType,jdbcType=VARCHAR}, #{appid,jdbcType=VARCHAR}, #{secret,jdbcType=VARCHAR}, 
      #{code,jdbcType=VARCHAR}, #{grantType,jdbcType=VARCHAR}, #{componentAppid,jdbcType=VARCHAR}, 
      #{componentAccessToken,jdbcType=VARCHAR}, #{iType,jdbcType=VARCHAR}, #{accessToken,jdbcType=VARCHAR}, 
      #{expiresIn,jdbcType=BIGINT}, #{refreshToken,jdbcType=VARCHAR}, #{openid,jdbcType=VARCHAR}, 
      #{iScope,jdbcType=VARCHAR}, #{errcode,jdbcType=VARCHAR}, #{errmsg,jdbcType=VARCHAR}, 
      #{ticket,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yd.dal.entity.tencent.TenInterfRecord" useGeneratedKeys="true">
    insert into ag_ten_interf_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="interfType != null">
        interf_type,
      </if>
      <if test="appid != null">
        appid,
      </if>
      <if test="secret != null">
        secret,
      </if>
      <if test="code != null">
        code,
      </if>
      <if test="grantType != null">
        grant_type,
      </if>
      <if test="componentAppid != null">
        component_appid,
      </if>
      <if test="componentAccessToken != null">
        component_access_token,
      </if>
      <if test="iType != null">
        i_type,
      </if>
      <if test="accessToken != null">
        access_token,
      </if>
      <if test="expiresIn != null">
        expires_in,
      </if>
      <if test="refreshToken != null">
        refresh_token,
      </if>
      <if test="openid != null">
        openid,
      </if>
      <if test="iScope != null">
        i_scope,
      </if>
      <if test="errcode != null">
        errcode,
      </if>
      <if test="errmsg != null">
        errmsg,
      </if>
      <if test="ticket != null">
        ticket,
      </if>
      <if test="createdAt != null">
        created_at,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="interfType != null">
        #{interfType,jdbcType=VARCHAR},
      </if>
      <if test="appid != null">
        #{appid,jdbcType=VARCHAR},
      </if>
      <if test="secret != null">
        #{secret,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="grantType != null">
        #{grantType,jdbcType=VARCHAR},
      </if>
      <if test="componentAppid != null">
        #{componentAppid,jdbcType=VARCHAR},
      </if>
      <if test="componentAccessToken != null">
        #{componentAccessToken,jdbcType=VARCHAR},
      </if>
      <if test="iType != null">
        #{iType,jdbcType=VARCHAR},
      </if>
      <if test="accessToken != null">
        #{accessToken,jdbcType=VARCHAR},
      </if>
      <if test="expiresIn != null">
        #{expiresIn,jdbcType=BIGINT},
      </if>
      <if test="refreshToken != null">
        #{refreshToken,jdbcType=VARCHAR},
      </if>
      <if test="openid != null">
        #{openid,jdbcType=VARCHAR},
      </if>
      <if test="iScope != null">
        #{iScope,jdbcType=VARCHAR},
      </if>
      <if test="errcode != null">
        #{errcode,jdbcType=VARCHAR},
      </if>
      <if test="errmsg != null">
        #{errmsg,jdbcType=VARCHAR},
      </if>
      <if test="ticket != null">
        #{ticket,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        #{createdAt,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yd.dal.entity.tencent.TenInterfRecord">
    update ag_ten_interf_record
    <set>
      <if test="interfType != null">
        interf_type = #{interfType,jdbcType=VARCHAR},
      </if>
      <if test="appid != null">
        appid = #{appid,jdbcType=VARCHAR},
      </if>
      <if test="secret != null">
        secret = #{secret,jdbcType=VARCHAR},
      </if>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="grantType != null">
        grant_type = #{grantType,jdbcType=VARCHAR},
      </if>
      <if test="componentAppid != null">
        component_appid = #{componentAppid,jdbcType=VARCHAR},
      </if>
      <if test="componentAccessToken != null">
        component_access_token = #{componentAccessToken,jdbcType=VARCHAR},
      </if>
      <if test="iType != null">
        i_type = #{iType,jdbcType=VARCHAR},
      </if>
      <if test="accessToken != null">
        access_token = #{accessToken,jdbcType=VARCHAR},
      </if>
      <if test="expiresIn != null">
        expires_in = #{expiresIn,jdbcType=BIGINT},
      </if>
      <if test="refreshToken != null">
        refresh_token = #{refreshToken,jdbcType=VARCHAR},
      </if>
      <if test="openid != null">
        openid = #{openid,jdbcType=VARCHAR},
      </if>
      <if test="iScope != null">
        i_scope = #{iScope,jdbcType=VARCHAR},
      </if>
      <if test="errcode != null">
        errcode = #{errcode,jdbcType=VARCHAR},
      </if>
      <if test="errmsg != null">
        errmsg = #{errmsg,jdbcType=VARCHAR},
      </if>
      <if test="ticket != null">
        ticket = #{ticket,jdbcType=VARCHAR},
      </if>
      <if test="createdAt != null">
        created_at = #{createdAt,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yd.dal.entity.tencent.TenInterfRecord">
    update ag_ten_interf_record
    set interf_type = #{interfType,jdbcType=VARCHAR},
      appid = #{appid,jdbcType=VARCHAR},
      secret = #{secret,jdbcType=VARCHAR},
      code = #{code,jdbcType=VARCHAR},
      grant_type = #{grantType,jdbcType=VARCHAR},
      component_appid = #{componentAppid,jdbcType=VARCHAR},
      component_access_token = #{componentAccessToken,jdbcType=VARCHAR},
      i_type = #{iType,jdbcType=VARCHAR},
      access_token = #{accessToken,jdbcType=VARCHAR},
      expires_in = #{expiresIn,jdbcType=BIGINT},
      refresh_token = #{refreshToken,jdbcType=VARCHAR},
      openid = #{openid,jdbcType=VARCHAR},
      i_scope = #{iScope,jdbcType=VARCHAR},
      errcode = #{errcode,jdbcType=VARCHAR},
      errmsg = #{errmsg,jdbcType=VARCHAR},
      ticket = #{ticket,jdbcType=VARCHAR},
      created_at = #{createdAt,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>