<?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.iformall.mapper.WxComponentVerifyTicketMapper">
    <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxComponentVerifyTicket">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="component_appid" jdbcType="VARCHAR" property="componentAppid"/>
        <result column="component_verify_ticket" jdbcType="VARCHAR" property="componentVerifyTicket"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="deadline" jdbcType="TIMESTAMP" property="deadline"/>
        <result column="access_token" jdbcType="VARCHAR" property="accessToken"/>
        <result column="access_token_expire" jdbcType="TIMESTAMP" property="accessTokenExpire"/>
    </resultMap>

    <sql id="allColumns">
	    `id`,`component_appid`,`component_verify_ticket`,`create_time`,`deadline`
	</sql>

    <sql id="dynamicWhereConditions">
        where 1 = 1
        <if test=" null != id ">
            and `id` = #{id}
        </if>
        <if test=" null != componentAppid ">
            and `component_appid` = #{componentAppid}
        </if>
        <if test=" null != componentVerifyTicket ">
            and `component_verify_ticket` like concat('%', #{componentVerifyTicket},'%')
        </if>
        <if test=" null != createTime ">
            and `create_time` = #{createTime}
        </if>
        <if test=" null != deadline ">
            and `deadline` = #{deadline}
        </if>
        <if test=" null != ids ">
            and id in
            <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
                #{idItem}
            </foreach>
        </if>
        <if test=" null != sortColumns">order by ${sortColumns}</if>
    </sql>

    <select id="findList" parameterType="com.iformall.domain.po.WxComponentVerifyTicket" resultMap="BaseResultMap">
        select
        <include refid="allColumns"/>
        from wx_component_verify_ticket
        <include refid="dynamicWhereConditions"/>
    </select>

    <update id="updateAccessToken" parameterType="com.iformall.domain.po.WxComponentVerifyTicket">
        update wx_component_verify_ticket
        set `access_token` = #{accessToken}, `access_token_expire` = #{accessTokenExpire}
        where component_appid = #{componentAppid}
    </update>


</mapper>
