<?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.yinet.wx.mapper.WxCacheMapper">

    <resultMap type="com.yinet.wx.domain.WxCache" id="WxCacheResult">
        <result property="wxCacheId" column="wx_cache_id"/>
        <result property="accessToken" column="access_token"/>
        <result property="jsapiTicket" column="jsapi_ticket"/>
        <result property="tokenTime" column="token_time"/>
        <result property="ticketTime" column="ticket_time"/>
    </resultMap>
    <select id="getAccessToken" resultMap="WxCacheResult">
        select * from wx_cache limit 1
    </select>
    <update id="updateWxCache" parameterType="WxCache">
        UPDATE wx_cache
        SET
        access_token = #{accessToken.accessToken},
        jsapi_ticket = #{accessToken.jsapiTicket},
        token_time=#{accessToken.tokenTime},
        ticket_time=#{accessToken.ticketTime}
        WHERE
        wx_cache_id=#{accessToken.wxCacheId}
    </update>
    <insert id="insertWxCache" parameterType="WxCache">
        INSERT INTO wx_cache (
        access_token,
        jsapi_ticket,
        token_time,
        ticket_time
        )VALUES(
        #{accessToken.accessToken},
        #{accessToken.jsapiTicket},
        #{accessToken.tokenTime},
        #{accessToken.ticketTime}
        );
    </insert>
</mapper>