<?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.ruixuan.launch.mapper.AccountTokenMapper">

    <resultMap type="com.ruixuan.launch.entity.AccountToken" id="AccountTokenResult">
        <result property="id" column="id"/>
        <result property="mediaId" column="media_id"/>
        <result property="agentId" column="agent_id"/>
        <result property="accessToken" column="access_token"/>
        <result property="accessTokenExpiresIn" column="access_token_expires_in"/>
        <result property="refreshToken" column="refresh_token"/>
        <result property="refreshTokenExpiresIn" column="refresh_token_expires_in"/>
        <result property="agentType" column="agent_type"/>
        <result property="appId" column="app_id"/>
        <result property="secret" column="secret"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectAccountTokenVo">
        select id,
               media_id,
               agent_id,
               access_token,
               access_token_expires_in,
               refresh_token,
               refresh_token_expires_in,
               agent_type,
               app_id,
               secret,
               create_time,
               update_time
        from agent_token
    </sql>

    <select id="selectAccountTokenById" parameterType="String" resultMap="AccountTokenResult">
        <include refid="selectAccountTokenVo"/>
        where id = #{id}
    </select>

    <select id="getKuaishouToken" parameterType="Long" resultMap="AccountTokenResult">
        <include refid="selectAccountTokenVo"/>
        where media_id = 2
        limit 1
    </select>

</mapper>